A cancel request racing an attempt's registration still cuts it - #98
Merged
Merged
Conversation
requestCancel preempts the Run's registered attempt, but a worker that read its record before the request landed may be between reserving an attempt and registering it: the preempt found nothing and the attempt ran on a live context to its own end. TestCascadeSurvivesRestart hung this way when the cascade reached the child in that window. preemptAttempt now leaves the cause behind when no attempt is registered, and attemptContext applies it to the next forward registration, so the attempt starts already cut. The entry is consumed there or dropped at terminality.
Merged
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.
`requestCancel` preempts the Run's registered attempt, but a worker that read its record before the request landed may be between reserving an attempt and registering it for preemption. The preempt found nothing, and the attempt ran on a live context to its own end. `TestCascadeSurvivesRestart` hung this way (about one run in ten under `-race`) when the cascade reached the child in that window; it is what timed out the build job on #97.
Fix. `preemptAttempt` leaves the cause behind when no attempt is registered, and `attemptContext` applies it to the next forward registration, so the attempt starts with its context already canceled. The entry is consumed by that registration or dropped at terminality. An unwind registration never applies it.
Test. `TestCancelBetweenReservationAndRegistrationCutsTheAttempt` holds the store's reservation transition until the cancel request has landed, so the window is hit deterministically; it fails against the unfixed engine with a Wait timeout. The cascade-restart test passed 40 of 40 runs under `-race` with the fix.
One sentence in `spec/01-model.md` states the rule.