Repository navigation
Conversation
retry stored the workflow as RUNNING and only then its task changes: the failed task marked retried, its copy, and the reopened JOIN. A decide in between, from the sweeper or an expedited decide, failed the workflow again on the failed task, and a JOIN evaluated before the copy had its seq failed on it too. The copy was then canceled before it started. A canceled JOIN was even queued before anything was stored. retry now queues the decider message, stores the task changes with the copies already numbered, stores RUNNING, queues the decider message again, and then queues the copies and the reopened tasks. Until RUNNING the workflow is terminal: the default sweeper drops it without deciding, and retry has queued no task. Because the message is queued first, a retry that cannot queue it stores nothing. A sweeper that read the workflow while it was terminal can remove that message, so it is queued again after the RUNNING write, also when that write fails after storing. Both wait out the workflow offset, so a decide does not come before the writes finish. No ExecutionDAO needs the workflow row to store a task, so archived workflows are unaffected. On a server whose workflows, queues, locks and index share one SQL database with 3 ms of added latency, retrying a dynamic fork whose branch failed, 8 at a time, lost the rescheduled branch in 203 of 240 retries; with the change, in 0 of 240. With only the first message, 210 of 240 workflows were RUNNING without one when the retry returned; with both, none were. testRetryStoresTheRescheduledTasksBeforeTheWorkflowIsRunning, testRetryQueuesAReopenedJoinOnlyAfterTheRescheduledTasksAreStored and testRetryQueuesTheDeciderMessageBeforeTheWorkflowIsRunning fail without the change. testRetryRequeuesTheDeciderMessageASweeperRemovedDuringItsTaskWrites fails without the second message, and testRetryRequeuesTheDeciderMessageWhenUpdateWorkflowFailsAfterItsWrite fails if a failed RUNNING write skips it. Fixes conductor-oss#1843
This branch has not been deployed
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
A retry of a workflow that failed on one branch of a dynamic fork could return 204 and fail again at once, with the rescheduled branch CANCELED before it started.
retrystored the workflow as RUNNING and only then its task changes: the failed task marked retried, its copy, and the reopened JOIN. A decide in between, from the sweeper or an expedited decide, saw a RUNNING workflow whose failed task was not yet marked retried and failed it again. A JOIN evaluated before the copy had its seq found the original failed branch and failed too. A CANCELED JOIN was queued before anything was stored.retrynow writes in this order:scheduleTaskinto a smallassignSeqhelper, unchanged for the other callers.scheduleTask) and the reopened JOIN, EXCLUSIVE_JOIN and DO_WHILE tasks.Until step 3 the workflow is terminal. The default sweeper drops a terminal workflow's message without deciding it, and retry has queued no task, so nothing acts on the half-written state. Because the message is queued first, a retry that cannot queue it stores nothing. A sweeper that read the workflow while it was still terminal can remove that first message, which is why it is queued again after step 3. Both pushes wait out the workflow offset (30 s by default), so the decide they trigger comes after the writes finish. The old comment about archived workflows does not hold: no
ExecutionDAO.updateTaskneeds the workflow row, so the order works the same for them.On a server with Postgres persistence, queue, lock and indexing, with 3 ms of added latency on Postgres, retrying
race_parentfrom the issue 8 at a time:These tests fail without the change:
testRetryStoresTheRescheduledTasksBeforeTheWorkflowIsRunning,testRetryQueuesAReopenedJoinOnlyAfterTheRescheduledTasksAreStoredandtestRetryQueuesTheDeciderMessageBeforeTheWorkflowIsRunning.testRetryRequeuesTheDeciderMessageASweeperRemovedDuringItsTaskWritesfails without the second push, andtestRetryRequeuesTheDeciderMessageWhenUpdateWorkflowFailsAfterItsWritefails if a failed RUNNING write skips it. They run the realDeciderService,Join,AsyncSystemTaskExecutorandWorkflowSweeperagainst the stored state at each write.Not in this PR:
PUT /api/workflow/decide/{workflowId}cancels those tasks, and the next retry works. On main, an interruption after the RUNNING write left a RUNNING workflow with no decider message, which retry refused as still running.Fixes #1843
Alternatives considered
retry. The lock does nothing unless a lock type is configured, it does not stop the JOIN system task, andterminateWorkflowreleases it before its final remove of the decider message. Ordering the writes fixes the race with or without a lock, as was done forrerun.