Repository navigation
fix(workflow): handle finished replays before scheduling new runs - #8369
Open
AkshayShah03 wants to merge 1 commit into
Open
AkshayShah03 wants to merge 1 commit into
AkshayShah03 wants to merge 1 commit into
Conversation
Since 6dbe5bb, a resumable workflow with a loop, a JoinNode and a dynamic child that asks for input could fail its second resume with a replay divergence. The run loop started a buffered trigger while a replayed fast-forward had already finished but not been handled, so a run that the recorded history places after that completion started first and the replay barrier waited for a recorded run that never came. Skip scheduling for a pass while a replayed task is already done, so its completion is handled first. Fixes google#8358
richarmurray6y8-creator
left a comment
There was a problem hiding this comment.
We reproduced the asker@1 timeout on the base revision and verified that the new regression test passes on this PR. All 88 HITL workflow tests passed locally.
We also saw a successor's body run before the scheduler handled a failure in a parallel branch in a controlled scheduler test. Did the successor's body execute in the fuzz case you mentioned? If you haven't checked that part yet, we'd be happy to put together a minimal workflow repro.
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.
Fixes #8358
Problem
Since 6dbe5bb, a resumable
Workflowthat loops through a router, has aJoinNode, and has a node whose dynamic child asks for input fails its second resume. It waits for the replay barrier's 15 s timeout and then raisesReplay divergence detected: Timed out waiting for sequence key 'asker@1'.A scheduler trace of the failing resume shows
_run_loopstartingbfrom a buffered trigger whilea's replayed fast-forward has already finished but hasn't been handled. That starts a run which the recorded history places aftera's completion, so the barrier waits for a recorded run that never comes. (@richarmurray6y8-creator described the same cause on the issue.)Solution
At the top of each
_run_looppass, if any pending task is a replayed fast-forward that is already done, skip_schedule_ready_nodesand the checkpoint flush for that pass.asyncio.waitthen returns that task immediately, its completion is handled in recorded order as usual, and scheduling resumes on the next pass. Fresh runs are unaffected becausereplayed_nodesonly holds replayed fast-forwards. I also added this step to the_run_looplifecycle ininterface-workflow.md.Testing Plan
test_resume_consumes_finished_replay_before_new_loop_runsintests/unittests/workflow/test_workflow_hitl.py, using the graph from Resumable Workflow: answering a RequestInput in a looping graph hangs 15 s and fails with "Replay divergence detected" (since 6dbe5bb6d) #8358 with a 0.5 s barrier timeout. On main it fails with the same replay divergence; with the fix all three questions are answered and the workflow ends. It passed 5 of 5 runs.pytest tests/unittests/workflow tests/unittests/runners tests/unittests/agents tests/unittests/flows: 3827 passed.wait_for_outputnodes, run resumable and non-resumable):