Notes on running PostgreSQL in production
PostgreSQL incident notes with the SQL for each fix: lock queues behind ALTER TABLE, sessions idle in transaction, replication slots that fill the disk.
-
Idle in transaction in Postgres: what it means, how to end it
In PostgreSQL, idle in transaction means a session opened a transaction and went quiet. See why it blocks others, find its owner and end it.
-
One ALTER TABLE can block every query on a Postgres table
A PostgreSQL migration waiting for ACCESS EXCLUSIVE queues each later query on the table behind it. See the lock queue and the settings that stop it.
-
An inactive Postgres replication slot is filling your disk
A PostgreSQL replication slot keeps WAL until its consumer confirms it. With the consumer gone, pg_wal grows until the disk fills. Find the slot and fix it.