Repository navigation
Deliver cancellations received during fetch - #1397
Merged
Merged
Conversation
bgentry
force-pushed
the
bg/cancel-during-fetch
branch
3 times, most recently
from
September 27, 2026 22:01
ac59cff to
a5d5513
Compare
brandur
approved these changes
Sep 27, 2026
bgentry
force-pushed
the
bg/cancel-during-fetch
branch
from
September 27, 2026 22:05
a5d5513 to
a77017e
Compare
A producer can claim a job during a fetch and receive its cancellation before registering an executor. The notification then has no active job to target, so the fetched job can run with an uncancelled context. Keep unmatched cancellation IDs for the current fetch and cancel matching executors before their goroutines start. Discard the IDs when the fetch returns so subsequent fetches retain existing behavior. Cover this ordering in both producer modes by pausing the fetch after it claims a job and waiting until the cancellation is handled before releasing the result.
bgentry
force-pushed
the
bg/cancel-during-fetch
branch
from
September 27, 2026 22:07
a77017e to
b4c2bcd
Compare
bgentry
enabled auto-merge (squash)
September 27, 2026 22:08
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.
A cancellation can arrive after a producer claims a job but before the fetch returns and registers its executor. In that window, the producer currently finds no active executor and drops the notification, allowing the job to run with an uncancelled context.
Remember unmatched cancellation IDs for the duration of that fetch and cancel matching executors before they start. The pending IDs are discarded when the fetch completes, so later fetches keep the existing behavior. A deterministic regression pauses the fetch after claiming a job, waits until the producer handles its cancellation, then verifies the worker receives a cancelled context and the job finishes cancelled in both producer modes.