postgres.git / summary / log / commit / refs

commit    4d6d7bdc064201076d2cf361c779b0a3dd4fafa9
Author:   Michael Paquier <michael@paquier.xyz>
Date:     Fri Jan 17 04:27:48 2025 +0000
First released in: 18.0, 13.19, 14.16, 15.11, 16.7, 17.3

    Revert recent changes related to handling of 2PC files at recovery
    
    This commit reverts 8f67f994e8ea (down to v13) and c3de0f9eed38 (down to
    v17), as these are proving to not be completely correct regarding two
    aspects:
    - In v17 and newer branches, c3de0f9eed38'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, 5a1dfde8334b being not enough.
    - In v13 and newer branches, 8f67f994e8ea is a workaround for the real
    issue, which is that we should not attempt CLOG lookups without reaching
    consistency.  This exists since 728bd991c3c4, 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


src/backend/access/transam/twophase.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c index 1df2731ecb4..0a0932cff44 100644 --- a/src/backend/access/transam/twophase.c +++ b/src/backend/access/transam/twophase.c @@ -2167,40 +2167,40 @@ ProcessTwoPhaseBuffer(TransactionId xid, if (!fromdisk) Assert(prepare_start_lsn != InvalidXLogRecPtr); - /* Reject XID if too new */ - if (TransactionIdFollowsOrEquals(xid, origNextXid)) + /* Already processed? */ + if (TransactionIdDidCommit(xid) || TransactionIdDidAbort(xid)) { if (fromdisk) { ereport(WARNING, - (errmsg("removing future two-phase state file for transaction %u", + (errmsg("removing stale two-phase state file for transaction %u", xid))); RemoveTwoPhaseFile(xid, true); } else { ereport(WARNING, - (errmsg("removing future two-phase state from memory for transaction %u", + (errmsg("removing stale two-phase state from memory for transaction %u", xid))); PrepareRedoRemove(xid, true); } return NULL; } - /* Already processed? */ - if (TransactionIdDidCommit(xid) || TransactionIdDidAbort(xid)) + /* Reject XID if too new */ + if (TransactionIdFollowsOrEquals(xid, origNextXid)) { if (fromdisk) { ereport(WARNING, - (errmsg("removing stale two-phase state file for transaction %u", + (errmsg("removing future two-phase state file for transaction %u", xid))); RemoveTwoPhaseFile(xid, true); } else { ereport(WARNING, - (errmsg("removing stale two-phase state from memory for transaction %u", + (errmsg("removing future two-phase state from memory for transaction %u", xid))); PrepareRedoRemove(xid, true); } [parent: 45004f527afa]