Content-Length: 263339 | pFad | http://github.com/postgrespro/postgres/commit/223a946804aafeefc6cb26de276776eec576547d

D3 Fix deadlock at startup, if max_prepared_transactions is too small. · postgrespro/postgres@223a946 · GitHub
Skip to content

Commit 223a946

Browse files
committed
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 bb38fb0, so backpatch to all supported versions like that commit.
1 parent 5feebfe commit 223a946

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/backend/access/transam/twophase.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1998,6 +1998,12 @@ RecoverPreparedTransactions(void)
19981998
if (InHotStandby)
19991999
StandbyReleaseLockTree(xid, hdr->nsubxacts, subxids);
20002000

2001+
/*
2002+
* We're done with recovering this transaction. Clear MyLockedGxact,
2003+
* like we do in PrepareTransaction() during normal operation.
2004+
*/
2005+
PostPrepare_Twophase();
2006+
20012007
pfree(buf);
20022008
}
20032009
}

0 commit comments

Comments
 (0)








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/postgrespro/postgres/commit/223a946804aafeefc6cb26de276776eec576547d

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy