Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit03c46e1

Browse files
committed
Fix handling of orphaned 2PC files in the future at recovery
Before728bd99, that has improved the support for 2PC files duringrecovery, the initial logic scanning files in pg_twophase was done so asfiles in the future of the transaction ID horizon were checked first,followed by a check if a transaction ID is aborted or committed whichcould involve a pg_xact lookup. After this commit, these checks havebeen done in reverse order.Files detected as in the future do not have a state that can be checkedin pg_xact, hence this caused recovery to fail abruptly should anorphaned 2PC file in the future of the transaction ID horizon exist inpg_twophase at the beginning of recovery.A test is added to check for this scenario, using an empty 2PC with atransaction ID large enough to be in the future when running the test.This test is added in 16 and older versions for now. 17 and newerversions are impacted by a second bug caused by the addition of theepoch in the 2PC file names. An equivalent test will be added in thesebranches in a follow-up commit, once the second set of issues reportedare fixed.Author: Vitaly Davydov, Michael PaquierDiscussion:https://postgr.es/m/11e597-676ab680-8d-374f23c0@145466129Backpatch-through: 13
1 parent15b4c46 commit03c46e1

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
@@ -2207,40 +2207,40 @@ ProcessTwoPhaseBuffer(TransactionId xid,
22072207
if (!fromdisk)
22082208
Assert(prepare_start_lsn!=InvalidXLogRecPtr);
22092209

2210-
/*Already processed? */
2211-
if (TransactionIdDidCommit(xid)||TransactionIdDidAbort(xid))
2210+
/*Reject XID if too new */
2211+
if (TransactionIdFollowsOrEquals(xid,origNextXid))
22122212
{
22132213
if (fromdisk)
22142214
{
22152215
ereport(WARNING,
2216-
(errmsg("removingstale two-phase state file for transaction %u",
2216+
(errmsg("removingfuture two-phase state file for transaction %u",
22172217
xid)));
22182218
RemoveTwoPhaseFile(xid, true);
22192219
}
22202220
else
22212221
{
22222222
ereport(WARNING,
2223-
(errmsg("removingstale two-phase state from memory for transaction %u",
2223+
(errmsg("removingfuture two-phase state from memory for transaction %u",
22242224
xid)));
22252225
PrepareRedoRemove(xid, true);
22262226
}
22272227
returnNULL;
22282228
}
22292229

2230-
/*Reject XID if too new */
2231-
if (TransactionIdFollowsOrEquals(xid,origNextXid))
2230+
/*Already processed? */
2231+
if (TransactionIdDidCommit(xid)||TransactionIdDidAbort(xid))
22322232
{
22332233
if (fromdisk)
22342234
{
22352235
ereport(WARNING,
2236-
(errmsg("removingfuture two-phase state file for transaction %u",
2236+
(errmsg("removingstale two-phase state file for transaction %u",
22372237
xid)));
22382238
RemoveTwoPhaseFile(xid, true);
22392239
}
22402240
else
22412241
{
22422242
ereport(WARNING,
2243-
(errmsg("removingfuture two-phase state from memory for transaction %u",
2243+
(errmsg("removingstale two-phase state from memory for transaction %u",
22442244
xid)));
22452245
PrepareRedoRemove(xid, true);
22462246
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp