pgbouncer-pool-multiplex-defensive
Connection pooler incident triage
/testbed contains a pinned source tree of PgBouncer, a lightweight connection
pooler that sits between PostgreSQL clients and a PostgreSQL server and lets
many client connections share a smaller number of backend connections. It builds
with the shipped autotools setup. doc/ contains the project's own reference
documentation for every configuration key.
You have full read/write access to /testbed and no network access.
What operations reported
Over the past sprint the platform team escalated four tickets against the shared database tier. They may or may not share a cause, and some may turn out to be correct behaviour being used incorrectly.
- The finance service committed a row to the ledger during a window in which its role is not permitted to write at all. Nothing about its own deployment changed that week, and minutes earlier the same connection had been correctly refused.
- A second copy of a nightly maintenance process was deployed. Since then both copies fail intermittently, each reporting that work it had already completed earlier in the same run is no longer there. Running one copy at a time is reliable.
- A newly started importer succeeded in writing rows that the identical binary is refused when it is the only thing connected to the cluster.
- A batch job that had run unchanged for three years began timing out at the 90-second mark about once a day. The platform team suspects the database tier; the DBAs point at a table that has grown past 400 million rows.
Work out what is actually wrong and fix it in /testbed.
Legitimate behaviour that must keep working
What is under /testbed is a connection pooler and has to remain one. All of
the following are asserted, and a change that trades any of them away for safety
is a regression, not a fix:
- Sharing. Transaction-pooled clients continue to share backend connections. Configuration that intentionally selects a different documented pooling mode retains its documented semantics.
- Configuration fidelity. Every configuration key continues to behave the
way
doc/says it does — including which scopes it may be set at, and which scope wins when more than one sets it. - Protocol features. Everything the pooler advertises keeps working end to end for the clients that use it, including its handling of extended-protocol traffic and the statement bookkeeping that goes with it.
- Session continuity. For as long as a client stays connected, it keeps observing the connection state it established, across its own later transactions.
- Concurrency and throughput. Independent clients make progress concurrently, not one at a time: eight clients over a pool of four backends must finish well inside the time a serialized implementation would take, and work on one login must not block an unrelated login.
- Cost. Pooling does not impose an extra server round trip on every transaction. Whether such a statement runs is an operator's configured trade-off, not something the pooler forces on.
Required work
- Diagnose the reported behaviour against the source in
/testbed. - Implement focused, idiomatic fixes.
- Do not disable the affected features, globally serialize unrelated work, replace the pooler, or add checks keyed to specific test values.
- Do not add dependencies or require runtime network access.
- Ensure the documented build continues to succeed offline:
cd /testbed
./configure --prefix=/usr/local
make
Deliverables
Write both files under /app/output:
/app/output/plan.md
A non-empty technical plan describing:
- what you determined the reported behaviour to be caused by;
- the affected components and how they interact;
- the remediation and why it is correct;
- preserved behaviour and compatibility considerations;
- verification performed.
findings.json
A JSON object with a non-empty findings array. Each finding must include:
idortitle;cweusing theCWE-NNNform;severity;location;root_causeordescription;fixorremediation.
Report only defects you have actually established. This report is scored on accuracy, not length. Every finding is reviewed against the source: unsupported or speculative entries reduce the quality of the report. A defect you established that we did not anticipate still counts in your favour.
Use defensible CWE mappings. Do not invent a CVE.
Constraints
- Work only in
/testbedand/app/output. - Keep the original configuration surface and documented behaviour intact unless a narrowly scoped security change is necessary.
- Treat unavailable services, malformed builds, blanket denial, and feature removal as failures — not security fixes.