]> granicus.if.org Git - postgresql/commit
Fix deadlock at startup, if max_prepared_transactions is too small.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 23 Apr 2015 18:25:44 +0000 (21:25 +0300)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Thu, 23 Apr 2015 18:36:50 +0000 (21:36 +0300)
commitd3f5d2892bc7f48adce4116d7f99f75214544934
tree55fc9ee734f14b2f7e83b147d51883a13a437e75
parent3d73a67ffc742e5d49e9ba3fe78a2fe9b1d9ee05
Fix deadlock at startup, if max_prepared_transactions is too small.

When the startup process recovers transactions by scanning pg_twophase
directory, it should clear MyLockedGxact after it's done processing each
transaction. Like we do during normal operation, at PREPARE TRANSACTION.
Otherwise, if the startup process exits due to an error, it will try to
clear the locking_backend field of the last recovered transaction. That's
usually harmless, but if the error happens in MarkAsPreparing, while
holding TwoPhaseStateLock, the shmem-exit hook will try to acquire
TwoPhaseStateLock again, and deadlock with itself.

This fixes bug #13128 reported by Grant McAlister. The bug was introduced
by commit bb38fb0d, so backpatch to all supported versions like that
commit.
src/backend/access/transam/twophase.c