infra(pgbouncer): transaction-pooling front for timescale_db #2
Loading…
Reference in a new issue
No description provided.
Delete branch "infra/pgbouncer"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Stack-wide connection pooler to fix the
too many connectionserrors ontracksolid_db(max_connections=100). About nine services each hold a persistent pool — several as the postgres superuser, idle for hours — so load peaks exhaust the 100-connection ceiling.PgBouncer multiplexes many client connections onto a small fixed set of real backends (~25 with the shipped sizing), so the DB connection count no longer scales with the number of app pools.
What's included
pgbouncer.ini— transaction pooling,auth_querypass-through auth, bounded pool sizes (default_pool_size=20+reserve_pool_size=5, one database ⇒ ≤25 backends), idle/lifetime recycling.auth_setup.sql—pgbouncer_authlogin role + SECURITY DEFINERpgbouncer.user_lookup()so per-app passwords aren't hand-maintained in a userlist.docker-compose.yml— the service; join the existing DB network, healthcheck + log rotation.userlist.txt.example+.gitignore— keep the auth verifier out of git.README.md— deploy steps, incremental cutover (migrate the heavy superuser pools first),SHOW POOLSoperations, sizing rule, and the transaction-pooling caveats.Important caveats (in the README)
SET, advisory locks,LISTEN/NOTIFY,WITH HOLDcursors). Per-connectionoptionsGUCs are ignored — pin them at the role level instead.options=GUCs +set_session(readonly=True). Recommended path: leave the MCP connecting directly and pool only the heavy superuser apps. (analytics_roalready has its read-only/timeout GUCs pinned at the role level, so correctness holds either way.)Related (already applied)
idle_session_timeout=5minwas set onanalytics_roanddashboard_roto reap their idle pooled connections immediately — independent of this PR.Not done
Nothing is deployed; these are config files only. Deploy is manual per the README, and each service is cut over incrementally.
🤖 Generated with Claude Code
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.