address PR feedback
This commit is contained in:
Родитель
d6e268f864
Коммит
e331a9c7cf
|
@ -118,22 +118,23 @@ namespace DurableTask.Netherite
|
|||
this.workItem.EventCount = historyState.History?.Count ?? 0;
|
||||
}
|
||||
|
||||
if (!this.IsExecutableInstance(this.workItem, out var reason, out bool traceWarningEvenForTimers))
|
||||
if (!this.IsExecutableInstance(this.workItem, out string reason, out bool isNormalSituationForTimerFired))
|
||||
{
|
||||
// this instance cannot be executed, so we are discarding the messages
|
||||
for (int i = 0; i < this.workItem.MessageBatch.MessagesToProcess.Count; i++)
|
||||
{
|
||||
TaskMessage message = this.workItem.MessageBatch.MessagesToProcess[i];
|
||||
|
||||
// since this can happen by design for canceled timers, we are not always creating warnings
|
||||
if (traceWarningEvenForTimers || ! (message.Event is TimerFiredEvent))
|
||||
if (isNormalSituationForTimerFired && message.Event is TimerFiredEvent)
|
||||
{
|
||||
partition.WorkItemTraceHelper.TraceTaskMessageDiscarded(
|
||||
continue; // do not trace a warning since it is a common situation
|
||||
}
|
||||
|
||||
partition.WorkItemTraceHelper.TraceTaskMessageDiscarded(
|
||||
this.PartitionId,
|
||||
message,
|
||||
this.workItem.MessageBatch.MessagesToProcessOrigin[i],
|
||||
reason);
|
||||
}
|
||||
}
|
||||
|
||||
// we issue a batch processed event which will remove the messages without updating the instance state
|
||||
|
@ -168,16 +169,16 @@ namespace DurableTask.Netherite
|
|||
this.workItem.Partition.EnqueueOrchestrationWorkItem(this.workItem);
|
||||
}
|
||||
|
||||
bool IsExecutableInstance(TaskOrchestrationWorkItem workItem, out string message, out bool traceWarningEvenForTimers)
|
||||
bool IsExecutableInstance(TaskOrchestrationWorkItem workItem, out string message, out bool isNormalSituationForTimerFired)
|
||||
{
|
||||
message = default;
|
||||
traceWarningEvenForTimers = default;
|
||||
|
||||
if (workItem.OrchestrationRuntimeState.ExecutionStartedEvent == null
|
||||
&& !this.MessagesToProcess.Any(msg => msg.Event is ExecutionStartedEvent))
|
||||
{
|
||||
if (DurableTask.Core.Common.Entities.AutoStart(this.InstanceId, this.MessagesToProcess))
|
||||
{
|
||||
isNormalSituationForTimerFired = default;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
|
@ -185,17 +186,17 @@ namespace DurableTask.Netherite
|
|||
if (DurableTask.Core.Common.Entities.IsEntityInstance(this.InstanceId))
|
||||
{
|
||||
message = "Instance is an entity that cannot process this type of message";
|
||||
traceWarningEvenForTimers = true;
|
||||
isNormalSituationForTimerFired = false;
|
||||
}
|
||||
else if (workItem.OrchestrationRuntimeState.Events.Count == 0)
|
||||
{
|
||||
message = "Instance does not exist (it may have been purged)";
|
||||
traceWarningEvenForTimers = false;
|
||||
isNormalSituationForTimerFired = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
message = $"Instance has an invalid history ({workItem.OrchestrationRuntimeState.Events} events)";
|
||||
traceWarningEvenForTimers = true;
|
||||
isNormalSituationForTimerFired = false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -206,10 +207,11 @@ namespace DurableTask.Netherite
|
|||
workItem.OrchestrationRuntimeState.OrchestrationStatus != OrchestrationStatus.Pending)
|
||||
{
|
||||
message = $"Instance is {workItem.OrchestrationRuntimeState.OrchestrationStatus}";
|
||||
traceWarningEvenForTimers = false;
|
||||
isNormalSituationForTimerFired = true;
|
||||
return false;
|
||||
}
|
||||
|
||||
isNormalSituationForTimerFired = default;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче