Repository navigation
serve: cancel timed-out queries and expose workspace state in /metrics - #524
Merged
tinder-maxwellelliott merged 1 commit intoOct 16, 2026
Merged
tinder-maxwellelliott merged 1 commit into
tinder-maxwellelliott merged 1 commit into
Conversation
Fixes Tinder#518. A query that outlived `--requestTimeout` kept running after the 504: it held the workspace, checked out revisions, ran `bazel query`, and then wrote hashes to the local and shared cache, with no way for the client to tell when the checkout was free again. A client that touched the checkout early could get a hash of a changed tree cached under its SHA and served fleet-wide. Both approaches the issue proposes are implemented: * `/metrics` reports `activeQueries` (queries accepted and not yet finished, including abandoned ones) and `workspaceBusy` (whether any operation holds `--workspacePath`), so a client can wait for the workspace before reusing it. * A timed-out query is cancelled rather than abandoned. A new `cancel::Cancellation` token runs every git and Bazel subprocess the query spawns and kills them on cancel, the generation it did not finish is never written to any cache tier, and the 504 is sent only after the query has released the workspace. The response body carries `cancelled` and `workspaceBusy`. `State.workspace_lock` becomes a `Workspace` that records its holder's token: `git_output` and the server's `BazelOptions` pick the token up from it, and a query cancelled while still queued gives up instead of taking the workspace for nothing. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01EhN3zsapeda1JRboWAeS8w
maxwellE
added a commit
to maxwellE/bazel-diff
that referenced
this pull request
Oct 16, 2026
Resolves the src/server.rs conflicts with Tinder#524, which replaced the State literal with State::new. The in-memory tier is now constructed there, and the remote-cache tests keep their compressed and plain fallback responses on top of the shared ready_state helper. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Gs1vjHt61po6uHgkYuh68N
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.
Fixes #518.
A query that outlived
--requestTimeoutkept running after the 504: it held the workspace, checked out revisions, ranbazel query, and then wrote hashes to the local and shared cache, with no way for the client to tell when the checkout was free again. A client that touched the checkout early could get a hash of a changed tree cached under its SHA and served fleet-wide.Both approaches the issue proposes are implemented:
/metricsreportsactiveQueries(queries accepted and not yet finished, including abandoned ones) andworkspaceBusy(whether any operation holds--workspacePath), so a client can wait for the workspace before reusing it.cancel::Cancellationtoken runs every git and Bazel subprocess the query spawns and kills them on cancel, the generation it did not finish is never written to any cache tier, and the 504 is sent only after the query has released the workspace. The response body carriescancelledandworkspaceBusy.State.workspace_lockbecomes aWorkspacethat records its holder's token:git_outputand the server'sBazelOptionspick the token up from it, and a query cancelled while still queued gives up instead of taking the workspace for nothing.