Repository navigation
fix: a rerun does not save the task it runs again after queueing it - #1885
Merged
Merged
Conversation
rerunWF saves the task it reruns as SCHEDULED and queues it. finalizeRerun, its last step, then saved every task of the workflow, that task included, from the copy the rerun held in memory. A worker that took the task at once and finished it had its COMPLETED overwritten with SCHEDULED, while its update had already removed the queue message: the task waited for the sweeper to repair it. finalizeRerun now saves only the tasks it resets itself. What it resets and queues is unchanged. Seen live on retries that rerun a failed task immediately: 2 of 20 and 1 of 25 stalled until the sweeper; with the change, 40 of 40 completed within 1.8 s with the task run exactly twice and no sweeper repairs. testRerunDoesNotSaveTheTaskItRunsAgainAfterQueueingIt fails without the change.
mp-orkes
approved these changes
Nov 25, 2026
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.
Pull Request type
NOTE: Please remember to run
./gradlew spotlessApplyto fix any format violations.Changes in this PR
rerunWFsaves the task it reruns as SCHEDULED and queues it.finalizeRerun, its last step, then saved every task of the workflow, that task included, from the copy the rerun held in memory:A worker can take the task as soon as it is queued. If it finishes before that save, its COMPLETED is overwritten with SCHEDULED. Its update has already removed the queue message, so the task sits SCHEDULED with nothing on its queue until the sweeper repairs it.
finalizeRerunnow saves only the tasks it resets itself (the failed and canceled siblings it sets back to SCHEDULED or IN_PROGRESS). What it resets and queues is unchanged. The rerun task, saved and queued byrerunWF, is not saved again.How it was found: on the native workflows branch (#1832), whose retry reruns the failed task in place through
rerunWF, an immediate retry stalled until the sweeper in 2 of 20 and 1 of 25 runs. Any rerun from a task can hit the same window when a worker is fast enough. A build that logged each removal from the task's queue showed the order: the worker's COMPLETED update removed the message, then the rerun's bulk save put SCHEDULED back. With this change, 40 of 40 completed within 1.8 s, the task ran exactly twice, and there were no sweeper repairs.Tests
TestWorkflowExecutor.testRerunDoesNotSaveTheTaskItRunsAgainAfterQueueingItrecords every save of the rerun task after it was queued. It fails on main (updateTaskssaves it again) and passes with this change.core: 992 tests pass.test-harnessspecs that exercise rerun (SubWorkflowRerunSpec,HierarchicalForkJoinSubworkflowRerunSpec,ForkJoinSpec,WorkflowAndTaskConfigurationSpec,JsonJQTransformSpec,QueueResiliencySpec): 71 tests pass.Alternatives considered
rerunWF's queueing afterfinalizeRerun, and changes the order the existing comments rely on: tasks are saved before they are queued, so an async worker never reads a stale CANCELED/FAILED state.