Skip to content

Commit 4d6d7bd

Browse files
committed
Revert recent changes related to handling of 2PC files at recovery
This commit reverts 8f67f99 (down to v13) and c3de0f9 (down to v17), as these are proving to not be completely correct regarding two aspects: - In v17 and newer branches, c3de0f9's check for epoch handling is incorrect, and does not correctly handle frozen epochs. A logic closer to widen_snapshot_xid() should be used. The 2PC code should try to integrate deeper with FullTransactionIds, 5a1dfde being not enough. - In v13 and newer branches, 8f67f99 is a workaround for the real issue, which is that we should not attempt CLOG lookups without reaching consistency. This exists since 728bd99, and this is reachable with ProcessTwoPhaseBuffer() called by restoreTwoPhaseData() at the beginning of recovery. Per discussion with Noah Misch. Discussion: https://postgr.es/m/20250116010051.f3.nmisch@google.com Backpatch-through: 13
1 parent 45004f5 commit 4d6d7bd

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

src/backend/access/transam/twophase.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2167,40 +2167,40 @@ ProcessTwoPhaseBuffer(TransactionId xid,
21672167
if (!fromdisk)
21682168
Assert(prepare_start_lsn != InvalidXLogRecPtr);
21692169

2170-
/* Reject XID if too new */
2171-
if (TransactionIdFollowsOrEquals(xid, origNextXid))
2170+
/* Already processed? */
2171+
if (TransactionIdDidCommit(xid) || TransactionIdDidAbort(xid))
21722172
{
21732173
if (fromdisk)
21742174
{
21752175
ereport(WARNING,
2176-
(errmsg("removing future two-phase state file for transaction %u",
2176+
(errmsg("removing stale two-phase state file for transaction %u",
21772177
xid)));
21782178
RemoveTwoPhaseFile(xid, true);
21792179
}
21802180
else
21812181
{
21822182
ereport(WARNING,
2183-
(errmsg("removing future two-phase state from memory for transaction %u",
2183+
(errmsg("removing stale two-phase state from memory for transaction %u",
21842184
xid)));
21852185
PrepareRedoRemove(xid, true);
21862186
}
21872187
return NULL;
21882188
}
21892189

2190-
/* Already processed? */
2191-
if (TransactionIdDidCommit(xid) || TransactionIdDidAbort(xid))
2190+
/* Reject XID if too new */
2191+
if (TransactionIdFollowsOrEquals(xid, origNextXid))
21922192
{
21932193
if (fromdisk)
21942194
{
21952195
ereport(WARNING,
2196-
(errmsg("removing stale two-phase state file for transaction %u",
2196+
(errmsg("removing future two-phase state file for transaction %u",
21972197
xid)));
21982198
RemoveTwoPhaseFile(xid, true);
21992199
}
22002200
else
22012201
{
22022202
ereport(WARNING,
2203-
(errmsg("removing stale two-phase state from memory for transaction %u",
2203+
(errmsg("removing future two-phase state from memory for transaction %u",
22042204
xid)));
22052205
PrepareRedoRemove(xid, true);
22062206
}

0 commit comments

Comments
 (0)