Skip to content

Fix race on cancelled incremental queries - #758

Open
emcfarlane wants to merge 2 commits into
mainfrom
ed/incremental-cancel-race
Open

Fix race on cancelled incremental queries#758
emcfarlane wants to merge 2 commits into
mainfrom
ed/incremental-cancel-race

Conversation

@emcfarlane

@emcfarlane emcfarlane commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

This fixes a race found with repeated cancellations in the LSP from testing. Auditing the surround found a couple of issues around pending tasks:

  • Results computed under a cancelled context were cached permanently
  • A panicking leader only cancelled its own Run, blocking concurrent Runs
  • A leader cancelled while queued on the semaphore left its key pending, blocking concurrent Runs
  • Diagnostics from a failed attempt were reported again on retry.

The fix marks results as completed (done, closed) and withdrawn (unpublished, closed). Withdrawal wakes waiters, which retry and elect a leader.

Cycle detection now walks the waiters list, instead of the deps graph. This avoids misclassification from a concurrent Run where a previous one was a cycle. Edges carry the requesting query, so cycle errors correctly identify the trail.

Also: WithTimings was never populated (recorded nothing); Run's diagnostic collection skips uncompleted tasks; FDS no longer mutates the memoized Link slice; transferFrom tolerates holds lost to cancellation; the reentrant-Run guard no longer mutates a shared slice.

@emcfarlane
emcfarlane marked this pull request as ready for review August 19, 2026 22:27
@emcfarlane
emcfarlane requested review from doriable and mcy August 19, 2026 22:29
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.

1 participant