Repository navigation
fix(jobs): make completed->completed transition idempotent to prevent race errors - #1068
Conversation
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request introduces a critical fix for a race condition within the job execution system. Previously, jobs that completed successfully could still report an error if both the execution loop and the worker wrapper attempted to mark them as completed concurrently. By making the Highlights
Changelog
Activity
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
… race errors Both execution_loop and the worker wrapper in execute() can race to call mark_completed(). Previously the second call hit "Cannot transition from completed to completed" and errored the job despite successful completion. This narrowly allows only the Completed->Completed self-transition as idempotent (early return with debug log, no duplicate history entry). All other self-transitions remain rejected to preserve state machine strictness. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
e1357a9 to
03c4445
Compare
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
… race errors (nearai#1068) * fix(jobs): make completed->completed transition idempotent to prevent race errors Both execution_loop and the worker wrapper in execute() can race to call mark_completed(). Previously the second call hit "Cannot transition from completed to completed" and errored the job despite successful completion. This narrowly allows only the Completed->Completed self-transition as idempotent (early return with debug log, no duplicate history entry). All other self-transitions remain rejected to preserve state machine strictness. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style: fix assert! formatting in idempotent completion test Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
… race errors (nearai#1068) * fix(jobs): make completed->completed transition idempotent to prevent race errors Both execution_loop and the worker wrapper in execute() can race to call mark_completed(). Previously the second call hit "Cannot transition from completed to completed" and errored the job despite successful completion. This narrowly allows only the Completed->Completed self-transition as idempotent (early return with debug log, no duplicate history entry). All other self-transitions remain rejected to preserve state machine strictness. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * style: fix assert! formatting in idempotent completion test Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
Summary
Supersedes #731. Fixes the race condition where jobs error out despite completing successfully.
execution_loopand the worker wrapper inexecute()race to callmark_completed(). The state machine rejects the secondCompleted -> Completedtransition, causing the job to error out.Completed -> Completedself-transition as idempotent -- early return withtracing::debug!log, no duplicate history entry. All other self-transitions (Pending -> Pending,InProgress -> InProgress, etc.) remain rejected to preserve state machine strictness.test_mark_completed_twice_returns_errorrenamed totest_mark_completed_twice_is_idempotentand updated to expectOk.test_completed_to_completed_is_idempotent(state-level) andtest_other_self_transitions_still_rejected(ensures narrow scope).Addresses @zmanian's review feedback on #731:
Completed -> Completed(not all self-transitions)tracing::debug!in the idempotent early-return pathTest plan
cargo checkpassescargo test --lib context-- all 79 tests pass (2 new)cargo clippy --all --tests-- zero warningsmark_completedcalls to verify no errorCloses #731
Generated with Claude Code