pgconfigurator
pgconfigurator

max_prepared_transactions

Requires a restartcount; 0 disables two-phase commit

Enables two-phase commit (PREPARE TRANSACTION) and caps how many can be pending.

What it does

Two-phase commit lets a transaction be PREPAREd and then COMMITted/ROLLBACKed later, which distributed transaction managers use to coordinate across systems. This sets how many prepared transactions can exist at once; 0 disables the feature entirely.

How to tune it

Leave it 0 unless you actually need two-phase commit — meaning an external transaction manager (XA, a distributed system that issues PREPARE TRANSACTION). Enabling it adds real operational duty: a prepared transaction survives crashes and recovery, holding its locks and pinning row versions across both, until you manually COMMIT or ROLLBACK it. Monitor pg_prepared_xacts.

FAQ

How do I find and clean up orphaned prepared transactions?
SELECT * FROM pg_prepared_xacts lists every one (with its 'gid'). Decide whether to finish each with COMMIT PREPARED 'gid' or ROLLBACK PREPARED 'gid'. Until you do, they hold locks and block VACUUM — and they survive crashes and replication failovers, so cleaning them up is your responsibility, not PostgreSQL's.

Related parameters