Poisoned Postgres connection pools
Blog post from PlanetScale
Postgres connection pools can become “poisoned” when session-level settings or unfinished transaction state leak through PgBouncer’s transaction-mode connections and affect later clients that reuse them. A common example is setting a session to read-only with commands such as `SET SESSION CHARACTERISTICS AS TRANSACTION READ ONLY` or `default_transaction_read_only`, which can cause subsequent write requests to fail with PostgreSQL error 25006, even though the database itself is not read-only. These failures should first be distinguished from writes mistakenly sent to replicas or clusters placed in read-only mode for operational reasons. Restoring affected connections generally requires resetting their state with `DISCARD ALL` or terminating suspect sessions, while the lasting solution is to remove session-scoped configuration from application code, ensure transactions reliably roll back after failures or timeouts, and route read traffic to replicas where possible. PlanetScale recommends using its query insights, CLI, and MCP server to identify problematic queries and code paths, with ORM replica-routing features potentially simplifying prevention efforts.
| Trend | Post Mentions | Total Month Mentions | Posts | Companies | MoM |
|---|---|---|---|---|---|
| MCP | 7 | 8,729 | 854 | 211 | -20% |
Use this post, company, and trend context to find content marketing opportunities, perform competitive analysis, or address product feature gaps via the Plushcap MCP server or the Plushcap API.