summaryrefslogtreecommitdiff
path: root/src/backend/access/transam
diff options
context:
space:
mode:
authorFujii Masao <fujii@postgresql.org>2019-11-13 16:59:17 +0900
committerFujii Masao <fujii@postgresql.org>2019-11-13 16:59:17 +0900
commit7b8a899bdeb638f46e102d1714c079a0874e9fa0 (patch)
tree103b0b4d14db162686996a74ab240277b60d0432 /src/backend/access/transam
parent94fec48516a77f219ab94890219d724b973e4674 (diff)
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
Diffstat (limited to 'src/backend/access/transam')
-rw-r--r--src/backend/access/transam/twophase.c56
1 files changed, 1 insertions, 55 deletions
diff --git a/src/backend/access/transam/twophase.c b/src/backend/access/transam/twophase.c
index 712e842b904..b3ad0d08e30 100644
--- a/src/backend/access/transam/twophase.c
+++ b/src/backend/access/transam/twophase.c
@@ -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