Fix race condition calling workflow onComplete twice#7349
Merged
Conversation
Signed-off-by: Ben Sherman <bentshermann@gmail.com>
✅ Deploy Preview for nextflow-docs canceled.
|
Member
Author
|
Ideally I'd prefer the runtime to always throw an exception instead of calling I suspect the runtime is doing this when it's on a separate thread, to ensure the exception isn't lost. If we can establish a clean pattern for propagating exceptions from threads and apply it everywhere, that should greatly reduce the dependence on the session object For now, I think this fix is sensible given the current constraints |
jorgee
approved these changes
Jul 17, 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.
Fix #6692
PR #4299 created a race condition where certain errors (e.g. a failed retry) can cause onComplete handlers (from a trace observer) to be called twice
This is because certain error conditions
abort()the session directly from a separate thread instead of throwing an exception. The main thread still tears down the session viadestroy(). Both methods callshutdown0() -> notfiyFlowComplete(), in this case concurrently.The
shutdown0()already has a flag to prevent adding new hooks after shutdown, so this PR simply expands the flag to also make the method idempotent. Doesn't matter for the shutdown hooks since they are drained, but it does matter for the trace observers.