Fix task executor worker identity reconciliation races - #874
Open
Andyz26 wants to merge 2 commits into
Open
Conversation
Andyz26
requested review from
calvin681,
dtrager02,
fdc-ntflx,
hellolittlej and
james-lubin
as code owners
September 1, 2026 21:34
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.
Summary
State transition analysis
Agent task ownership
flowchart LR I[Idle] -->|submit A: reserve before Ack| P[Preparing A] P -->|initialization succeeds| R[Running A] P -->|cancel: mark and Ack| C[Cancelling A] R -->|cancel: mark and Ack| C P -->|shutdown| C R -->|shutdown or completion| C C -->|task and classloader disposed| I P -->|submit B| X[Reject with actual worker A] R -->|submit B| XThe reserved slot is the single source of worker identity for submission checks, heartbeats, cancellation, and cleanup. A second assignment cannot observe the executor as idle while the first task is preparing. Cancellation Ack confirms acceptance rather than teardown completion;
Availableis reported only after cleanup. Stop failures settle the internal completion future, and shutdown waits are bounded by the configured RPC timeout.Control-plane reconciliation
flowchart TB P[Pending] -->|scheduler assigns A| A[Assigned A] A -->|Occupied A| R[Running A] R -->|authoritative Available status| P R -->|Available heartbeat; capable agent| V[Verifying A] V -->|second Available heartbeat| P V -->|Occupied worker| Q[Quarantined reported worker] A -->|Occupied B| Q R -->|Occupied B| Q Q -->|cancel reported worker| Q Q -->|authoritative Available status| P R -->|Available heartbeat; legacy agent| L[Legacy quarantine] L -->|authoritative Available status or capability upgrade| POnly a registered
Pendingexecutor enters the scheduling index. Ambiguous ownership remains fenced. Reservation-capable agents can prove that repeatedAvailableheartbeats are safe; legacy agents require an authoritative status change or upgrade.Assignment failure direction
flowchart TB F[Assignment attempt] --> G{Did submit begin?} G -->|No| N[NotSent] N -->|retry budget remains| RF[Retry with fresh gateway] N -->|attempt expired| B[Block late gateway submission] G -->|Yes or unknown| M[MayHaveRun] M --> Q[Fence executor and cancel expected worker] F -->|AlreadyRunning actual worker B| C[Conflict] C --> QC[Quarantine and cancel B] F -->|failure from older assignment epoch| S[Ignore stale failure]Tests
The tests cover preparation-time ownership, prompt cancellation acknowledgement, stop failure cleanup, bounded shutdown, conflicting assignments, stale and mismatched reports, capable and legacy recovery, delayed assignment failures, late gateway completion, and disconnect/reconnect state preservation.