mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Store 2PC GID in commit/abort WAL recs for logical decoding
Store GID of 2PC in commit/abort WAL records when wal_level = logical. This allows logical decoding to send the SAME gid to subscribers across restarts of logical replication. Track relica origin replay progress for 2PC. (Edited from patch 0003 in the logical decoding 2PC series.) Authors: Nikhil Sontakke, Stas Kelvich Reviewed-by: Simon Riggs, Andres Freund
This commit is contained in:
@ -21,6 +21,13 @@
|
||||
#include "storage/sinval.h"
|
||||
#include "utils/datetime.h"
|
||||
|
||||
/*
|
||||
* Maximum size of Global Transaction ID (including '\0').
|
||||
*
|
||||
* Note that the max value of GIDSIZE must fit in the uint16 gidlen,
|
||||
* specified in TwoPhaseFileHeader.
|
||||
*/
|
||||
#define GIDSIZE 200
|
||||
|
||||
/*
|
||||
* Xact isolation levels
|
||||
@ -156,6 +163,7 @@ typedef void (*SubXactCallback) (SubXactEvent event, SubTransactionId mySubid,
|
||||
#define XACT_XINFO_HAS_TWOPHASE (1U << 4)
|
||||
#define XACT_XINFO_HAS_ORIGIN (1U << 5)
|
||||
#define XACT_XINFO_HAS_AE_LOCKS (1U << 6)
|
||||
#define XACT_XINFO_HAS_GID (1U << 7)
|
||||
|
||||
/*
|
||||
* Also stored in xinfo, these indicating a variety of additional actions that
|
||||
@ -286,7 +294,6 @@ typedef struct xl_xact_abort
|
||||
typedef struct xl_xact_parsed_commit
|
||||
{
|
||||
TimestampTz xact_time;
|
||||
|
||||
uint32 xinfo;
|
||||
|
||||
Oid dbId; /* MyDatabaseId */
|
||||
@ -302,16 +309,24 @@ typedef struct xl_xact_parsed_commit
|
||||
SharedInvalidationMessage *msgs;
|
||||
|
||||
TransactionId twophase_xid; /* only for 2PC */
|
||||
char twophase_gid[GIDSIZE]; /* only for 2PC */
|
||||
int nabortrels; /* only for 2PC */
|
||||
RelFileNode *abortnodes; /* only for 2PC */
|
||||
|
||||
XLogRecPtr origin_lsn;
|
||||
TimestampTz origin_timestamp;
|
||||
} xl_xact_parsed_commit;
|
||||
|
||||
typedef xl_xact_parsed_commit xl_xact_parsed_prepare;
|
||||
|
||||
typedef struct xl_xact_parsed_abort
|
||||
{
|
||||
TimestampTz xact_time;
|
||||
uint32 xinfo;
|
||||
|
||||
Oid dbId; /* MyDatabaseId */
|
||||
Oid tsId; /* MyDatabaseTableSpace */
|
||||
|
||||
int nsubxacts;
|
||||
TransactionId *subxacts;
|
||||
|
||||
@ -319,6 +334,10 @@ typedef struct xl_xact_parsed_abort
|
||||
RelFileNode *xnodes;
|
||||
|
||||
TransactionId twophase_xid; /* only for 2PC */
|
||||
char twophase_gid[GIDSIZE]; /* only for 2PC */
|
||||
|
||||
XLogRecPtr origin_lsn;
|
||||
TimestampTz origin_timestamp;
|
||||
} xl_xact_parsed_abort;
|
||||
|
||||
|
||||
@ -386,12 +405,14 @@ extern XLogRecPtr XactLogCommitRecord(TimestampTz commit_time,
|
||||
int nmsgs, SharedInvalidationMessage *msgs,
|
||||
bool relcacheInval, bool forceSync,
|
||||
int xactflags,
|
||||
TransactionId twophase_xid);
|
||||
TransactionId twophase_xid,
|
||||
const char *twophase_gid);
|
||||
|
||||
extern XLogRecPtr XactLogAbortRecord(TimestampTz abort_time,
|
||||
int nsubxacts, TransactionId *subxacts,
|
||||
int nrels, RelFileNode *rels,
|
||||
int xactflags, TransactionId twophase_xid);
|
||||
int xactflags, TransactionId twophase_xid,
|
||||
const char *twophase_gid);
|
||||
extern void xact_redo(XLogReaderState *record);
|
||||
|
||||
/* xactdesc.c */
|
||||
|
Reference in New Issue
Block a user