mirror of
https://github.com/postgres/postgres.git
synced 2025-10-25 13:17:41 +03:00
Integrate FullTransactionIds deeper into two-phase code
This refactoring is a follow-up of the work done in 5a1dfde833, 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
This commit is contained in:
@@ -18,6 +18,7 @@
|
||||
#error "lock.h may not be included from frontend code"
|
||||
#endif
|
||||
|
||||
#include "access/transam.h"
|
||||
#include "lib/ilist.h"
|
||||
#include "storage/lockdefs.h"
|
||||
#include "storage/lwlock.h"
|
||||
@@ -581,7 +582,7 @@ extern bool LockHasWaiters(const LOCKTAG *locktag,
|
||||
extern VirtualTransactionId *GetLockConflicts(const LOCKTAG *locktag,
|
||||
LOCKMODE lockmode, int *countp);
|
||||
extern void AtPrepare_Locks(void);
|
||||
extern void PostPrepare_Locks(TransactionId xid);
|
||||
extern void PostPrepare_Locks(FullTransactionId fxid);
|
||||
extern bool LockCheckConflicts(LockMethod lockMethodTable,
|
||||
LOCKMODE lockmode,
|
||||
LOCK *lock, PROCLOCK *proclock);
|
||||
@@ -597,13 +598,13 @@ extern BlockedProcsData *GetBlockerStatusData(int blocked_pid);
|
||||
extern xl_standby_lock *GetRunningTransactionLocks(int *nlocks);
|
||||
extern const char *GetLockmodeName(LOCKMETHODID lockmethodid, LOCKMODE mode);
|
||||
|
||||
extern void lock_twophase_recover(TransactionId xid, uint16 info,
|
||||
extern void lock_twophase_recover(FullTransactionId fxid, uint16 info,
|
||||
void *recdata, uint32 len);
|
||||
extern void lock_twophase_postcommit(TransactionId xid, uint16 info,
|
||||
extern void lock_twophase_postcommit(FullTransactionId fxid, uint16 info,
|
||||
void *recdata, uint32 len);
|
||||
extern void lock_twophase_postabort(TransactionId xid, uint16 info,
|
||||
extern void lock_twophase_postabort(FullTransactionId fxid, uint16 info,
|
||||
void *recdata, uint32 len);
|
||||
extern void lock_twophase_standby_recover(TransactionId xid, uint16 info,
|
||||
extern void lock_twophase_standby_recover(FullTransactionId fxid, uint16 info,
|
||||
void *recdata, uint32 len);
|
||||
|
||||
extern DeadLockState DeadLockCheck(PGPROC *proc);
|
||||
|
||||
@@ -72,9 +72,9 @@ extern void PreCommit_CheckForSerializationFailure(void);
|
||||
|
||||
/* two-phase commit support */
|
||||
extern void AtPrepare_PredicateLocks(void);
|
||||
extern void PostPrepare_PredicateLocks(TransactionId xid);
|
||||
extern void PredicateLockTwoPhaseFinish(TransactionId xid, bool isCommit);
|
||||
extern void predicatelock_twophase_recover(TransactionId xid, uint16 info,
|
||||
extern void PostPrepare_PredicateLocks(FullTransactionId fxid);
|
||||
extern void PredicateLockTwoPhaseFinish(FullTransactionId xid, bool isCommit);
|
||||
extern void predicatelock_twophase_recover(FullTransactionId fxid, uint16 info,
|
||||
void *recdata, uint32 len);
|
||||
|
||||
/* parallel query support */
|
||||
|
||||
Reference in New Issue
Block a user