mirror of
https://github.com/postgres/postgres.git
synced 2026-06-11 01:30:11 -04:00
This commit fixes three issues: 1) When a disabled subscription is created with retain_dead_tuples set to true, the launcher is not woken up immediately, which may lead to delays in creating the conflict detection slot. Creating the conflict detection slot is essential even when the subscription is not enabled. This ensures that dead tuples are retained, which is necessary for accurately identifying the type of conflict during replication. 2) Conflict-related data was unnecessarily retained when the subscription does not have a table. 3) Conflict-relevant data could be prematurely removed before applying prepared transactions on the publisher that are in the commit critical section. This issue occurred because the backend executing COMMIT PREPARED was not accounted for during the computation of oldestXid in the commit phase on the publisher. As a result, the subscriber could advance the conflict slot's xmin without waiting for such COMMIT PREPARED transactions to complete. We fixed this issue by identifying prepared transactions that are in the commit critical section during computation of oldestXid in commit phase. Author: Zhijie Hou <houzj.fnst@fujitsu.com> Reviewed-by: shveta malik <shveta.malik@gmail.com> Reviewed-by: Dilip Kumar <dilipbalaut@gmail.com> Reviewed-by: Nisha Moond <nisha.moond412@gmail.com> Reviewed-by: Amit Kapila <amit.kapila16@gmail.com> Discussion: https://postgr.es/m/OS9PR01MB16913DACB64E5721872AA5C02943BA@OS9PR01MB16913.jpnprd01.prod.outlook.com Discussion: https://postgr.es/m/OS9PR01MB16913F67856B0DA2A909788129400A@OS9PR01MB16913.jpnprd01.prod.outlook.com
73 lines
2.4 KiB
C
73 lines
2.4 KiB
C
/*-------------------------------------------------------------------------
|
|
*
|
|
* twophase.h
|
|
* Two-phase-commit related declarations.
|
|
*
|
|
*
|
|
* Portions Copyright (c) 1996-2025, PostgreSQL Global Development Group
|
|
* Portions Copyright (c) 1994, Regents of the University of California
|
|
*
|
|
* src/include/access/twophase.h
|
|
*
|
|
*-------------------------------------------------------------------------
|
|
*/
|
|
#ifndef TWOPHASE_H
|
|
#define TWOPHASE_H
|
|
|
|
#include "access/xact.h"
|
|
#include "access/xlogdefs.h"
|
|
#include "datatype/timestamp.h"
|
|
#include "storage/lock.h"
|
|
|
|
/*
|
|
* GlobalTransactionData is defined in twophase.c; other places have no
|
|
* business knowing the internal definition.
|
|
*/
|
|
typedef struct GlobalTransactionData *GlobalTransaction;
|
|
|
|
/* GUC variable */
|
|
extern PGDLLIMPORT int max_prepared_xacts;
|
|
|
|
extern Size TwoPhaseShmemSize(void);
|
|
extern void TwoPhaseShmemInit(void);
|
|
|
|
extern void AtAbort_Twophase(void);
|
|
extern void PostPrepare_Twophase(void);
|
|
|
|
extern TransactionId TwoPhaseGetXidByVirtualXID(VirtualTransactionId vxid,
|
|
bool *have_more);
|
|
extern PGPROC *TwoPhaseGetDummyProc(FullTransactionId fxid, bool lock_held);
|
|
extern int TwoPhaseGetDummyProcNumber(FullTransactionId fxid, bool lock_held);
|
|
|
|
extern GlobalTransaction MarkAsPreparing(FullTransactionId fxid, const char *gid,
|
|
TimestampTz prepared_at,
|
|
Oid owner, Oid databaseid);
|
|
|
|
extern void StartPrepare(GlobalTransaction gxact);
|
|
extern void EndPrepare(GlobalTransaction gxact);
|
|
extern bool StandbyTransactionIdIsPrepared(TransactionId xid);
|
|
|
|
extern TransactionId PrescanPreparedTransactions(TransactionId **xids_p,
|
|
int *nxids_p);
|
|
extern void StandbyRecoverPreparedTransactions(void);
|
|
extern void RecoverPreparedTransactions(void);
|
|
|
|
extern void CheckPointTwoPhase(XLogRecPtr redo_horizon);
|
|
|
|
extern void FinishPreparedTransaction(const char *gid, bool isCommit);
|
|
|
|
extern void PrepareRedoAdd(FullTransactionId fxid, char *buf,
|
|
XLogRecPtr start_lsn, XLogRecPtr end_lsn,
|
|
RepOriginId origin_id);
|
|
extern void PrepareRedoRemove(TransactionId xid, bool giveWarning);
|
|
extern void restoreTwoPhaseData(void);
|
|
extern bool LookupGXact(const char *gid, XLogRecPtr prepare_end_lsn,
|
|
TimestampTz origin_prepare_timestamp);
|
|
|
|
extern void TwoPhaseTransactionGid(Oid subid, TransactionId xid, char *gid_res,
|
|
int szgid);
|
|
extern bool LookupGXactBySubid(Oid subid);
|
|
|
|
extern TransactionId TwoPhaseGetOldestXidInCommit(void);
|
|
|
|
#endif /* TWOPHASE_H */
|