Skip to content

Deliver cancellations received during fetch - #1397

Merged
bgentry merged 1 commit into
masterfrom
bg/cancel-during-fetch
Sep 27, 2026
Merged

bgentry merged 1 commit into
masterfrom
bg/cancel-during-fetch

Conversation

@bgentry

@bgentry bgentry commented Sep 27, 2026

Copy link
Copy Markdown
Contributor

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.

@bgentry
bgentry force-pushed the bg/cancel-during-fetch branch 3 times, most recently from ac59cff to a5d5513 Compare September 27, 2026 22:01
@bgentry
bgentry force-pushed the bg/cancel-during-fetch branch from a5d5513 to a77017e Compare September 27, 2026 22:05
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
bgentry force-pushed the bg/cancel-during-fetch branch from a77017e to b4c2bcd Compare September 27, 2026 22:07
@bgentry
bgentry enabled auto-merge (squash) September 27, 2026 22:08
@bgentry
bgentry merged commit d0b2ad1 into master Sep 27, 2026
15 checks passed
@bgentry
bgentry deleted the bg/cancel-during-fetch branch September 27, 2026 22:10
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