Repository navigation
fix(backend): raise conversation-finalization queue concurrency to 16 - #19921
Conversation
At 4 concurrent dispatches the shared finalization queue saturated after self-heal recovery joined it (median dispatch delay ~6 min vs a 300s replay window), so the reconciler re-minted most generations and about half of all dispatches were stale-generation acks. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 62599ae928
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| --project="${{ inputs.project_id }}" \ | ||
| --max-attempts=5 \ | ||
| --max-concurrent-dispatches=4 | ||
| --max-concurrent-dispatches=16 |
There was a problem hiding this comment.
Configure the queue on a reachable production path
This new value can never be applied by the repository’s deployment workflows: the containing step requires runtime_env == 'prod' && deploy_targets == 'all', but the manual production workflow rejects prod plus all before deployment (.github/workflows/gcp_backend.yml:127-130, also enforced by .github/scripts/validate-backend-deploy-inputs.sh:19-21), while the only other real caller pins environment: development and deploy_targets: all (gcp_backend_auto_dev.yml:305-306). Thus the operator-set live value remains unmanaged and this commit does not actually deploy the production fix; reconcile the queue from the supported production cloud-run-only path or a dedicated production workflow.
Useful? React with 👍 / 👎.
What changed and why
This raises the production
conversation-finalizationCloud Tasks queue from 4 to 16max-concurrent-dispatchesindeploy-backend-stack, and updatesbackend/docs/listen_finalization_jobs.mdxto match. No test pins the value 4.Since #19199 (deployed on backend-sync revision
a90b225, 2026-09-26 ~17Z), every listen finalization and every self-healSERVER_RECOVERYjob has gone through this queue toPOST /v1/conversation-finalization-jobs/runon backend-sync. Before that the queue saw about 10 attempts per 3 hours. Since then it sees 5–10k per 3 hours. At 4 concurrent dispatches it is saturated. Measured in Cloud Monitoring (cloudtasks.googleapis.com/queue/*, queueconversation-finalization):The replay reconciler (
claim_finalization_replay) re-mints a queued job's dispatch generation once it has been queued for more thanLISTEN_FINALIZATION_RECONCILE_STALE_SECONDS(default 300 s). A median queue delay of ~370 s is longer than that window, so most jobs are re-enqueued before their first task runs. The original task is then acked asstale_generation. In 2026-09-29 12Z backend-sync logs there were 3,190 finalization requests: 1,690 stale-generation acks, 1,010 completions and 475 recovery terminals. About half the dispatch capacity was spent acknowledging duplicates, and every user conversation waited about 6 minutes before finalization started.16 dispatches leave headroom for the current load of about 0.9 requests/s with a mean handler time of about 5 s. The handler is I/O-bound, and backend-sync keeps at least 5 instances at concurrency 20.
Rollout
The live queue was raised to 16 by an operator on 2026-09-30. Until this merges, every full prod deploy resets it to 4. The value is applied only by a full prod backend deploy (
deploy_targets == 'all'). To take effect before that, an operator can rungcloud tasks queues update conversation-finalization --location=us-central1 --project=based-hardware --max-concurrent-dispatches=16. After the change, check thattask_attempt_delaysp50 falls below 300 s and that stale-generation acks stop.Product invariants affected
none
Failure class (fixes)
Failure-Class: none
Verification
gcloud tasks queues update/createarguments. No expression contexts changed.scripts/pr-preflightfor this branch.🤖 Generated with Claude Code