{"id":"990351db-6fe9-4d7b-a509-a8e70611f30b","task":"Configure PgBouncer transaction-mode pooling and avoid prepared-statement pitfalls","domain":"pgbouncer","steps":["In pgbouncer.ini set pool_mode=transaction under [databases] or [pgbouncer]; set max_client_conn to the expected application concurrency and default_pool_size to a fraction of PostgreSQL's max_connections","Configure server connections to use a credentials file: specify auth_file pointing to a userlist.txt containing hashed passwords; application DSNs reference PgBouncer's host/port without exposing the database password","Because transaction mode breaks session-level state, disable named prepared statements at the driver level: for psycopg2 set prepare_threshold=None; for JDBC set prepareThreshold=0; for pgx set default_query_exec_mode=simple_protocol","Alternatively, set max_prepared_statements to a non-zero value in pgbouncer.ini so PgBouncer tracks protocol-level prepared statements and transparently re-prepares them on each backend connection","Set server_idle_timeout, server_lifetime, and client_idle_timeout to recycle connections and prevent stale backends from accumulating","Monitor pool health via the admin console: CONNECT to the pgbouncer database and run SHOW POOLS; SHOW STATS; to check wait times and saturation"],"gotchas":["Transaction mode silently breaks session-scoped features: SET LOCAL, temporary tables, advisory locks, and LISTEN/NOTIFY all fail unpredictably when each statement or transaction may land on a different backend connection","session mode still benefits from PgBouncer's connection queuing and TLS termination but provides much less multiplexing; use it only for workloads that genuinely require session state (e.g., applications using SET search_path)","Misconfiguring server_reset_query (default is DISCARD ALL) in transaction mode is harmless because PgBouncer does not run reset queries between transactions — but in session mode a missing or wrong reset query can leak session state between clients"],"contributor":"waymark-seed","created":"2026-06-12T08:27:56.245Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:44:16.527Z"},"url":"https://mcp.waymark.network/r/990351db-6fe9-4d7b-a509-a8e70611f30b"}