Skip to content

Commit 6674c79

Browse files
authored
Fix history events buildup from version reject (#1220)
When an orchestration was being rejected due to a versioning mismatch an issue would cause the history events of the orchestration to build continuously. This was caused by the orchestration adding an OrchestrationStarted event before the versioning took place and was saved even on a rejected version. This change causes the versioning code to exit the process method entirely instead of just prematurely end the process loop. This avoids the commit of the history. Signed-off-by: halspang <[email protected]>
1 parent 1c09332 commit 6674c79

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

src/DurableTask.Core/TaskOrchestrationDispatcher.cs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ protected async Task<bool> OnProcessWorkItemAsync(TaskOrchestrationWorkItem work
406406
else // Abandon work item in all other cases (will be retried later).
407407
{
408408
await this.orchestrationService.AbandonTaskOrchestrationWorkItemAsync(workItem);
409-
break;
409+
return true;
410410
}
411411
}
412412
}
@@ -1059,9 +1059,10 @@ TaskMessage ProcessScheduleTaskDecision(
10591059
eventId: scheduleTaskOrchestratorAction.Id,
10601060
name: scheduleTaskOrchestratorAction.Name,
10611061
version: scheduleTaskOrchestratorAction.Version,
1062-
input: scheduleTaskOrchestratorAction.Input) {
1063-
Tags = scheduleTaskOrchestratorAction.Tags
1064-
};
1062+
input: scheduleTaskOrchestratorAction.Input)
1063+
{
1064+
Tags = scheduleTaskOrchestratorAction.Tags
1065+
};
10651066

10661067
ActivitySpanId clientSpanId = ActivitySpanId.CreateRandom();
10671068

@@ -1080,9 +1081,10 @@ TaskMessage ProcessScheduleTaskDecision(
10801081
scheduledEvent = new TaskScheduledEvent(
10811082
eventId: scheduleTaskOrchestratorAction.Id,
10821083
name: scheduleTaskOrchestratorAction.Name,
1083-
version: scheduleTaskOrchestratorAction.Version) {
1084-
Tags = scheduleTaskOrchestratorAction.Tags
1085-
};
1084+
version: scheduleTaskOrchestratorAction.Version)
1085+
{
1086+
Tags = scheduleTaskOrchestratorAction.Tags
1087+
};
10861088

10871089
if (parentTraceActivity != null)
10881090
{

test/DurableTask.AzureStorage.Tests/AzureStorageScenarioTests.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2518,6 +2518,9 @@ public async Task OrchestrationRejectsWithVersionMismatch()
25182518
status = await client.GetStatusAsync();
25192519
Assert.IsTrue(OrchestrationStatus.Running == status?.OrchestrationStatus || OrchestrationStatus.Pending == status?.OrchestrationStatus);
25202520

2521+
var history = await client.GetOrchestrationHistoryAsync(client.InstanceId);
2522+
Assert.AreEqual(0, history.Count, "A rejected orchestration should have no history as it should never have been started.");
2523+
25212524
await host.StopAsync();
25222525
}
25232526
}

0 commit comments

Comments
 (0)