Skip to content

Commit 62a17a9

Browse files
committed
Integrate FullTransactionIds deeper into two-phase code
This refactoring is a follow-up of the work done in 5a1dfde, that has switched 2PC file names to use FullTransactionIds when written on disk. This will help with the integration of a follow-up solution related to the handling of two-phase files during recovery, to address older defects while reading these from disk after a crash. This change is useful in itself as it reduces the need to build the file names from epoch numbers and TransactionIds, because we can use directly FullTransactionIds from which the 2PC file names are guessed. So this avoids a lot of back-and-forth between the FullTransactionIds retrieved from the file names and how these are passed around in the internal 2PC logic. Note that the core of the change is the use of a FullTransactionId instead of a TransactionId in GlobalTransactionData, that tracks 2PC file information in shared memory. The change in TwoPhaseCallback makes this commit unfit for stable branches. Noah has contributed a good chunk of this patch. I have spent some time on it as well while working on the issues with two-phase state files and recovery. Author: Noah Misch <noah@leadboat.com> Co-Authored-by: Michael Paquier <michael@paquier.xyz> Discussion: https://postgr.es/m/Z5sd5O9JO7NYNK-C@paquier.xyz Discussion: https://postgr.es/m/20250116205254.65.nmisch@google.com
1 parent 8aa54aa commit 62a17a9

File tree

12 files changed

+200
-154
lines changed

12 files changed

+200
-154
lines changed

src/backend/access/transam/multixact.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1847,7 +1847,7 @@ AtPrepare_MultiXact(void)
18471847
* Clean up after successful PREPARE TRANSACTION
18481848
*/
18491849
void
1850-
PostPrepare_MultiXact(TransactionId xid)
1850+
PostPrepare_MultiXact(FullTransactionId fxid)
18511851
{
18521852
MultiXactId myOldestMember;
18531853

@@ -1858,7 +1858,7 @@ PostPrepare_MultiXact(TransactionId xid)
18581858
myOldestMember = OldestMemberMXactId[MyProcNumber];
18591859
if (MultiXactIdIsValid(myOldestMember))
18601860
{
1861-
ProcNumber dummyProcNumber = TwoPhaseGetDummyProcNumber(xid, false);
1861+
ProcNumber dummyProcNumber = TwoPhaseGetDummyProcNumber(fxid, false);
18621862

18631863
/*
18641864
* Even though storing MultiXactId is atomic, acquire lock to make
@@ -1896,10 +1896,10 @@ PostPrepare_MultiXact(TransactionId xid)
18961896
* Recover the state of a prepared transaction at startup
18971897
*/
18981898
void
1899-
multixact_twophase_recover(TransactionId xid, uint16 info,
1899+
multixact_twophase_recover(FullTransactionId fxid, uint16 info,
19001900
void *recdata, uint32 len)
19011901
{
1902-
ProcNumber dummyProcNumber = TwoPhaseGetDummyProcNumber(xid, false);
1902+
ProcNumber dummyProcNumber = TwoPhaseGetDummyProcNumber(fxid, false);
19031903
MultiXactId oldestMember;
19041904

19051905
/*
@@ -1917,10 +1917,10 @@ multixact_twophase_recover(TransactionId xid, uint16 info,
19171917
* Similar to AtEOXact_MultiXact but for COMMIT PREPARED
19181918
*/
19191919
void
1920-
multixact_twophase_postcommit(TransactionId xid, uint16 info,
1920+
multixact_twophase_postcommit(FullTransactionId fxid, uint16 info,
19211921
void *recdata, uint32 len)
19221922
{
1923-
ProcNumber dummyProcNumber = TwoPhaseGetDummyProcNumber(xid, true);
1923+
ProcNumber dummyProcNumber = TwoPhaseGetDummyProcNumber(fxid, true);
19241924

19251925
Assert(len == sizeof(MultiXactId));
19261926

@@ -1932,10 +1932,10 @@ multixact_twophase_postcommit(TransactionId xid, uint16 info,
19321932
* This is actually just the same as the COMMIT case.
19331933
*/
19341934
void
1935-
multixact_twophase_postabort(TransactionId xid, uint16 info,
1935+
multixact_twophase_postabort(FullTransactionId fxid, uint16 info,
19361936
void *recdata, uint32 len)
19371937
{
1938-
multixact_twophase_postcommit(xid, info, recdata, len);
1938+
multixact_twophase_postcommit(fxid, info, recdata, len);
19391939
}
19401940

19411941
/*

0 commit comments

Comments
 (0)