The PgBouncer Misconfiguration
#production-outage — app crashed after DB scaling
Backend Lead: PgBouncer enabled in transaction mode. Checkout 500s immediately.
Logs: prepared statement does not exist · relation temp_cart_items does not exist · session SET vars vanish.
The trap: Transaction mode assigns a different backend connection per query. PREPARE, TEMP TABLE, and SET are connection-local.
Your task
Refactor `process_checkout()` in `checkout_service.py`: stateless SQL — inline SELECT, regular_cart with user_id, AT TIME ZONE instead of SET.
Book: PREPARE + TEMP TABLE · Prod: stateless SQL or the pool breaks your app.
Skills you'll prove
Interview Tip
When asked about connection pooling, say: "We enabled PgBouncer in transaction mode to scale Postgres connections, and checkout immediately broke with prepared statement does not exist and missing temp tables. Transaction mode gives you a backend connection only for one transaction — prepared statements, temp tables, and SET vars are connection-local. We refactored to stateless SQL: inline parameterized queries, regular tables filtered by user_id instead of temp tables, and AT TIME ZONE instead of SET. That let us run 10x concurrent users on a fraction of the connections."