Skip to content

fix(workflow): handle finished replays before scheduling new runs - #8369

Open
AkshayShah03 wants to merge 1 commit into
google:mainfrom
AkshayShah03:fix/replay-join-scheduling
Open

AkshayShah03 wants to merge 1 commit into
google:mainfrom
AkshayShah03:fix/replay-join-scheduling

Conversation

@AkshayShah03

Copy link
Copy Markdown
Contributor

Fixes #8358

Problem

Since 6dbe5bb, a resumable Workflow that loops through a router, has a JoinNode, 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 raises Replay divergence detected: Timed out waiting for sequence key 'asker@1'.

A scheduler trace of the failing resume shows _run_loop starting b from a buffered trigger while a's replayed fast-forward has already finished but hasn't been handled. That starts a run which the recorded history places after a'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_loop pass, if any pending task is a replayed fast-forward that is already done, skip _schedule_ready_nodes and the checkpoint flush for that pass. asyncio.wait then returns that task immediately, its completion is handled in recorded order as usual, and scheduling resumes on the next pass. Fresh runs are unaffected because replayed_nodes only holds replayed fast-forwards. I also added this step to the _run_loop lifecycle in interface-workflow.md.

Testing Plan

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 richarmurray6y8-creator left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Resumable Workflow: answering a RequestInput in a looping graph hangs 15 s and fails with "Replay divergence detected" (since 6dbe5bb6d)

2 participants