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

Commit060f9f5

Browse files
committed
Revert recent changes related to handling of 2PC files at recovery
This commit reverts8f67f99 (down to v13) andc3de0f9 (down tov17), as these are proving to not be completely correct regarding twoaspects:- In v17 and newer branches,c3de0f9's check for epoch handling isincorrect, and does not correctly handle frozen epochs. A logic closerto widen_snapshot_xid() should be used. The 2PC code should try tointegrate deeper with FullTransactionIds,5a1dfde being not enough.- In v13 and newer branches,8f67f99 is a workaround for the realissue, which is that we should not attempt CLOG lookups without reachingconsistency. This exists since728bd99, and this is reachable withProcessTwoPhaseBuffer() called by restoreTwoPhaseData() at the beginningof recovery.Per discussion with Noah Misch.Discussion:https://postgr.es/m/20250116010051.f3.nmisch@google.comBackpatch-through: 13
1 parent5f72564 commit060f9f5

File tree

2 files changed

+9
-32
lines changed

2 files changed

+9
-32
lines changed

‎src/backend/access/transam/twophase.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2156,40 +2156,40 @@ ProcessTwoPhaseBuffer(TransactionId xid,
21562156
if (!fromdisk)
21572157
Assert(prepare_start_lsn!=InvalidXLogRecPtr);
21582158

2159-
/*Reject XID if too new */
2160-
if (TransactionIdFollowsOrEquals(xid,origNextXid))
2159+
/*Already processed? */
2160+
if (TransactionIdDidCommit(xid)||TransactionIdDidAbort(xid))
21612161
{
21622162
if (fromdisk)
21632163
{
21642164
ereport(WARNING,
2165-
(errmsg("removingfuture two-phase state file for transaction %u",
2165+
(errmsg("removingstale two-phase state file for transaction %u",
21662166
xid)));
21672167
RemoveTwoPhaseFile(xid, true);
21682168
}
21692169
else
21702170
{
21712171
ereport(WARNING,
2172-
(errmsg("removingfuture two-phase state from memory for transaction %u",
2172+
(errmsg("removingstale two-phase state from memory for transaction %u",
21732173
xid)));
21742174
PrepareRedoRemove(xid, true);
21752175
}
21762176
returnNULL;
21772177
}
21782178

2179-
/*Already processed? */
2180-
if (TransactionIdDidCommit(xid)||TransactionIdDidAbort(xid))
2179+
/*Reject XID if too new */
2180+
if (TransactionIdFollowsOrEquals(xid,origNextXid))
21812181
{
21822182
if (fromdisk)
21832183
{
21842184
ereport(WARNING,
2185-
(errmsg("removingstale two-phase state file for transaction %u",
2185+
(errmsg("removingfuture two-phase state file for transaction %u",
21862186
xid)));
21872187
RemoveTwoPhaseFile(xid, true);
21882188
}
21892189
else
21902190
{
21912191
ereport(WARNING,
2192-
(errmsg("removingstale two-phase state from memory for transaction %u",
2192+
(errmsg("removingfuture two-phase state from memory for transaction %u",
21932193
xid)));
21942194
PrepareRedoRemove(xid, true);
21952195
}

‎src/test/recovery/t/009_twophase.pl

Lines changed: 1 addition & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
use PostgresNode;
99
use TestLib;
10-
use Test::Moretests=>28;
10+
use Test::Moretests=>27;
1111

1212
my$psql_out ='';
1313
my$psql_rc ='';
@@ -527,26 +527,3 @@ sub configure_and_reload
527527
is($psql_out,
528528
qq{27|issued to paris},
529529
"Check expected t_009_tbl2 data on standby");
530-
531-
###############################################################################
532-
# Check handling of orphaned 2PC files at recovery.
533-
###############################################################################
534-
535-
$cur_primary->teardown_node;
536-
537-
# Grab location in logs of primary
538-
my$log_offset =-s$cur_primary->logfile;
539-
540-
# Create a fake file with a transaction ID large enough to be in the future,
541-
# then check that the primary is able to start and remove this file at
542-
# recovery.
543-
544-
my$future_2pc_file =$cur_primary->data_dir .'/pg_twophase/00FFFFFF';
545-
append_to_file$future_2pc_file,"";
546-
547-
$cur_primary->start;
548-
$cur_primary->log_check(
549-
"future two-phase file removed at recovery",
550-
$log_offset,
551-
log_like=>
552-
[qr/removing future two-phase state file for transaction 16777215/]);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp