fix(rpc): prevent Studio database-pool starvation (v0.121 hotfix) - #1766
Conversation
Run synchronous RPC handlers and public async read-path database checkouts outside the API event loop. Preserve worker-originated websocket notifications on the application loop. Bound Explorer queries to two per process, close read sessions inside the query worker, and coalesce count refreshes with a five-second cache. Overload returns 503 with Retry-After without opening another session. Hotfix for the v0.121 production line; no schema, dependency, pool-size, or runtime-version changes. Validated with 859 backend unit tests, 196 frontend unit tests, frontend type checks, and repository formatting/lint checks. Full stable-track E2E remains a landing gate.
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Advanced Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Landing checkpoint: freeze the single-PR v0.121 hotfix cut at #1766.
The user authorized admin merge only after green and release afterward. Heads and base remain frozen while E2E runs. Standard release promotion scope still requires the user's pending confirmation. |
|
/run-e2e v0.5 all |
|
E2E status was updated. Follow the current E2E and merge checks on this PR. Detailed diagnostics are available internally. |
|
CI diagnosis: the PostgreSQL integration job passed, but backend unit collection failed because Starlette 1.6.0's optional TestClient now requires httpx2, which this repository does not install. The new Explorer test file introduced that optional-client import. The fix is test-only: invoke the in-memory ASGI app directly, with no new dependency and no production-code change. Validating against CI's FastAPI/Starlette/AnyIO versions before publishing the revision. The original E2E snapshot will be superseded by one explicitly selected run after the revised head is frozen; it will not be used to merge a different head. |
Exercise Explorer routes directly through ASGI so regression tests run with the repository dependencies even when Starlette TestClient requires httpx2. No runtime dependency or production-code changes. Validated all 859 backend tests using both the existing local environment and an isolated overlay matching CI FastAPI 0.135.1, Starlette 1.6.0, AnyIO 4.15.1 and typing_extensions 4.16.0.
|
Revised landing checkpoint: #1766 only, with the test-client packaging correction. No production behavior or dependency changes since the initial cut.
The previous run 34873235915 tested the superseded head. A new full v0.5/all-scope/all-stack request now produces valid evidence for the corrected exact head and intentionally supersedes the old run. No force/cache/cloud/capacity override is needed. Do not merge until current CI and exact full E2E are green. |
|
/run-e2e v0.5 all |
|
E2E status was updated. Follow the current E2E and merge checks on this PR. Detailed diagnostics are available internally. |
|
Hotfix landing verified
Release remains pending deployment-scope confirmation. Planned patch is |
Standard release startedThe owner confirmed the standard deployment lane, including Rally and Collective Memory, on 2026-09-14. The deployment-scope hold is resolved. Started the existing Verified the new annotated tag peels to merged hotfix commit Automatic follow-up is active for build, staging, production promotion and live health/image verification. Deployment is not yet complete. |
Release handoff — published and promoted; verification blocked
The owner authorized the standard deployment scope. Staging GitOps PR #722 merged as Post-deploy verification is not green: run 34882106929, attempt 2.
No gates were bypassed. No infrastructure fixes, pool changes, restarts, rollback, cleanup or transaction repairs were performed. Automatic follow-up is being paused pending refreshed AWS access and investigation of the autoscaler health failure; do not rebuild/redeploy or blindly rerun these unchanged failed health gates. |
|
AWS follow-up: the v0.121.24 hotfix is now actually rolled out on Studio Prod. Its current migration succeeded at 20:28:54 UTC after guarded removal of the stale finalizer from an already-completed/deleting August 25 Job. Studio Rollout is Healthy with 4/4 updated RPC replicas, workers are Ready, and Studio's full live verification job 104143613078 passed in run 34894088124. Shared release blocker diagnosed and repaired: production Prometheus had exceeded its 1 GiB cap and was OOMKilled over 1,300 times, leaving all three KEDA triggers unable to connect. argocd-aws-apps#61 is merged (b9624a6) after green CI; replacement is Ready with zero restarts, and all three ScaledObjects are Ready=True. Live demand metrics return Studio=5, Rally=0, CM=0. Release verification coverage is repaired by devexp-argocd-apps#724 (5259d2d), with green full Linux release tests. The remaining verifier failure is evidence retention: Rally/CM were Synced+Healthy with all four runtime images verified, but their successful migration Jobs expired after the one-hour TTL before the delayed check could inspect the fifth image. Follow-up #725 retains the latest named migration Job until the next sync replaces it; CI and all three post-merge live gates remain required. No new app release/tag or pool resizing; no health-gate bypass. Final completion is not yet claimed. |



Problem and outcome
Hotfix for the
v0.121production line following Studio's September 14 database-health outage. Concurrent Explorer reads could occupy the shared application pool while a synchronous pool checkout on the API loop delayed response completion and session cleanup. The database itself remained available.Keep database waits off the API loop, return Explorer connections before responses leave their worker, and bound repeated Explorer reads. This is based directly on released
v0.121.23(7d66e42b5dddddbecd2067df545107248d7c7c8c), excluding Studio Next and sibling PRs.Implementation and validation
Validation:
Risks and rollback
Sync handlers now execute in worker threads; regression tests preserve dependency commit/rollback, client context, JSON-RPC results/errors, and websocket delivery. Explorer counts can lag five seconds, or briefly return the previous count during a refresh. Busy Explorer reads receive a retryable 503.
Rollback is the previous
v0.121.23image set; no schema rollback is necessary. Production recovery must still be verified after deployment; the hotfix does not resolve unrelated stuck consensus transactions.Delivery context
Single-PR landing cut; no cross-repository dependencies or handoffs. Freeze head
e8208389451cfe9ba392b4726bb0b56d928f24a7and base7d66e42b5dddddbecd2067df545107248d7c7c8c. Request fullv0.5 allE2E once for this exact snapshot. User authorized E2E, admin merge after green, and release. Planned next patch isv0.121.24; release deployment scope is being confirmed because the standard lane also promotes Rally and Collective Memory.