Skip to content

Commit ca2876a

Browse files
committed
fix recovery of 3pc state record
1 parent 1a3d071 commit ca2876a

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/backend/access/transam/twophase.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1785,6 +1785,18 @@ RecreateTwoPhaseFile(TransactionId xid, void *content, int len)
17851785
COMP_CRC32C(statefile_crc, content, len);
17861786
FIN_CRC32C(statefile_crc);
17871787

1788+
/*
1789+
* 3PC hacky support. Xid for xlog record is set during xlog insert
1790+
* via GetCurrentTransactionIdIfAny() call. However this tx isn't already
1791+
* active so allow it to be zero in xlog, but override here during recovery
1792+
* so the file name will be valid xid.
1793+
*/
1794+
if (!TransactionIdIsValid(xid))
1795+
{
1796+
Assert( *(((TwoPhaseFileHeader *) content)->state_3pc) != '\0');
1797+
xid = ((TwoPhaseFileHeader *) content)->xid;
1798+
}
1799+
17881800
TwoPhaseFilePath(path, xid);
17891801

17901802
fd = OpenTransientFile(path,

0 commit comments

Comments
 (0)