fix(db): restore elastic postgres pool - #583
Conversation
|
Bugbot is not enabled for your account, so this pull request was not reviewed. Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs. |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Repository UI Review profile: ASSERTIVE Plan: Pro Plus 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 |
Greptile SummaryThe PR restores a lazily initialized, bounded PostgreSQL pool in place of the shared single client while retaining query instrumentation, error handling, warmup, and shutdown behavior.
Confidence Score: 5/5The PR appears safe to merge, with no concrete changed-code failure identified in the restored pool implementation. The shared database path now uses the Promise-based pg pool API expected by Drizzle, while the configured acquisition bounds and acquire-release/end lifecycle preserve the existing public behavior. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart LR
Caller[Application query] --> Proxy[Lazy db proxy]
Proxy --> Drizzle[Drizzle ORM]
Drizzle --> Pool[Shared pg.Pool]
Pool --> PgBouncer[PgBouncer / PostgreSQL]
Warmup[warmPostgres] --> Acquire[Acquire and release client]
Acquire --> Pool
Shutdown[shutdownPostgres] --> End[pool.end]
End --> Pool
Reviews (1): Last reviewed commit: "fix(db): raise postgres pool ceiling" | Re-trigger Greptile |
|
Closing because this PR was mistakenly opened against |
Summary
pg.Poolin the shared PostgreSQL client.minremains 0), cap each replica at 50 connections, close idle clients after 30 seconds, and bound acquisition at 10 seconds.Production evidence
Calling client.query() when the client is already executing a query, proving concurrent requests are sharing onepg.Client./links/createburst from one API key produced p95 6.49s latency and 28 cache-command timeouts; every slow request had one PostgreSQL query and 0 HTTP 5xx.Validation
bun run lintbun run check-types(34/34 tasks)bun run test(25/25 tasks; 3,905 AI-package tests passed, 0 failed)Rollout and rollback
/links/createp95 under the next real burst.Issue
Emergency maintainer production-incident hotfix; no public issue contains the operational details.
AI disclosure
OpenAI Codex assisted with incident investigation, the minimal cherry-pick, validation, and PR preparation. The implementation was already exercised in staging and was verified with the full local suite.
Summary by cubic
Restore an elastic
pg.Poolfor the shared PostgreSQL client to fix concurrent query contention and reduce timeouts. The pool is lazy (min 0), defaults to 50 max connections per replica, closes idle after 30s, and bounds acquisition to 10s.pg.Clientwithpg.Pooland moved query timing to the pool.DB_POOL_MAXenv support to override the pool ceiling.Written for commit 6d65b6f. Summary will update on new commits.