Repository navigation
fix(auto-routing): recover benchmark cases whose queue invocation is canceled - #7774
Merged
Merged
Conversation
…canceled The Workers runtime cancels in-flight benchmark queue invocations without running their error handling. The container's Durable Object request outlived the canceled caller, so the container answered a connection nobody read and never posted the outcome, and the redelivered claim was dropped until its lease expired and the re-claim failed the lane. BenchRunnerContainer now relays the caller's request.signal (enable_request_signal) to the container request, so the container posts the outcome. A same-token redelivery resumes its executing claim; a ledgered case without output keeps its slot and rechecks every 30 seconds until the case timeout plus the delivery window has passed since the paid call started, then fails the lane as before.
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Executive SummaryThe incremental commit fixes all three prior findings with tests; no new issues were found in the changed cancellation, ledger-restart, and test code. Files Reviewed (8 files)
Previous Review Summary (commit 64d2c70)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit 64d2c70)Status: 3 Issues Found | Recommendation: Address before merge Executive SummaryThe core fix is well-covered by tests; the main gap is that the fixed 270s paid-output wait can end before a canceled empty-output retry can post its outcome, causing a lane failure to discard a legitimately paid result. Overview
Issue Details (click to expand)WARNING
SUGGESTION
Files Reviewed (21 files)
Reviewed by deepseek-v4.1-flash · Input: 42.4K · Output: 12K · Cached: 673.7K Review guidance: REVIEW.md from base branch |
…eadline for retries An empty-output retry now moves the ledgered paid start, so a canceled retry's output is awaited for a full case timeout. The relay aborts at once when the caller is already gone, and the workerd test closes its upstream even when startup fails.
iscekic
enabled auto-merge
October 16, 2026 17:17
pandemicsyn
approved these changes
Oct 16, 2026
This was referenced Oct 17, 2026
Alas129
pushed a commit
to Alas129/Kilo-Org-cloud
that referenced
this pull request
Oct 20, 2026
…er (Kilo-Org#7792) deploy-workers.yml auto-discovers every services/**/wrangler.jsonc as a deployable Worker. PR Kilo-Org#7774 added a workerd test fixture at services/auto-routing-benchmark/test/fixtures/caller-cancellation/wrangler.jsonc, which has no compatibility_date, so the deploy step failed with "a compatibility_date is required when uploading a Worker". That failed deploy-workers, which blocked deploy-production's record-deployment (it requires needs.deploy-workers.result == 'success'), so base_sha never advanced and every scheduled run failed the same way. Exclude test fixtures from worker discovery (keeping the real auto-routing-benchmark worker deployable), and add a compatibility_date to the fixture so local wrangler/workerd runs stay valid. Co-authored-by: kiloconnect[bot] <240665456+kiloconnect[bot]@users.noreply.github.com>
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.
Problem
Benchmark lanes kept dying with
benchmark_scheduler_wait reason=ambiguous_execution, with no deploy involved.Root cause, from read-only Axiom and D1 evidence:
canceled, no exception, no log line). None of our error handling runs./run. A Durable Object request keeps running after its caller is canceled, so the container finished the case and wrote its answer into the Durable Object's still-open connection. It therefore treated the response as delivered and never posted/container/case-result. Thecanceled/runevents end when the container answers, well after their caller was canceled. Outside rollouts, almost no container results are recovered.startChunkrefused an already active claim, so the redelivery was dropped silently.Fix
BenchRunnerContainerrelays the caller's cancellation to the container request (withCallerCancellation), and the worker sets theenable_request_signalcompatibility flag. When the caller goes away, the container sees its request close, finishes the case, and posts the outcome as fix(auto-routing): survive container rollouts and make scheduler limits admin-configurable #7614 intended. The runtime never passes an incoming request's own signal on to a subrequest, even when you pass it explicitly, so the abort goes through a newAbortController.scheduler_executions.started_atrecords when the paid call began. The column is additive, generated withpnpm db:generate, and defaults to0, so existing rows count as past their deadline.What
enable_request_signalchanges in this workerThe flag only makes an incoming request's
signalabort when its client disconnects; without it the signal never fires.request_signal_passthroughstays off, so no incoming signal reaches a subrequest implicitly. In this worker:BenchRunnerContainer: relays the signal to the container request. This is intended.@cloudflare/containers: already handsrequest.signalto its container-start wait. That wait now stops when the caller is gone, and returns a 500 that nobody reads./container/case-resultand outbound fetches: unaffected. No handler readsrequest.signal, and none forwards an incoming request tofetch.Request.Tests
caller-cancellation.workerd.test.tsruns a fixture Durable Object in real workerd, through wrangler'sunstable_startWorker, using the service's compatibility date and flags fromwrangler.jsonc. A caller starts a subrequest and leaves mid-flight:withCallerCancellation, the upstream connection closes.@cloudflare/containersdoes on its own, it stays open until answered.run-redelivery.test.tsruns production migrations on real SQLite withprocessJobandacceptContainerCaseResult:bench-runner-container.test.tschecks that the container class forwards a request whose own signal aborts with the caller's.caller-cancellation.test.tscovers a caller that is already gone.run-process-job.test.tsandscheduler.test.tsare updated for the resume, recheck, ledger start-time and retry-restart behavior, and the scheduler smoke now asserts that a resumed delivery cannot begin a ledgered paid case again.The new workerd, redelivery, and container-class tests fail on current
main: the redelivery is a no-op, the relay never closes, and the forwarded signal is the incoming one. They pass here.Verification
Run on a work VM for
services/auto-routing-benchmark:pnpm typecheck,pnpm lint,pnpm exec vitest run(all suites pass),pnpm smoke:scheduler,oxfmt --list-differenton the changed files, andpnpm types.worker-configuration.d.tschanges only in its config hash.Known and out of scope
The cancellations themselves are Cloudflare-side. Most end within seconds after a 5-minute wall-clock boundary, in batches that share an end time, and other workers' queue consumers in the account show the same alignment. No limit was involved (wall and CPU time far below the limits, no
exceeded*outcomes), and no container exits, Durable Object resets or D1 errors coincide with them. This PR makes lanes survive those cancellations; it does not prevent them.Not verified until deploy: the local workerd run shows the relay closing the container request at the moment of cancellation. That production's runtime propagates a canceled queue invocation to the Durable Object the same way is inferred, not observed. After deploy,
benchmark_container_result_recoveredshould follow canceled invocations, andambiguous_executionshould drop.