Skip to content

A cancel request racing an attempt's registration still cuts it - #98

Merged
dangra merged 1 commit into
masterfrom
late-preempt
Sep 17, 2026
Merged

dangra merged 1 commit into
masterfrom
late-preempt

Conversation

@dangra

@dangra dangra commented Sep 17, 2026

Copy link
Copy Markdown
Owner

`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.

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.
Copilot AI lite review requested due to automatic review settings September 17, 2026 19:08

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@dangra
dangra merged commit 38778e7 into master Sep 17, 2026
7 checks passed
@dangra dangra mentioned this pull request Sep 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants