• Sources: PlanetScale blog, HN discussion
  • Summary: In transaction mode each backend connection is reused across clients, so a SET SESSION CHARACTERISTICS AS TRANSACTION READ ONLY or default_transaction_read_only = on outlives the transaction that set it and every later client inherits it. The symptom is Postgres error 25006 and writes failing with cannot execute INSERT in a read-only transaction, which reads like a read-only cluster but is not, and the post gives the distinguishing error text. The fix is DISCARD ALL on every pooled connection, and the prevention is routing reads to a replica instead of enforcing read-only on primary transactions. The post is vendor-authored, and the failure mode is a property of PgBouncer transaction mode that applies to any Postgres deployment behind it.
  • Why it matters: A single client setting a session-level flag can make an entire connection pool reject writes with an error that points at the wrong cause.

send feedback on this story