Skip to content

fix(backend): raise conversation-finalization queue concurrency to 16 - #19921

Merged
Git-on-my-level merged 1 commit into
mainfrom
fix/finalization-queue-concurrency
Sep 30, 2026
Merged

Git-on-my-level merged 1 commit into
mainfrom
fix/finalization-queue-concurrency

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

What changed and why

This raises the production conversation-finalization Cloud Tasks queue from 4 to 16 max-concurrent-dispatches in deploy-backend-stack, and updates backend/docs/listen_finalization_jobs.mdx to 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-heal SERVER_RECOVERY job has gone through this queue to POST /v1/conversation-finalization-jobs/run on 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/*, queue conversation-finalization):

window queue depth (6h max) task_attempt_delays p50 p99
09-24 to 09-26 14Z 0–3 0 s ≤16 s
09-26 20Z to 09-30 08Z 248–728 211–380 s ~521 s

The replay reconciler (claim_finalization_replay) re-mints a queued job's dispatch generation once it has been queued for more than LISTEN_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 as stale_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 run gcloud tasks queues update conversation-finalization --location=us-central1 --project=based-hardware --max-concurrent-dispatches=16. After the change, check that task_attempt_delays p50 falls below 300 s and that stale-generation acks stop.

Product invariants affected

none

Failure class (fixes)

Failure-Class: none

Verification

  • Config-only change to the composite action's gcloud tasks queues update/create arguments. No expression contexts changed.
  • scripts/pr-preflight for this branch.

🤖 Generated with Claude Code

Review in cubic

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]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-09-30T05:12:39.914174Z 62599ae PR opened
ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge 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 👍 / 👎.

@Git-on-my-level
Git-on-my-level merged commit f99eb51 into main Sep 30, 2026
59 checks passed
@Git-on-my-level
Git-on-my-level deleted the fix/finalization-queue-concurrency branch September 30, 2026 05:14
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