Repository navigation
fix(exec): claim the exec hold atomically and release only the claim's own - #854
Merged
Merged
Conversation
…s own (AGT-4785 review) Two orchestrators deploying one issue could both read 'not held', both write, and the first refused deploy then cleared the hold the second still needed. claimExecHold reads and writes under one immediate transaction and returns a strictly increasing stamp; releaseExecHoldIf deletes only that stamp.
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
Closes the TOCTOU window left open in #847 (reported there as the one unfixed concurrency item).
exec --issuereadisExecHeld, then calledmarkExecHold. Two orchestrators deploying the same issue could both read "not held" and both write. When the first deploy was then refused it cleared the hold, although the second deploy's run depended on it, and idle_fill could take that run.claimExecHoldreads and writes under oneIMMEDIATEtransaction and returns{ wasHeld, stamp }. Each claim gets a strictly increasingupdated_at, so two claims never share a stamp even within one millisecond.releaseExecHoldIf(issueId, stamp)deletes the row only if it still carries that stamp. A later claim, or anexec answerre-mark, movesupdated_at, so the row is left alone.execdeploy uses these through newclaimHold/releaseHoldseams (replacingisHeld/clearHold);exec answerstill usesmarkExecHold.Verification
npm run cipasses.test:coverageon this tree: 7905 passed, 1 failed insrc/support/fileLock.test.ts. It passes 3/3 alone and this diff does not touch it (load-dependent, the same pattern as the verify tests earlier in this stack).claimalways reportwasHeld: falsefails 3.exec answerre-mark, and fail-closed on an unwritable store. New CLI tests run the deploy against the real store (execDeployHold.test.ts, split out becauseexecCommand.test.tsis at its line cap).Known remaining behaviour
If both of two concurrent deploys are refused, the second one sees
wasHeld: trueand keeps the hold, so it stays until the 24h TTL. That errs toward protecting a run rather than stranding one.