Fix concurrent local activity replay nondeterminism#1573
Draft
paulcacheux wants to merge 2 commits into
Draft
Conversation
Add a regression test that runs two concurrent coroutines (via asyncio.gather) each issuing multiple sequential local activities, then replays the recorded history. Without a fix, replay fails with NondeterminismError because local activity markers are consumed in a different order than the original execution.
During first execution, local activity resolve_activity jobs arrive in completion order (wall-clock). During replay, they arrive in sequence number order. When multiple coroutines issue local activities concurrently, this ordering difference causes coroutines to resume in a different order, assigning different sequence numbers to subsequent commands and triggering NondeterminismError. Fix by sorting local activity resolutions by sequence number before processing. This ensures coroutines always resume in scheduling order regardless of execution mode.
|
|
1 similar comment
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
When multiple coroutines issue local activities concurrently (e.g. via
asyncio.gather), replay can fail withNondeterminismError.During first execution, local activity
resolve_activityjobs arrive in completion order (wall-clock timing). During replay, they arrive in sequence number order. This ordering difference causes coroutines to resume in a different order, assigning different sequence numbers to subsequent commands, which no longer match the recorded markers.Fix
Sort local activity
resolve_activityjobs by sequence number before processing them in_WorkflowInstanceImpl.activate(). This ensures coroutines always resume in scheduling order regardless of execution mode (first-execution vs replay).The fix is safe for existing workflows:
NondeterminismErroranyway.Test
Added
test_workflow_concurrent_local_activity_replay: runs a workflow with two concurrent coroutines each issuing multiple sequential local activities, then replays the recorded history. Without the fix, replay fails withNondeterminismError.