mirror of
https://github.com/postgres/postgres.git
synced 2025-11-09 06:21:09 +03:00
Make pg_waldump report more detail information about PREPARE TRANSACTION record.
This commit changes xact_desc() so that it reports the detail information about PREPARE TRANSACTION record, like GID (global transaction identifier), timestamp at prepare transaction, delete-on-abort/commit relations, XID of subtransactions, and invalidation messages. These are helpful when diagnosing 2PC-related troubles. Author: Fujii Masao Reviewed-by: Michael Paquier, Andrey Lepikhov, Kyotaro Horiguchi, Julien Rouhaud, Alvaro Herrera Discussion: https://postgr.es/m/CAHGQGwEvhASad4JJnCv=0dW2TJypZgW_Vpb-oZik2a3utCqcrA@mail.gmail.com
This commit is contained in:
@@ -910,23 +910,7 @@ TwoPhaseGetDummyProc(TransactionId xid, bool lock_held)
|
||||
*/
|
||||
#define TWOPHASE_MAGIC 0x57F94534 /* format identifier */
|
||||
|
||||
typedef struct TwoPhaseFileHeader
|
||||
{
|
||||
uint32 magic; /* format identifier */
|
||||
uint32 total_len; /* actual file length */
|
||||
TransactionId xid; /* original transaction XID */
|
||||
Oid database; /* OID of database it was in */
|
||||
TimestampTz prepared_at; /* time of preparation */
|
||||
Oid owner; /* user running the transaction */
|
||||
int32 nsubxacts; /* number of following subxact XIDs */
|
||||
int32 ncommitrels; /* number of delete-on-commit rels */
|
||||
int32 nabortrels; /* number of delete-on-abort rels */
|
||||
int32 ninvalmsgs; /* number of cache invalidation messages */
|
||||
bool initfileinval; /* does relcache init file need invalidation? */
|
||||
uint16 gidlen; /* length of the GID - GID follows the header */
|
||||
XLogRecPtr origin_lsn; /* lsn of this record at origin node */
|
||||
TimestampTz origin_timestamp; /* time of prepare at origin node */
|
||||
} TwoPhaseFileHeader;
|
||||
typedef xl_xact_prepare TwoPhaseFileHeader;
|
||||
|
||||
/*
|
||||
* Header for each record in a state file
|
||||
@@ -1331,44 +1315,6 @@ ReadTwoPhaseFile(TransactionId xid, bool missing_ok)
|
||||
return buf;
|
||||
}
|
||||
|
||||
/*
|
||||
* ParsePrepareRecord
|
||||
*/
|
||||
void
|
||||
ParsePrepareRecord(uint8 info, char *xlrec, xl_xact_parsed_prepare *parsed)
|
||||
{
|
||||
TwoPhaseFileHeader *hdr;
|
||||
char *bufptr;
|
||||
|
||||
hdr = (TwoPhaseFileHeader *) xlrec;
|
||||
bufptr = xlrec + MAXALIGN(sizeof(TwoPhaseFileHeader));
|
||||
|
||||
parsed->origin_lsn = hdr->origin_lsn;
|
||||
parsed->origin_timestamp = hdr->origin_timestamp;
|
||||
parsed->twophase_xid = hdr->xid;
|
||||
parsed->dbId = hdr->database;
|
||||
parsed->nsubxacts = hdr->nsubxacts;
|
||||
parsed->nrels = hdr->ncommitrels;
|
||||
parsed->nabortrels = hdr->nabortrels;
|
||||
parsed->nmsgs = hdr->ninvalmsgs;
|
||||
|
||||
strncpy(parsed->twophase_gid, bufptr, hdr->gidlen);
|
||||
bufptr += MAXALIGN(hdr->gidlen);
|
||||
|
||||
parsed->subxacts = (TransactionId *) bufptr;
|
||||
bufptr += MAXALIGN(hdr->nsubxacts * sizeof(TransactionId));
|
||||
|
||||
parsed->xnodes = (RelFileNode *) bufptr;
|
||||
bufptr += MAXALIGN(hdr->ncommitrels * sizeof(RelFileNode));
|
||||
|
||||
parsed->abortnodes = (RelFileNode *) bufptr;
|
||||
bufptr += MAXALIGN(hdr->nabortrels * sizeof(RelFileNode));
|
||||
|
||||
parsed->msgs = (SharedInvalidationMessage *) bufptr;
|
||||
bufptr += MAXALIGN(hdr->ninvalmsgs * sizeof(SharedInvalidationMessage));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Reads 2PC data from xlog. During checkpoint this data will be moved to
|
||||
|
||||
Reference in New Issue
Block a user