PostgreSQL Source Code  git master
twophase.h File Reference
#include "access/xlogdefs.h"
#include "access/xact.h"
#include "datatype/timestamp.h"
#include "storage/lock.h"
Include dependency graph for twophase.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Typedefs

typedef struct GlobalTransactionDataGlobalTransaction
 

Functions

Size TwoPhaseShmemSize (void)
 
void TwoPhaseShmemInit (void)
 
void AtAbort_Twophase (void)
 
void PostPrepare_Twophase (void)
 
PGPROCTwoPhaseGetDummyProc (TransactionId xid)
 
BackendId TwoPhaseGetDummyBackendId (TransactionId xid)
 
GlobalTransaction MarkAsPreparing (TransactionId xid, const char *gid, TimestampTz prepared_at, Oid owner, Oid databaseid)
 
void StartPrepare (GlobalTransaction gxact)
 
void EndPrepare (GlobalTransaction gxact)
 
bool StandbyTransactionIdIsPrepared (TransactionId xid)
 
TransactionId PrescanPreparedTransactions (TransactionId **xids_p, int *nxids_p)
 
void ParsePrepareRecord (uint8 info, char *xlrec, xl_xact_parsed_prepare *parsed)
 
void StandbyRecoverPreparedTransactions (void)
 
void RecoverPreparedTransactions (void)
 
void CheckPointTwoPhase (XLogRecPtr redo_horizon)
 
void FinishPreparedTransaction (const char *gid, bool isCommit)
 
void PrepareRedoAdd (char *buf, XLogRecPtr start_lsn, XLogRecPtr end_lsn, RepOriginId origin_id)
 
void PrepareRedoRemove (TransactionId xid, bool giveWarning)
 
void restoreTwoPhaseData (void)
 

Variables

PGDLLIMPORT int max_prepared_xacts
 

Typedef Documentation

◆ GlobalTransaction

Definition at line 26 of file twophase.h.

Function Documentation

◆ AtAbort_Twophase()

void AtAbort_Twophase ( void  )

Definition at line 317 of file twophase.c.

References InvalidBackendId, GlobalTransactionData::locking_backend, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), RemoveGXact(), and GlobalTransactionData::valid.

Referenced by AbortTransaction(), and AtProcExit_Twophase().

318 {
319  if (MyLockedGxact == NULL)
320  return;
321 
322  /*
323  * What to do with the locked global transaction entry? If we were in the
324  * process of preparing the transaction, but haven't written the WAL
325  * record and state file yet, the transaction must not be considered as
326  * prepared. Likewise, if we are in the process of finishing an
327  * already-prepared transaction, and fail after having already written the
328  * 2nd phase commit or rollback record to the WAL, the transaction should
329  * not be considered as prepared anymore. In those cases, just remove the
330  * entry from shared memory.
331  *
332  * Otherwise, the entry must be left in place so that the transaction can
333  * be finished later, so just unlock it.
334  *
335  * If we abort during prepare, after having written the WAL record, we
336  * might not have transferred all locks and other state to the prepared
337  * transaction yet. Likewise, if we abort during commit or rollback,
338  * after having written the WAL record, we might not have released all the
339  * resources held by the transaction yet. In those cases, the in-memory
340  * state can be wrong, but it's too late to back out.
341  */
342  LWLockAcquire(TwoPhaseStateLock, LW_EXCLUSIVE);
343  if (!MyLockedGxact->valid)
345  else
347  LWLockRelease(TwoPhaseStateLock);
348 
349  MyLockedGxact = NULL;
350 }
BackendId locking_backend
Definition: twophase.c:168
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1725
static void RemoveGXact(GlobalTransaction gxact)
Definition: twophase.c:633
#define InvalidBackendId
Definition: backendid.h:23
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1121
static GlobalTransaction MyLockedGxact
Definition: twophase.c:199

◆ CheckPointTwoPhase()

void CheckPointTwoPhase ( XLogRecPtr  redo_horizon)

Definition at line 1722 of file twophase.c.

References buf, ereport, errmsg_plural(), fsync_fname(), i, GlobalTransactionData::inredo, InvalidXLogRecPtr, LOG, log_checkpoints, LW_SHARED, LWLockAcquire(), LWLockRelease(), max_prepared_xacts, TwoPhaseStateData::numPrepXacts, GlobalTransactionData::ondisk, pfree(), GlobalTransactionData::prepare_end_lsn, GlobalTransactionData::prepare_start_lsn, TwoPhaseStateData::prepXacts, RecreateTwoPhaseFile(), TWOPHASE_DIR, GlobalTransactionData::valid, GlobalTransactionData::xid, and XlogReadTwoPhaseData().

Referenced by CheckPointGuts().

1723 {
1724  int i;
1725  int serialized_xacts = 0;
1726 
1727  if (max_prepared_xacts <= 0)
1728  return; /* nothing to do */
1729 
1730  TRACE_POSTGRESQL_TWOPHASE_CHECKPOINT_START();
1731 
1732  /*
1733  * We are expecting there to be zero GXACTs that need to be copied to
1734  * disk, so we perform all I/O while holding TwoPhaseStateLock for
1735  * simplicity. This prevents any new xacts from preparing while this
1736  * occurs, which shouldn't be a problem since the presence of long-lived
1737  * prepared xacts indicates the transaction manager isn't active.
1738  *
1739  * It's also possible to move I/O out of the lock, but on every error we
1740  * should check whether somebody committed our transaction in different
1741  * backend. Let's leave this optimization for future, if somebody will
1742  * spot that this place cause bottleneck.
1743  *
1744  * Note that it isn't possible for there to be a GXACT with a
1745  * prepare_end_lsn set prior to the last checkpoint yet is marked invalid,
1746  * because of the efforts with delayChkpt.
1747  */
1748  LWLockAcquire(TwoPhaseStateLock, LW_SHARED);
1749  for (i = 0; i < TwoPhaseState->numPrepXacts; i++)
1750  {
1751  /*
1752  * Note that we are using gxact not pgxact so this works in recovery
1753  * also
1754  */
1756 
1757  if ((gxact->valid || gxact->inredo) &&
1758  !gxact->ondisk &&
1759  gxact->prepare_end_lsn <= redo_horizon)
1760  {
1761  char *buf;
1762  int len;
1763 
1764  XlogReadTwoPhaseData(gxact->prepare_start_lsn, &buf, &len);
1765  RecreateTwoPhaseFile(gxact->xid, buf, len);
1766  gxact->ondisk = true;
1769  pfree(buf);
1770  serialized_xacts++;
1771  }
1772  }
1773  LWLockRelease(TwoPhaseStateLock);
1774 
1775  /*
1776  * Flush unconditionally the parent directory to make any information
1777  * durable on disk. Two-phase files could have been removed and those
1778  * removals need to be made persistent as well as any files newly created
1779  * previously since the last checkpoint.
1780  */
1781  fsync_fname(TWOPHASE_DIR, true);
1782 
1783  TRACE_POSTGRESQL_TWOPHASE_CHECKPOINT_DONE();
1784 
1785  if (log_checkpoints && serialized_xacts > 0)
1786  ereport(LOG,
1787  (errmsg_plural("%u two-phase state file was written "
1788  "for a long-running prepared transaction",
1789  "%u two-phase state files were written "
1790  "for long-running prepared transactions",
1791  serialized_xacts,
1792  serialized_xacts)));
1793 }
bool log_checkpoints
Definition: xlog.c:102
#define InvalidXLogRecPtr
Definition: xlogdefs.h:28
static TwoPhaseStateData * TwoPhaseState
Definition: twophase.c:191
int errmsg_plural(const char *fmt_singular, const char *fmt_plural, unsigned long n,...)
Definition: elog.c:850
void fsync_fname(const char *fname, bool isdir)
Definition: fd.c:575
#define LOG
Definition: elog.h:26
XLogRecPtr prepare_start_lsn
Definition: twophase.c:163
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1725
void pfree(void *pointer)
Definition: mcxt.c:1031
int max_prepared_xacts
Definition: twophase.c:117
static char * buf
Definition: pg_test_fsync.c:67
#define ereport(elevel, rest)
Definition: elog.h:122
GlobalTransaction prepXacts[FLEXIBLE_ARRAY_MEMBER]
Definition: twophase.c:188
static void RecreateTwoPhaseFile(TransactionId xid, void *content, int len)
Definition: twophase.c:1641
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1121
#define TWOPHASE_DIR
Definition: twophase.c:114
TransactionId xid
Definition: twophase.c:165
static void XlogReadTwoPhaseData(XLogRecPtr lsn, char **buf, int *len)
Definition: twophase.c:1361
int i
XLogRecPtr prepare_end_lsn
Definition: twophase.c:164

◆ EndPrepare()

void EndPrepare ( GlobalTransaction  gxact)

Definition at line 1064 of file twophase.c.

References Assert, StateFileChunk::data, PGXACT::delayChkpt, DoNotReplicateId, END_CRIT_SECTION, ereport, errcode(), errmsg(), ERROR, xllist::head, InvalidRepOriginId, InvalidXLogRecPtr, StateFileChunk::len, TwoPhaseFileHeader::magic, MarkAsPrepared(), MaxAllocSize, MyPgXact, StateFileChunk::next, xllist::num_chunks, TwoPhaseFileHeader::origin_lsn, TwoPhaseFileHeader::origin_timestamp, GlobalTransactionData::prepare_end_lsn, GlobalTransactionData::prepare_start_lsn, ProcLastRecPtr, records, RegisterTwoPhaseRecord(), replorigin_session_advance(), replorigin_session_origin, replorigin_session_origin_lsn, replorigin_session_origin_timestamp, START_CRIT_SECTION, SyncRepWaitForLSN(), xllist::tail, TwoPhaseFileHeader::total_len, xllist::total_len, TWOPHASE_MAGIC, TWOPHASE_RM_END_ID, XLOG_INCLUDE_ORIGIN, XLOG_XACT_PREPARE, XLogBeginInsert(), XLogEnsureRecordSpace(), XLogFlush(), XLogInsert(), XLogRegisterData(), and XLogSetRecordFlags().

Referenced by PrepareTransaction().

1065 {
1066  TwoPhaseFileHeader *hdr;
1067  StateFileChunk *record;
1068  bool replorigin;
1069 
1070  /* Add the end sentinel to the list of 2PC records */
1072  NULL, 0);
1073 
1074  /* Go back and fill in total_len in the file header record */
1075  hdr = (TwoPhaseFileHeader *) records.head->data;
1076  Assert(hdr->magic == TWOPHASE_MAGIC);
1077  hdr->total_len = records.total_len + sizeof(pg_crc32c);
1078 
1079  replorigin = (replorigin_session_origin != InvalidRepOriginId &&
1081 
1082  if (replorigin)
1083  {
1087  }
1088  else
1089  {
1091  hdr->origin_timestamp = 0;
1092  }
1093 
1094  /*
1095  * If the data size exceeds MaxAllocSize, we won't be able to read it in
1096  * ReadTwoPhaseFile. Check for that now, rather than fail in the case
1097  * where we write data to file and then re-read at commit time.
1098  */
1099  if (hdr->total_len > MaxAllocSize)
1100  ereport(ERROR,
1101  (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
1102  errmsg("two-phase state file maximum length exceeded")));
1103 
1104  /*
1105  * Now writing 2PC state data to WAL. We let the WAL's CRC protection
1106  * cover us, so no need to calculate a separate CRC.
1107  *
1108  * We have to set delayChkpt here, too; otherwise a checkpoint starting
1109  * immediately after the WAL record is inserted could complete without
1110  * fsync'ing our state file. (This is essentially the same kind of race
1111  * condition as the COMMIT-to-clog-write case that RecordTransactionCommit
1112  * uses delayChkpt for; see notes there.)
1113  *
1114  * We save the PREPARE record's location in the gxact for later use by
1115  * CheckPointTwoPhase.
1116  */
1118 
1120 
1121  MyPgXact->delayChkpt = true;
1122 
1123  XLogBeginInsert();
1124  for (record = records.head; record != NULL; record = record->next)
1125  XLogRegisterData(record->data, record->len);
1126 
1128 
1129  gxact->prepare_end_lsn = XLogInsert(RM_XACT_ID, XLOG_XACT_PREPARE);
1130 
1131  if (replorigin)
1132  {
1133  /* Move LSNs forward for this replication origin */
1135  gxact->prepare_end_lsn);
1136  }
1137 
1138  XLogFlush(gxact->prepare_end_lsn);
1139 
1140  /* If we crash now, we have prepared: WAL replay will fix things */
1141 
1142  /* Store record's start location to read that later on Commit */
1144 
1145  /*
1146  * Mark the prepared transaction as valid. As soon as xact.c marks
1147  * MyPgXact as not running our XID (which it will do immediately after
1148  * this function returns), others can commit/rollback the xact.
1149  *
1150  * NB: a side effect of this is to make a dummy ProcArray entry for the
1151  * prepared XID. This must happen before we clear the XID from MyPgXact,
1152  * else there is a window where the XID is not running according to
1153  * TransactionIdIsInProgress, and onlookers would be entitled to assume
1154  * the xact crashed. Instead we have a window where the same XID appears
1155  * twice in ProcArray, which is OK.
1156  */
1157  MarkAsPrepared(gxact, false);
1158 
1159  /*
1160  * Now we can mark ourselves as out of the commit critical section: a
1161  * checkpoint starting after this will certainly see the gxact as a
1162  * candidate for fsyncing.
1163  */
1164  MyPgXact->delayChkpt = false;
1165 
1166  /*
1167  * Remember that we have this GlobalTransaction entry locked for us. If
1168  * we crash after this point, it's too late to abort, but we must unlock
1169  * it so that the prepared transaction can be committed or rolled back.
1170  */
1171  MyLockedGxact = gxact;
1172 
1173  END_CRIT_SECTION();
1174 
1175  /*
1176  * Wait for synchronous replication, if required.
1177  *
1178  * Note that at this stage we have marked the prepare, but still show as
1179  * running in the procarray (twice!) and continue to hold locks.
1180  */
1181  SyncRepWaitForLSN(gxact->prepare_end_lsn, false);
1182 
1183  records.tail = records.head = NULL;
1184  records.num_chunks = 0;
1185 }
#define InvalidXLogRecPtr
Definition: xlogdefs.h:28
#define XLOG_XACT_PREPARE
Definition: xact.h:141
#define DoNotReplicateId
Definition: origin.h:35
StateFileChunk * tail
Definition: twophase.c:947
uint32 pg_crc32c
Definition: pg_crc32c.h:38
XLogRecPtr ProcLastRecPtr
Definition: xlog.c:338
void SyncRepWaitForLSN(XLogRecPtr lsn, bool commit)
Definition: syncrep.c:146
#define END_CRIT_SECTION()
Definition: miscadmin.h:133
#define START_CRIT_SECTION()
Definition: miscadmin.h:131
int errcode(int sqlerrcode)
Definition: elog.c:575
#define TWOPHASE_RM_END_ID
Definition: twophase_rmgr.h:24
#define XLOG_INCLUDE_ORIGIN
Definition: xlog.h:192
uint32 num_chunks
Definition: twophase.c:948
void XLogFlush(XLogRecPtr record)
Definition: xlog.c:2783
void RegisterTwoPhaseRecord(TwoPhaseRmgrId rmid, uint16 info, const void *data, uint32 len)
Definition: twophase.c:1191
PGXACT * MyPgXact
Definition: proc.c:68
XLogRecPtr prepare_start_lsn
Definition: twophase.c:163
char * data
Definition: twophase.c:939
#define ERROR
Definition: elog.h:43
TimestampTz origin_timestamp
Definition: twophase.c:916
XLogRecPtr replorigin_session_origin_lsn
Definition: origin.c:156
TimestampTz replorigin_session_origin_timestamp
Definition: origin.c:157
uint32 len
Definition: twophase.c:940
void XLogSetRecordFlags(uint8 flags)
Definition: xloginsert.c:397
#define ereport(elevel, rest)
Definition: elog.h:122
bool delayChkpt
Definition: proc.h:232
static struct xllist records
uint32 total_len
Definition: twophase.c:950
#define MaxAllocSize
Definition: memutils.h:40
struct StateFileChunk * next
Definition: twophase.c:941
void XLogRegisterData(char *data, int len)
Definition: xloginsert.c:323
XLogRecPtr XLogInsert(RmgrId rmid, uint8 info)
Definition: xloginsert.c:415
#define TWOPHASE_MAGIC
Definition: twophase.c:899
StateFileChunk * head
Definition: twophase.c:946
#define Assert(condition)
Definition: c.h:699
RepOriginId replorigin_session_origin
Definition: origin.c:155
void XLogEnsureRecordSpace(int max_block_id, int ndatas)
Definition: xloginsert.c:146
void replorigin_session_advance(XLogRecPtr remote_commit, XLogRecPtr local_commit)
Definition: origin.c:1147
static void MarkAsPrepared(GlobalTransaction gxact, bool lock_held)
Definition: twophase.c:535
#define InvalidRepOriginId
Definition: origin.h:34
int errmsg(const char *fmt,...)
Definition: elog.c:797
static GlobalTransaction MyLockedGxact
Definition: twophase.c:199
XLogRecPtr origin_lsn
Definition: twophase.c:915
void XLogBeginInsert(void)
Definition: xloginsert.c:120
XLogRecPtr prepare_end_lsn
Definition: twophase.c:164

◆ FinishPreparedTransaction()

void FinishPreparedTransaction ( const char *  gid,
bool  isCommit 
)

Definition at line 1433 of file twophase.c.

References PROC_HDR::allPgXact, PROC_HDR::allProcs, Assert, AtEOXact_PgStat(), buf, GetUserId(), TwoPhaseFileHeader::gidlen, HOLD_INTERRUPTS, i, TwoPhaseFileHeader::initfileinval, InvalidBackendId, LockGXact(), LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), MAXALIGN, TwoPhaseFileHeader::nabortrels, TwoPhaseFileHeader::ncommitrels, TwoPhaseFileHeader::ninvalmsgs, TwoPhaseFileHeader::nsubxacts, GlobalTransactionData::ondisk, pfree(), GlobalTransactionData::pgprocno, PredicateLockTwoPhaseFinish(), GlobalTransactionData::prepare_start_lsn, ProcArrayRemove(), ProcessRecords(), ProcGlobal, ReadTwoPhaseFile(), RecordTransactionAbortPrepared(), RecordTransactionCommitPrepared(), RelationCacheInitFilePostInvalidate(), RelationCacheInitFilePreInvalidate(), RemoveGXact(), RemoveTwoPhaseFile(), RESUME_INTERRUPTS, SendSharedInvalidMessages(), smgrclose(), smgrdounlink(), smgropen(), TransactionIdEquals, TransactionIdLatest(), twophase_postabort_callbacks, twophase_postcommit_callbacks, GlobalTransactionData::valid, GlobalTransactionData::xid, PGXACT::xid, TwoPhaseFileHeader::xid, and XlogReadTwoPhaseData().

Referenced by standard_ProcessUtility().

1434 {
1435  GlobalTransaction gxact;
1436  PGPROC *proc;
1437  PGXACT *pgxact;
1438  TransactionId xid;
1439  char *buf;
1440  char *bufptr;
1441  TwoPhaseFileHeader *hdr;
1442  TransactionId latestXid;
1443  TransactionId *children;
1444  RelFileNode *commitrels;
1445  RelFileNode *abortrels;
1446  RelFileNode *delrels;
1447  int ndelrels;
1448  SharedInvalidationMessage *invalmsgs;
1449  int i;
1450 
1451  /*
1452  * Validate the GID, and lock the GXACT to ensure that two backends do not
1453  * try to commit the same GID at once.
1454  */
1455  gxact = LockGXact(gid, GetUserId());
1456  proc = &ProcGlobal->allProcs[gxact->pgprocno];
1457  pgxact = &ProcGlobal->allPgXact[gxact->pgprocno];
1458  xid = pgxact->xid;
1459 
1460  /*
1461  * Read and validate 2PC state data. State data will typically be stored
1462  * in WAL files if the LSN is after the last checkpoint record, or moved
1463  * to disk if for some reason they have lived for a long time.
1464  */
1465  if (gxact->ondisk)
1466  buf = ReadTwoPhaseFile(xid, true);
1467  else
1468  XlogReadTwoPhaseData(gxact->prepare_start_lsn, &buf, NULL);
1469 
1470 
1471  /*
1472  * Disassemble the header area
1473  */
1474  hdr = (TwoPhaseFileHeader *) buf;
1475  Assert(TransactionIdEquals(hdr->xid, xid));
1476  bufptr = buf + MAXALIGN(sizeof(TwoPhaseFileHeader));
1477  bufptr += MAXALIGN(hdr->gidlen);
1478  children = (TransactionId *) bufptr;
1479  bufptr += MAXALIGN(hdr->nsubxacts * sizeof(TransactionId));
1480  commitrels = (RelFileNode *) bufptr;
1481  bufptr += MAXALIGN(hdr->ncommitrels * sizeof(RelFileNode));
1482  abortrels = (RelFileNode *) bufptr;
1483  bufptr += MAXALIGN(hdr->nabortrels * sizeof(RelFileNode));
1484  invalmsgs = (SharedInvalidationMessage *) bufptr;
1485  bufptr += MAXALIGN(hdr->ninvalmsgs * sizeof(SharedInvalidationMessage));
1486 
1487  /* compute latestXid among all children */
1488  latestXid = TransactionIdLatest(xid, hdr->nsubxacts, children);
1489 
1490  /* Prevent cancel/die interrupt while cleaning up */
1491  HOLD_INTERRUPTS();
1492 
1493  /*
1494  * The order of operations here is critical: make the XLOG entry for
1495  * commit or abort, then mark the transaction committed or aborted in
1496  * pg_xact, then remove its PGPROC from the global ProcArray (which means
1497  * TransactionIdIsInProgress will stop saying the prepared xact is in
1498  * progress), then run the post-commit or post-abort callbacks. The
1499  * callbacks will release the locks the transaction held.
1500  */
1501  if (isCommit)
1503  hdr->nsubxacts, children,
1504  hdr->ncommitrels, commitrels,
1505  hdr->ninvalmsgs, invalmsgs,
1506  hdr->initfileinval, gid);
1507  else
1509  hdr->nsubxacts, children,
1510  hdr->nabortrels, abortrels,
1511  gid);
1512 
1513  ProcArrayRemove(proc, latestXid);
1514 
1515  /*
1516  * In case we fail while running the callbacks, mark the gxact invalid so
1517  * no one else will try to commit/rollback, and so it will be recycled if
1518  * we fail after this point. It is still locked by our backend so it
1519  * won't go away yet.
1520  *
1521  * (We assume it's safe to do this without taking TwoPhaseStateLock.)
1522  */
1523  gxact->valid = false;
1524 
1525  /*
1526  * We have to remove any files that were supposed to be dropped. For
1527  * consistency with the regular xact.c code paths, must do this before
1528  * releasing locks, so do it before running the callbacks.
1529  *
1530  * NB: this code knows that we couldn't be dropping any temp rels ...
1531  */
1532  if (isCommit)
1533  {
1534  delrels = commitrels;
1535  ndelrels = hdr->ncommitrels;
1536  }
1537  else
1538  {
1539  delrels = abortrels;
1540  ndelrels = hdr->nabortrels;
1541  }
1542  for (i = 0; i < ndelrels; i++)
1543  {
1544  SMgrRelation srel = smgropen(delrels[i], InvalidBackendId);
1545 
1546  smgrdounlink(srel, false);
1547  smgrclose(srel);
1548  }
1549 
1550  /*
1551  * Handle cache invalidation messages.
1552  *
1553  * Relcache init file invalidation requires processing both before and
1554  * after we send the SI messages. See AtEOXact_Inval()
1555  */
1556  if (hdr->initfileinval)
1558  SendSharedInvalidMessages(invalmsgs, hdr->ninvalmsgs);
1559  if (hdr->initfileinval)
1561 
1562  /* And now do the callbacks */
1563  if (isCommit)
1565  else
1567 
1568  PredicateLockTwoPhaseFinish(xid, isCommit);
1569 
1570  /* Count the prepared xact as committed or aborted */
1571  AtEOXact_PgStat(isCommit);
1572 
1573  /*
1574  * And now we can clean up any files we may have left.
1575  */
1576  if (gxact->ondisk)
1577  RemoveTwoPhaseFile(xid, true);
1578 
1579  LWLockAcquire(TwoPhaseStateLock, LW_EXCLUSIVE);
1580  RemoveGXact(gxact);
1581  LWLockRelease(TwoPhaseStateLock);
1582  MyLockedGxact = NULL;
1583 
1585 
1586  pfree(buf);
1587 }
static void RecordTransactionAbortPrepared(TransactionId xid, int nchildren, TransactionId *children, int nrels, RelFileNode *rels, const char *gid)
Definition: twophase.c:2327
void smgrclose(SMgrRelation reln)
Definition: smgr.c:296
#define TransactionIdEquals(id1, id2)
Definition: transam.h:43
uint32 TransactionId
Definition: c.h:474
Definition: proc.h:219
Oid GetUserId(void)
Definition: miscinit.c:379
PGXACT * allPgXact
Definition: proc.h:246
TransactionId xid
Definition: proc.h:221
TransactionId TransactionIdLatest(TransactionId mainxid, int nxids, const TransactionId *xids)
Definition: transam.c:365
static void ProcessRecords(char *bufptr, TransactionId xid, const TwoPhaseCallback callbacks[])
Definition: twophase.c:1593
void smgrdounlink(SMgrRelation reln, bool isRedo)
Definition: smgr.c:414
const TwoPhaseCallback twophase_postcommit_callbacks[TWOPHASE_RM_MAX_ID+1]
Definition: twophase_rmgr.c:33
PROC_HDR * ProcGlobal
Definition: proc.c:80
TransactionId xid
Definition: twophase.c:905
XLogRecPtr prepare_start_lsn
Definition: twophase.c:163
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1725
#define RESUME_INTERRUPTS()
Definition: miscadmin.h:117
void pfree(void *pointer)
Definition: mcxt.c:1031
static GlobalTransaction LockGXact(const char *gid, Oid user)
Definition: twophase.c:557
void ProcArrayRemove(PGPROC *proc, TransactionId latestXid)
Definition: procarray.c:333
static void RemoveGXact(GlobalTransaction gxact)
Definition: twophase.c:633
void PredicateLockTwoPhaseFinish(TransactionId xid, bool isCommit)
Definition: predicate.c:4850
static char * buf
Definition: pg_test_fsync.c:67
SMgrRelation smgropen(RelFileNode rnode, BackendId backend)
Definition: smgr.c:137
#define InvalidBackendId
Definition: backendid.h:23
const TwoPhaseCallback twophase_postabort_callbacks[TWOPHASE_RM_MAX_ID+1]
Definition: twophase_rmgr.c:42
static char * ReadTwoPhaseFile(TransactionId xid, bool give_warnings)
Definition: twophase.c:1212
void RelationCacheInitFilePostInvalidate(void)
Definition: relcache.c:6032
static void RemoveTwoPhaseFile(TransactionId xid, bool giveWarning)
Definition: twophase.c:1621
void RelationCacheInitFilePreInvalidate(void)
Definition: relcache.c:6006
#define Assert(condition)
Definition: c.h:699
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1121
#define MAXALIGN(LEN)
Definition: c.h:652
void SendSharedInvalidMessages(const SharedInvalidationMessage *msgs, int n)
Definition: sinval.c:49
static void XlogReadTwoPhaseData(XLogRecPtr lsn, char **buf, int *len)
Definition: twophase.c:1361
static GlobalTransaction MyLockedGxact
Definition: twophase.c:199
#define HOLD_INTERRUPTS()
Definition: miscadmin.h:115
int i
PGPROC * allProcs
Definition: proc.h:244
Definition: proc.h:95
static void RecordTransactionCommitPrepared(TransactionId xid, int nchildren, TransactionId *children, int nrels, RelFileNode *rels, int ninvalmsgs, SharedInvalidationMessage *invalmsgs, bool initfileinval, const char *gid)
Definition: twophase.c:2233
void AtEOXact_PgStat(bool isCommit)
Definition: pgstat.c:2053

◆ MarkAsPreparing()

GlobalTransaction MarkAsPreparing ( TransactionId  xid,
const char *  gid,
TimestampTz  prepared_at,
Oid  owner,
Oid  databaseid 
)

Definition at line 372 of file twophase.c.

References Assert, AtProcExit_Twophase(), before_shmem_exit(), ereport, errcode(), ERRCODE_DUPLICATE_OBJECT, errhint(), errmsg(), ERROR, TwoPhaseStateData::freeGXacts, GlobalTransactionData::gid, GIDSIZE, i, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), MarkAsPreparingGuts(), max_prepared_xacts, GlobalTransactionData::next, TwoPhaseStateData::numPrepXacts, GlobalTransactionData::ondisk, TwoPhaseStateData::prepXacts, and twophaseExitRegistered.

Referenced by PrepareTransaction().

374 {
375  GlobalTransaction gxact;
376  int i;
377 
378  if (strlen(gid) >= GIDSIZE)
379  ereport(ERROR,
380  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
381  errmsg("transaction identifier \"%s\" is too long",
382  gid)));
383 
384  /* fail immediately if feature is disabled */
385  if (max_prepared_xacts == 0)
386  ereport(ERROR,
387  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
388  errmsg("prepared transactions are disabled"),
389  errhint("Set max_prepared_transactions to a nonzero value.")));
390 
391  /* on first call, register the exit hook */
393  {
395  twophaseExitRegistered = true;
396  }
397 
398  LWLockAcquire(TwoPhaseStateLock, LW_EXCLUSIVE);
399 
400  /* Check for conflicting GID */
401  for (i = 0; i < TwoPhaseState->numPrepXacts; i++)
402  {
403  gxact = TwoPhaseState->prepXacts[i];
404  if (strcmp(gxact->gid, gid) == 0)
405  {
406  ereport(ERROR,
408  errmsg("transaction identifier \"%s\" is already in use",
409  gid)));
410  }
411  }
412 
413  /* Get a free gxact from the freelist */
414  if (TwoPhaseState->freeGXacts == NULL)
415  ereport(ERROR,
416  (errcode(ERRCODE_OUT_OF_MEMORY),
417  errmsg("maximum number of prepared transactions reached"),
418  errhint("Increase max_prepared_transactions (currently %d).",
420  gxact = TwoPhaseState->freeGXacts;
421  TwoPhaseState->freeGXacts = gxact->next;
422 
423  MarkAsPreparingGuts(gxact, xid, gid, prepared_at, owner, databaseid);
424 
425  gxact->ondisk = false;
426 
427  /* And insert it into the active array */
430 
431  LWLockRelease(TwoPhaseStateLock);
432 
433  return gxact;
434 }
int errhint(const char *fmt,...)
Definition: elog.c:987
static TwoPhaseStateData * TwoPhaseState
Definition: twophase.c:191
GlobalTransaction freeGXacts
Definition: twophase.c:182
int errcode(int sqlerrcode)
Definition: elog.c:575
static bool twophaseExitRegistered
Definition: twophase.c:201
GlobalTransaction next
Definition: twophase.c:151
char gid[GIDSIZE]
Definition: twophase.c:172
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1725
static void MarkAsPreparingGuts(GlobalTransaction gxact, TransactionId xid, const char *gid, TimestampTz prepared_at, Oid owner, Oid databaseid)
Definition: twophase.c:446
#define ERROR
Definition: elog.h:43
int max_prepared_xacts
Definition: twophase.c:117
#define GIDSIZE
Definition: xact.h:30
void before_shmem_exit(pg_on_exit_callback function, Datum arg)
Definition: ipc.c:331
#define ereport(elevel, rest)
Definition: elog.h:122
GlobalTransaction prepXacts[FLEXIBLE_ARRAY_MEMBER]
Definition: twophase.c:188
#define Assert(condition)
Definition: c.h:699
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1121
int errmsg(const char *fmt,...)
Definition: elog.c:797
int i
static void AtProcExit_Twophase(int code, Datum arg)
Definition: twophase.c:307
#define ERRCODE_DUPLICATE_OBJECT
Definition: streamutil.c:32

◆ ParsePrepareRecord()

void ParsePrepareRecord ( uint8  info,
char *  xlrec,
xl_xact_parsed_prepare parsed 
)

Definition at line 1317 of file twophase.c.

References xl_xact_parsed_commit::abortnodes, TwoPhaseFileHeader::database, xl_xact_parsed_commit::dbId, TwoPhaseFileHeader::gidlen, MAXALIGN, xl_xact_parsed_commit::msgs, xl_xact_parsed_commit::nabortrels, TwoPhaseFileHeader::nabortrels, TwoPhaseFileHeader::ncommitrels, TwoPhaseFileHeader::ninvalmsgs, xl_xact_parsed_commit::nmsgs, xl_xact_parsed_commit::nrels, xl_xact_parsed_commit::nsubxacts, TwoPhaseFileHeader::nsubxacts, xl_xact_parsed_commit::origin_lsn, TwoPhaseFileHeader::origin_lsn, xl_xact_parsed_commit::origin_timestamp, TwoPhaseFileHeader::origin_timestamp, xl_xact_parsed_commit::subxacts, xl_xact_parsed_commit::twophase_gid, xl_xact_parsed_commit::twophase_xid, TwoPhaseFileHeader::xid, and xl_xact_parsed_commit::xnodes.

1318 {
1319  TwoPhaseFileHeader *hdr;
1320  char *bufptr;
1321 
1322  hdr = (TwoPhaseFileHeader *) xlrec;
1323  bufptr = xlrec + MAXALIGN(sizeof(TwoPhaseFileHeader));
1324 
1325  parsed->origin_lsn = hdr->origin_lsn;
1326  parsed->origin_timestamp = hdr->origin_timestamp;
1327  parsed->twophase_xid = hdr->xid;
1328  parsed->dbId = hdr->database;
1329  parsed->nsubxacts = hdr->nsubxacts;
1330  parsed->nrels = hdr->ncommitrels;
1331  parsed->nabortrels = hdr->nabortrels;
1332  parsed->nmsgs = hdr->ninvalmsgs;
1333 
1334  strncpy(parsed->twophase_gid, bufptr, hdr->gidlen);
1335  bufptr += MAXALIGN(hdr->gidlen);
1336 
1337  parsed->subxacts = (TransactionId *) bufptr;
1338  bufptr += MAXALIGN(hdr->nsubxacts * sizeof(TransactionId));
1339 
1340  parsed->xnodes = (RelFileNode *) bufptr;
1341  bufptr += MAXALIGN(hdr->ncommitrels * sizeof(RelFileNode));
1342 
1343  parsed->abortnodes = (RelFileNode *) bufptr;
1344  bufptr += MAXALIGN(hdr->nabortrels * sizeof(RelFileNode));
1345 
1346  parsed->msgs = (SharedInvalidationMessage *) bufptr;
1347  bufptr += MAXALIGN(hdr->ninvalmsgs * sizeof(SharedInvalidationMessage));
1348 }
RelFileNode * xnodes
Definition: xact.h:309
uint32 TransactionId
Definition: c.h:474
TimestampTz origin_timestamp
Definition: xact.h:320
TransactionId twophase_xid
Definition: xact.h:314
TransactionId * subxacts
Definition: xact.h:306
SharedInvalidationMessage * msgs
Definition: xact.h:312
XLogRecPtr origin_lsn
Definition: xact.h:319
TransactionId xid
Definition: twophase.c:905
TimestampTz origin_timestamp
Definition: twophase.c:916
RelFileNode * abortnodes
Definition: xact.h:317
#define MAXALIGN(LEN)
Definition: c.h:652
XLogRecPtr origin_lsn
Definition: twophase.c:915
char twophase_gid[GIDSIZE]
Definition: xact.h:315

◆ PostPrepare_Twophase()

void PostPrepare_Twophase ( void  )

Definition at line 357 of file twophase.c.

References InvalidBackendId, GlobalTransactionData::locking_backend, LW_EXCLUSIVE, LWLockAcquire(), and LWLockRelease().

Referenced by PrepareTransaction(), and RecoverPreparedTransactions().

358 {
359  LWLockAcquire(TwoPhaseStateLock, LW_EXCLUSIVE);
361  LWLockRelease(TwoPhaseStateLock);
362 
363  MyLockedGxact = NULL;
364 }
BackendId locking_backend
Definition: twophase.c:168
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1725
#define InvalidBackendId
Definition: backendid.h:23
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1121
static GlobalTransaction MyLockedGxact
Definition: twophase.c:199

◆ PrepareRedoAdd()

void PrepareRedoAdd ( char *  buf,
XLogRecPtr  start_lsn,
XLogRecPtr  end_lsn,
RepOriginId  origin_id 
)

Definition at line 2386 of file twophase.c.

References Assert, DEBUG2, elog, ereport, errcode(), errhint(), errmsg(), ERROR, TwoPhaseStateData::freeGXacts, GlobalTransactionData::gid, GlobalTransactionData::inredo, InvalidBackendId, InvalidRepOriginId, GlobalTransactionData::locking_backend, LW_EXCLUSIVE, LWLockHeldByMeInMode(), max_prepared_xacts, MAXALIGN, GlobalTransactionData::next, TwoPhaseStateData::numPrepXacts, GlobalTransactionData::ondisk, TwoPhaseFileHeader::origin_lsn, GlobalTransactionData::owner, TwoPhaseFileHeader::owner, GlobalTransactionData::prepare_end_lsn, GlobalTransactionData::prepare_start_lsn, GlobalTransactionData::prepared_at, TwoPhaseFileHeader::prepared_at, TwoPhaseStateData::prepXacts, RecoveryInProgress(), replorigin_advance(), GlobalTransactionData::valid, GlobalTransactionData::xid, TwoPhaseFileHeader::xid, and XLogRecPtrIsInvalid.

Referenced by restoreTwoPhaseData(), and xact_redo().

2388 {
2390  char *bufptr;
2391  const char *gid;
2392  GlobalTransaction gxact;
2393 
2394  Assert(LWLockHeldByMeInMode(TwoPhaseStateLock, LW_EXCLUSIVE));
2396 
2397  bufptr = buf + MAXALIGN(sizeof(TwoPhaseFileHeader));
2398  gid = (const char *) bufptr;
2399 
2400  /*
2401  * Reserve the GID for the given transaction in the redo code path.
2402  *
2403  * This creates a gxact struct and puts it into the active array.
2404  *
2405  * In redo, this struct is mainly used to track PREPARE/COMMIT entries in
2406  * shared memory. Hence, we only fill up the bare minimum contents here.
2407  * The gxact also gets marked with gxact->inredo set to true to indicate
2408  * that it got added in the redo phase
2409  */
2410 
2411  /* Get a free gxact from the freelist */
2412  if (TwoPhaseState->freeGXacts == NULL)
2413  ereport(ERROR,
2414  (errcode(ERRCODE_OUT_OF_MEMORY),
2415  errmsg("maximum number of prepared transactions reached"),
2416  errhint("Increase max_prepared_transactions (currently %d).",
2417  max_prepared_xacts)));
2418  gxact = TwoPhaseState->freeGXacts;
2419  TwoPhaseState->freeGXacts = gxact->next;
2420 
2421  gxact->prepared_at = hdr->prepared_at;
2422  gxact->prepare_start_lsn = start_lsn;
2423  gxact->prepare_end_lsn = end_lsn;
2424  gxact->xid = hdr->xid;
2425  gxact->owner = hdr->owner;
2427  gxact->valid = false;
2428  gxact->ondisk = XLogRecPtrIsInvalid(start_lsn);
2429  gxact->inredo = true; /* yes, added in redo */
2430  strcpy(gxact->gid, gid);
2431 
2432  /* And insert it into the active array */
2435 
2436  if (origin_id != InvalidRepOriginId)
2437  {
2438  /* recover apply progress */
2439  replorigin_advance(origin_id, hdr->origin_lsn, end_lsn,
2440  false /* backward */ , false /* WAL */ );
2441  }
2442 
2443  elog(DEBUG2, "added 2PC data in shared memory for transaction %u", gxact->xid);
2444 }
bool LWLockHeldByMeInMode(LWLock *l, LWLockMode mode)
Definition: lwlock.c:1859
int errhint(const char *fmt,...)
Definition: elog.c:987
static TwoPhaseStateData * TwoPhaseState
Definition: twophase.c:191
GlobalTransaction freeGXacts
Definition: twophase.c:182
int errcode(int sqlerrcode)
Definition: elog.c:575
TransactionId xid
Definition: twophase.c:905
void replorigin_advance(RepOriginId node, XLogRecPtr remote_commit, XLogRecPtr local_commit, bool go_backward, bool wal_log)
Definition: origin.c:834
GlobalTransaction next
Definition: twophase.c:151
bool RecoveryInProgress(void)
Definition: xlog.c:7949
char gid[GIDSIZE]
Definition: twophase.c:172
BackendId locking_backend
Definition: twophase.c:168
XLogRecPtr prepare_start_lsn
Definition: twophase.c:163
#define ERROR
Definition: elog.h:43
int max_prepared_xacts
Definition: twophase.c:117
#define DEBUG2
Definition: elog.h:24
static char * buf
Definition: pg_test_fsync.c:67
#define ereport(elevel, rest)
Definition: elog.h:122
GlobalTransaction prepXacts[FLEXIBLE_ARRAY_MEMBER]
Definition: twophase.c:188
#define XLogRecPtrIsInvalid(r)
Definition: xlogdefs.h:29
#define InvalidBackendId
Definition: backendid.h:23
#define Assert(condition)
Definition: c.h:699
#define MAXALIGN(LEN)
Definition: c.h:652
#define InvalidRepOriginId
Definition: origin.h:34
TransactionId xid
Definition: twophase.c:165
TimestampTz prepared_at
Definition: twophase.c:154
int errmsg(const char *fmt,...)
Definition: elog.c:797
XLogRecPtr origin_lsn
Definition: twophase.c:915
#define elog
Definition: elog.h:219
TimestampTz prepared_at
Definition: twophase.c:907
XLogRecPtr prepare_end_lsn
Definition: twophase.c:164

◆ PrepareRedoRemove()

void PrepareRedoRemove ( TransactionId  xid,
bool  giveWarning 
)

Definition at line 2456 of file twophase.c.

References Assert, DEBUG2, elog, i, GlobalTransactionData::inredo, LW_EXCLUSIVE, LWLockHeldByMeInMode(), TwoPhaseStateData::numPrepXacts, GlobalTransactionData::ondisk, TwoPhaseStateData::prepXacts, RecoveryInProgress(), RemoveGXact(), RemoveTwoPhaseFile(), and GlobalTransactionData::xid.

Referenced by ProcessTwoPhaseBuffer(), and xact_redo().

2457 {
2458  GlobalTransaction gxact = NULL;
2459  int i;
2460  bool found = false;
2461 
2462  Assert(LWLockHeldByMeInMode(TwoPhaseStateLock, LW_EXCLUSIVE));
2464 
2465  for (i = 0; i < TwoPhaseState->numPrepXacts; i++)
2466  {
2467  gxact = TwoPhaseState->prepXacts[i];
2468 
2469  if (gxact->xid == xid)
2470  {
2471  Assert(gxact->inredo);
2472  found = true;
2473  break;
2474  }
2475  }
2476 
2477  /*
2478  * Just leave if there is nothing, this is expected during WAL replay.
2479  */
2480  if (!found)
2481  return;
2482 
2483  /*
2484  * And now we can clean up any files we may have left.
2485  */
2486  elog(DEBUG2, "removing 2PC data for transaction %u", xid);
2487  if (gxact->ondisk)
2488  RemoveTwoPhaseFile(xid, giveWarning);
2489  RemoveGXact(gxact);
2490 
2491  return;
2492 }
bool LWLockHeldByMeInMode(LWLock *l, LWLockMode mode)
Definition: lwlock.c:1859
static TwoPhaseStateData * TwoPhaseState
Definition: twophase.c:191
bool RecoveryInProgress(void)
Definition: xlog.c:7949
static void RemoveGXact(GlobalTransaction gxact)
Definition: twophase.c:633
#define DEBUG2
Definition: elog.h:24
GlobalTransaction prepXacts[FLEXIBLE_ARRAY_MEMBER]
Definition: twophase.c:188
static void RemoveTwoPhaseFile(TransactionId xid, bool giveWarning)
Definition: twophase.c:1621
#define Assert(condition)
Definition: c.h:699
TransactionId xid
Definition: twophase.c:165
int i
#define elog
Definition: elog.h:219

◆ PrescanPreparedTransactions()

TransactionId PrescanPreparedTransactions ( TransactionId **  xids_p,
int *  nxids_p 
)

Definition at line 1862 of file twophase.c.

References Assert, buf, i, GlobalTransactionData::inredo, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), VariableCacheData::nextXid, TwoPhaseStateData::numPrepXacts, GlobalTransactionData::ondisk, palloc(), pfree(), GlobalTransactionData::prepare_start_lsn, TwoPhaseStateData::prepXacts, ProcessTwoPhaseBuffer(), repalloc(), ShmemVariableCache, TransactionIdPrecedes(), and GlobalTransactionData::xid.

Referenced by StartupXLOG(), and xlog_redo().

1863 {
1864  TransactionId origNextXid = ShmemVariableCache->nextXid;
1865  TransactionId result = origNextXid;
1866  TransactionId *xids = NULL;
1867  int nxids = 0;
1868  int allocsize = 0;
1869  int i;
1870 
1871  LWLockAcquire(TwoPhaseStateLock, LW_EXCLUSIVE);
1872  for (i = 0; i < TwoPhaseState->numPrepXacts; i++)
1873  {
1874  TransactionId xid;
1875  char *buf;
1877 
1878  Assert(gxact->inredo);
1879 
1880  xid = gxact->xid;
1881 
1882  buf = ProcessTwoPhaseBuffer(xid,
1883  gxact->prepare_start_lsn,
1884  gxact->ondisk, false, true);
1885 
1886  if (buf == NULL)
1887  continue;
1888 
1889  /*
1890  * OK, we think this file is valid. Incorporate xid into the
1891  * running-minimum result.
1892  */
1893  if (TransactionIdPrecedes(xid, result))
1894  result = xid;
1895 
1896  if (xids_p)
1897  {
1898  if (nxids == allocsize)
1899  {
1900  if (nxids == 0)
1901  {
1902  allocsize = 10;
1903  xids = palloc(allocsize * sizeof(TransactionId));
1904  }
1905  else
1906  {
1907  allocsize = allocsize * 2;
1908  xids = repalloc(xids, allocsize * sizeof(TransactionId));
1909  }
1910  }
1911  xids[nxids++] = xid;
1912  }
1913 
1914  pfree(buf);
1915  }
1916  LWLockRelease(TwoPhaseStateLock);
1917 
1918  if (xids_p)
1919  {
1920  *xids_p = xids;
1921  *nxids_p = nxids;
1922  }
1923 
1924  return result;
1925 }
static TwoPhaseStateData * TwoPhaseState
Definition: twophase.c:191
uint32 TransactionId
Definition: c.h:474
XLogRecPtr prepare_start_lsn
Definition: twophase.c:163
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1725
void pfree(void *pointer)
Definition: mcxt.c:1031
TransactionId nextXid
Definition: transam.h:117
static char * buf
Definition: pg_test_fsync.c:67
VariableCache ShmemVariableCache
Definition: varsup.c:34
GlobalTransaction prepXacts[FLEXIBLE_ARRAY_MEMBER]
Definition: twophase.c:188
bool TransactionIdPrecedes(TransactionId id1, TransactionId id2)
Definition: transam.c:300
static char * ProcessTwoPhaseBuffer(TransactionId xid, XLogRecPtr prepare_start_lsn, bool fromdisk, bool setParent, bool setNextXid)
Definition: twophase.c:2084
#define Assert(condition)
Definition: c.h:699
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1121
void * repalloc(void *pointer, Size size)
Definition: mcxt.c:1044
TransactionId xid
Definition: twophase.c:165
void * palloc(Size size)
Definition: mcxt.c:924
int i

◆ RecoverPreparedTransactions()

void RecoverPreparedTransactions ( void  )

Definition at line 1983 of file twophase.c.

References Assert, buf, TwoPhaseFileHeader::database, ereport, errmsg(), GlobalTransactionData::gid, TwoPhaseFileHeader::gidlen, GXactLoadSubxactData(), i, InHotStandby, GlobalTransactionData::inredo, LOG, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), MarkAsPrepared(), MarkAsPreparingGuts(), MAXALIGN, TwoPhaseFileHeader::nabortrels, TwoPhaseFileHeader::ncommitrels, TwoPhaseFileHeader::ninvalmsgs, TwoPhaseFileHeader::nsubxacts, TwoPhaseStateData::numPrepXacts, GlobalTransactionData::ondisk, TwoPhaseFileHeader::owner, pfree(), PostPrepare_Twophase(), GlobalTransactionData::prepare_start_lsn, TwoPhaseFileHeader::prepared_at, TwoPhaseStateData::prepXacts, ProcessRecords(), ProcessTwoPhaseBuffer(), StandbyReleaseLockTree(), TransactionIdEquals, twophase_recover_callbacks, GlobalTransactionData::xid, and TwoPhaseFileHeader::xid.

Referenced by StartupXLOG().

1984 {
1985  int i;
1986 
1987  LWLockAcquire(TwoPhaseStateLock, LW_EXCLUSIVE);
1988  for (i = 0; i < TwoPhaseState->numPrepXacts; i++)
1989  {
1990  TransactionId xid;
1991  char *buf;
1993  char *bufptr;
1994  TwoPhaseFileHeader *hdr;
1995  TransactionId *subxids;
1996  const char *gid;
1997 
1998  xid = gxact->xid;
1999 
2000  /*
2001  * Reconstruct subtrans state for the transaction --- needed because
2002  * pg_subtrans is not preserved over a restart. Note that we are
2003  * linking all the subtransactions directly to the top-level XID;
2004  * there may originally have been a more complex hierarchy, but
2005  * there's no need to restore that exactly. It's possible that
2006  * SubTransSetParent has been set before, if the prepared transaction
2007  * generated xid assignment records.
2008  */
2009  buf = ProcessTwoPhaseBuffer(xid,
2010  gxact->prepare_start_lsn,
2011  gxact->ondisk, true, false);
2012  if (buf == NULL)
2013  continue;
2014 
2015  ereport(LOG,
2016  (errmsg("recovering prepared transaction %u from shared memory", xid)));
2017 
2018  hdr = (TwoPhaseFileHeader *) buf;
2019  Assert(TransactionIdEquals(hdr->xid, xid));
2020  bufptr = buf + MAXALIGN(sizeof(TwoPhaseFileHeader));
2021  gid = (const char *) bufptr;
2022  bufptr += MAXALIGN(hdr->gidlen);
2023  subxids = (TransactionId *) bufptr;
2024  bufptr += MAXALIGN(hdr->nsubxacts * sizeof(TransactionId));
2025  bufptr += MAXALIGN(hdr->ncommitrels * sizeof(RelFileNode));
2026  bufptr += MAXALIGN(hdr->nabortrels * sizeof(RelFileNode));
2027  bufptr += MAXALIGN(hdr->ninvalmsgs * sizeof(SharedInvalidationMessage));
2028 
2029  /*
2030  * Recreate its GXACT and dummy PGPROC. But, check whether it was
2031  * added in redo and already has a shmem entry for it.
2032  */
2033  MarkAsPreparingGuts(gxact, xid, gid,
2034  hdr->prepared_at,
2035  hdr->owner, hdr->database);
2036 
2037  /* recovered, so reset the flag for entries generated by redo */
2038  gxact->inredo = false;
2039 
2040  GXactLoadSubxactData(gxact, hdr->nsubxacts, subxids);
2041  MarkAsPrepared(gxact, true);
2042 
2043  LWLockRelease(TwoPhaseStateLock);
2044 
2045  /*
2046  * Recover other state (notably locks) using resource managers.
2047  */
2049 
2050  /*
2051  * Release locks held by the standby process after we process each
2052  * prepared transaction. As a result, we don't need too many
2053  * additional locks at any one time.
2054  */
2055  if (InHotStandby)
2056  StandbyReleaseLockTree(xid, hdr->nsubxacts, subxids);
2057 
2058  /*
2059  * We're done with recovering this transaction. Clear MyLockedGxact,
2060  * like we do in PrepareTransaction() during normal operation.
2061  */
2063 
2064  pfree(buf);
2065 
2066  LWLockAcquire(TwoPhaseStateLock, LW_EXCLUSIVE);
2067  }
2068 
2069  LWLockRelease(TwoPhaseStateLock);
2070 }
static TwoPhaseStateData * TwoPhaseState
Definition: twophase.c:191
#define TransactionIdEquals(id1, id2)
Definition: transam.h:43
uint32 TransactionId
Definition: c.h:474
static void ProcessRecords(char *bufptr, TransactionId xid, const TwoPhaseCallback callbacks[])
Definition: twophase.c:1593
const TwoPhaseCallback twophase_recover_callbacks[TWOPHASE_RM_MAX_ID+1]
Definition: twophase_rmgr.c:24
#define InHotStandby
Definition: xlog.h:74
TransactionId xid
Definition: twophase.c:905
#define LOG
Definition: elog.h:26
XLogRecPtr prepare_start_lsn
Definition: twophase.c:163
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1725
void pfree(void *pointer)
Definition: mcxt.c:1031
static void MarkAsPreparingGuts(GlobalTransaction gxact, TransactionId xid, const char *gid, TimestampTz prepared_at, Oid owner, Oid databaseid)
Definition: twophase.c:446
static void GXactLoadSubxactData(GlobalTransaction gxact, int nsubxacts, TransactionId *children)
Definition: twophase.c:508
static char * buf
Definition: pg_test_fsync.c:67
void StandbyReleaseLockTree(TransactionId xid, int nsubxids, TransactionId *subxids)
Definition: standby.c:676
#define ereport(elevel, rest)
Definition: elog.h:122
GlobalTransaction prepXacts[FLEXIBLE_ARRAY_MEMBER]
Definition: twophase.c:188
static char * ProcessTwoPhaseBuffer(TransactionId xid, XLogRecPtr prepare_start_lsn, bool fromdisk, bool setParent, bool setNextXid)
Definition: twophase.c:2084
#define Assert(condition)
Definition: c.h:699
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1121
#define MAXALIGN(LEN)
Definition: c.h:652
static void MarkAsPrepared(GlobalTransaction gxact, bool lock_held)
Definition: twophase.c:535
TransactionId xid
Definition: twophase.c:165
int errmsg(const char *fmt,...)
Definition: elog.c:797
void PostPrepare_Twophase(void)
Definition: twophase.c:357
int i
TimestampTz prepared_at
Definition: twophase.c:907

◆ restoreTwoPhaseData()

void restoreTwoPhaseData ( void  )

Definition at line 1804 of file twophase.c.

References AllocateDir(), buf, dirent::d_name, FreeDir(), InvalidRepOriginId, InvalidXLogRecPtr, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), PrepareRedoAdd(), ProcessTwoPhaseBuffer(), ReadDir(), TWOPHASE_DIR, and GlobalTransactionData::xid.

Referenced by StartupXLOG().

1805 {
1806  DIR *cldir;
1807  struct dirent *clde;
1808 
1809  LWLockAcquire(TwoPhaseStateLock, LW_EXCLUSIVE);
1810  cldir = AllocateDir(TWOPHASE_DIR);
1811  while ((clde = ReadDir(cldir, TWOPHASE_DIR)) != NULL)
1812  {
1813  if (strlen(clde->d_name) == 8 &&
1814  strspn(clde->d_name, "0123456789ABCDEF") == 8)
1815  {
1816  TransactionId xid;
1817  char *buf;
1818 
1819  xid = (TransactionId) strtoul(clde->d_name, NULL, 16);
1820 
1822  true, false, false);
1823  if (buf == NULL)
1824  continue;
1825 
1828  }
1829  }
1830  LWLockRelease(TwoPhaseStateLock);
1831  FreeDir(cldir);
1832 }
#define InvalidXLogRecPtr
Definition: xlogdefs.h:28
uint32 TransactionId
Definition: c.h:474
Definition: dirent.h:9
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1725
Definition: dirent.c:25
static char * buf
Definition: pg_test_fsync.c:67
DIR * AllocateDir(const char *dirname)
Definition: fd.c:2590
static char * ProcessTwoPhaseBuffer(TransactionId xid, XLogRecPtr prepare_start_lsn, bool fromdisk, bool setParent, bool setNextXid)
Definition: twophase.c:2084
void PrepareRedoAdd(char *buf, XLogRecPtr start_lsn, XLogRecPtr end_lsn, RepOriginId origin_id)
Definition: twophase.c:2386
struct dirent * ReadDir(DIR *dir, const char *dirname)
Definition: fd.c:2656
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1121
#define InvalidRepOriginId
Definition: origin.h:34
#define TWOPHASE_DIR
Definition: twophase.c:114
char d_name[MAX_PATH]
Definition: dirent.h:14
int FreeDir(DIR *dir)
Definition: fd.c:2708

◆ StandbyRecoverPreparedTransactions()

void StandbyRecoverPreparedTransactions ( void  )

Definition at line 1942 of file twophase.c.

References Assert, buf, i, GlobalTransactionData::inredo, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), TwoPhaseStateData::numPrepXacts, GlobalTransactionData::ondisk, pfree(), GlobalTransactionData::prepare_start_lsn, TwoPhaseStateData::prepXacts, ProcessTwoPhaseBuffer(), and GlobalTransactionData::xid.

Referenced by StartupXLOG(), and xlog_redo().

1943 {
1944  int i;
1945 
1946  LWLockAcquire(TwoPhaseStateLock, LW_EXCLUSIVE);
1947  for (i = 0; i < TwoPhaseState->numPrepXacts; i++)
1948  {
1949  TransactionId xid;
1950  char *buf;
1952 
1953  Assert(gxact->inredo);
1954 
1955  xid = gxact->xid;
1956 
1957  buf = ProcessTwoPhaseBuffer(xid,
1958  gxact->prepare_start_lsn,
1959  gxact->ondisk, false, false);
1960  if (buf != NULL)
1961  pfree(buf);
1962  }
1963  LWLockRelease(TwoPhaseStateLock);
1964 }
static TwoPhaseStateData * TwoPhaseState
Definition: twophase.c:191
uint32 TransactionId
Definition: c.h:474
XLogRecPtr prepare_start_lsn
Definition: twophase.c:163
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1725
void pfree(void *pointer)
Definition: mcxt.c:1031
static char * buf
Definition: pg_test_fsync.c:67
GlobalTransaction prepXacts[FLEXIBLE_ARRAY_MEMBER]
Definition: twophase.c:188
static char * ProcessTwoPhaseBuffer(TransactionId xid, XLogRecPtr prepare_start_lsn, bool fromdisk, bool setParent, bool setNextXid)
Definition: twophase.c:2084
#define Assert(condition)
Definition: c.h:699
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1121
TransactionId xid
Definition: twophase.c:165
int i

◆ StandbyTransactionIdIsPrepared()

bool StandbyTransactionIdIsPrepared ( TransactionId  xid)

Definition at line 1405 of file twophase.c.

References Assert, buf, max_prepared_xacts, pfree(), ReadTwoPhaseFile(), TransactionIdEquals, TransactionIdIsValid, and TwoPhaseFileHeader::xid.

Referenced by KnownAssignedXidsRemovePreceding(), and StandbyReleaseOldLocks().

1406 {
1407  char *buf;
1408  TwoPhaseFileHeader *hdr;
1409  bool result;
1410 
1412 
1413  if (max_prepared_xacts <= 0)
1414  return false; /* nothing to do */
1415 
1416  /* Read and validate file */
1417  buf = ReadTwoPhaseFile(xid, false);
1418  if (buf == NULL)
1419  return false;
1420 
1421  /* Check header also */
1422  hdr = (TwoPhaseFileHeader *) buf;
1423  result = TransactionIdEquals(hdr->xid, xid);
1424  pfree(buf);
1425 
1426  return result;
1427 }
#define TransactionIdEquals(id1, id2)
Definition: transam.h:43
TransactionId xid
Definition: twophase.c:905
void pfree(void *pointer)
Definition: mcxt.c:1031
int max_prepared_xacts
Definition: twophase.c:117
static char * buf
Definition: pg_test_fsync.c:67
static char * ReadTwoPhaseFile(TransactionId xid, bool give_warnings)
Definition: twophase.c:1212
#define Assert(condition)
Definition: c.h:699
#define TransactionIdIsValid(xid)
Definition: transam.h:41

◆ StartPrepare()

void StartPrepare ( GlobalTransaction  gxact)

Definition at line 991 of file twophase.c.

References PROC_HDR::allPgXact, PROC_HDR::allProcs, xllist::bytes_free, StateFileChunk::data, TwoPhaseFileHeader::database, PGPROC::databaseId, GlobalTransactionData::gid, TwoPhaseFileHeader::gidlen, GXactLoadSubxactData(), xllist::head, TwoPhaseFileHeader::initfileinval, StateFileChunk::len, TwoPhaseFileHeader::magic, Max, TwoPhaseFileHeader::nabortrels, TwoPhaseFileHeader::ncommitrels, StateFileChunk::next, TwoPhaseFileHeader::ninvalmsgs, TwoPhaseFileHeader::nsubxacts, xllist::num_chunks, GlobalTransactionData::owner, TwoPhaseFileHeader::owner, palloc(), palloc0(), pfree(), GlobalTransactionData::pgprocno, GlobalTransactionData::prepared_at, TwoPhaseFileHeader::prepared_at, ProcGlobal, records, save_state_data(), smgrGetPendingDeletes(), xllist::tail, TwoPhaseFileHeader::total_len, xllist::total_len, TWOPHASE_MAGIC, xactGetCommittedChildren(), xactGetCommittedInvalidationMessages(), GlobalTransactionData::xid, PGXACT::xid, and TwoPhaseFileHeader::xid.

Referenced by PrepareTransaction().

992 {
993  PGPROC *proc = &ProcGlobal->allProcs[gxact->pgprocno];
994  PGXACT *pgxact = &ProcGlobal->allPgXact[gxact->pgprocno];
995  TransactionId xid = pgxact->xid;
996  TwoPhaseFileHeader hdr;
997  TransactionId *children;
998  RelFileNode *commitrels;
999  RelFileNode *abortrels;
1000  SharedInvalidationMessage *invalmsgs;
1001 
1002  /* Initialize linked list */
1003  records.head = palloc0(sizeof(StateFileChunk));
1004  records.head->len = 0;
1005  records.head->next = NULL;
1006 
1007  records.bytes_free = Max(sizeof(TwoPhaseFileHeader), 512);
1009 
1011  records.num_chunks = 1;
1012 
1013  records.total_len = 0;
1014 
1015  /* Create header */
1016  hdr.magic = TWOPHASE_MAGIC;
1017  hdr.total_len = 0; /* EndPrepare will fill this in */
1018  hdr.xid = xid;
1019  hdr.database = proc->databaseId;
1020  hdr.prepared_at = gxact->prepared_at;
1021  hdr.owner = gxact->owner;
1022  hdr.nsubxacts = xactGetCommittedChildren(&children);
1023  hdr.ncommitrels = smgrGetPendingDeletes(true, &commitrels);
1024  hdr.nabortrels = smgrGetPendingDeletes(false, &abortrels);
1026  &hdr.initfileinval);
1027  hdr.gidlen = strlen(gxact->gid) + 1; /* Include '\0' */
1028 
1029  save_state_data(&hdr, sizeof(TwoPhaseFileHeader));
1030  save_state_data(gxact->gid, hdr.gidlen);
1031 
1032  /*
1033  * Add the additional info about subxacts, deletable files and cache
1034  * invalidation messages.
1035  */
1036  if (hdr.nsubxacts > 0)
1037  {
1038  save_state_data(children, hdr.nsubxacts * sizeof(TransactionId));
1039  /* While we have the child-xact data, stuff it in the gxact too */
1040  GXactLoadSubxactData(gxact, hdr.nsubxacts, children);
1041  }
1042  if (hdr.ncommitrels > 0)
1043  {
1044  save_state_data(commitrels, hdr.ncommitrels * sizeof(RelFileNode));
1045  pfree(commitrels);
1046  }
1047  if (hdr.nabortrels > 0)
1048  {
1049  save_state_data(abortrels, hdr.nabortrels * sizeof(RelFileNode));
1050  pfree(abortrels);
1051  }
1052  if (hdr.ninvalmsgs > 0)
1053  {
1054  save_state_data(invalmsgs,
1055  hdr.ninvalmsgs * sizeof(SharedInvalidationMessage));
1056  pfree(invalmsgs);
1057  }
1058 }
int xactGetCommittedChildren(TransactionId **ptr)
Definition: xact.c:5208
uint32 TransactionId
Definition: c.h:474
Definition: proc.h:219
PGXACT * allPgXact
Definition: proc.h:246
TransactionId xid
Definition: proc.h:221
StateFileChunk * tail
Definition: twophase.c:947
PROC_HDR * ProcGlobal
Definition: proc.c:80
TransactionId xid
Definition: twophase.c:905
uint32 num_chunks
Definition: twophase.c:948
char gid[GIDSIZE]
Definition: twophase.c:172
char * data
Definition: twophase.c:939
void pfree(void *pointer)
Definition: mcxt.c:1031
static void GXactLoadSubxactData(GlobalTransaction gxact, int nsubxacts, TransactionId *children)
Definition: twophase.c:508
uint32 bytes_free
Definition: twophase.c:949
int smgrGetPendingDeletes(bool forCommit, RelFileNode **ptr)
Definition: storage.c:388
uint32 len
Definition: twophase.c:940
Oid databaseId
Definition: proc.h:114
static struct xllist records
uint32 total_len
Definition: twophase.c:950
struct StateFileChunk * next
Definition: twophase.c:941
void * palloc0(Size size)
Definition: mcxt.c:955
#define TWOPHASE_MAGIC
Definition: twophase.c:899
#define Max(x, y)
Definition: c.h:851
StateFileChunk * head
Definition: twophase.c:946
static void save_state_data(const void *data, uint32 len)
Definition: twophase.c:963
TimestampTz prepared_at
Definition: twophase.c:154
void * palloc(Size size)
Definition: mcxt.c:924
int xactGetCommittedInvalidationMessages(SharedInvalidationMessage **msgs, bool *RelcacheInitFileInval)
Definition: inval.c:816
PGPROC * allProcs
Definition: proc.h:244
TimestampTz prepared_at
Definition: twophase.c:907
Definition: proc.h:95

◆ TwoPhaseGetDummyBackendId()

BackendId TwoPhaseGetDummyBackendId ( TransactionId  xid)

Definition at line 854 of file twophase.c.

References GlobalTransactionData::dummyBackendId, and TwoPhaseGetGXact().

Referenced by multixact_twophase_postcommit(), multixact_twophase_recover(), and PostPrepare_MultiXact().

855 {
856  GlobalTransaction gxact = TwoPhaseGetGXact(xid);
857 
858  return gxact->dummyBackendId;
859 }
static GlobalTransaction TwoPhaseGetGXact(TransactionId xid)
Definition: twophase.c:805
BackendId dummyBackendId
Definition: twophase.c:153

◆ TwoPhaseGetDummyProc()

PGPROC* TwoPhaseGetDummyProc ( TransactionId  xid)

Definition at line 866 of file twophase.c.

References PROC_HDR::allProcs, GlobalTransactionData::pgprocno, ProcGlobal, and TwoPhaseGetGXact().

Referenced by lock_twophase_postcommit(), lock_twophase_recover(), and PostPrepare_Locks().

867 {
868  GlobalTransaction gxact = TwoPhaseGetGXact(xid);
869 
870  return &ProcGlobal->allProcs[gxact->pgprocno];
871 }
static GlobalTransaction TwoPhaseGetGXact(TransactionId xid)
Definition: twophase.c:805
PROC_HDR * ProcGlobal
Definition: proc.c:80
PGPROC * allProcs
Definition: proc.h:244

◆ TwoPhaseShmemInit()

void TwoPhaseShmemInit ( void  )

Definition at line 252 of file twophase.c.

References Assert, GlobalTransactionData::dummyBackendId, TwoPhaseStateData::freeGXacts, i, IsUnderPostmaster, max_prepared_xacts, MAXALIGN, MaxBackends, GlobalTransactionData::next, TwoPhaseStateData::numPrepXacts, offsetof, PGPROC::pgprocno, GlobalTransactionData::pgprocno, PreparedXactProcs, ShmemInitStruct(), and TwoPhaseShmemSize().

Referenced by CreateSharedMemoryAndSemaphores().

253 {
254  bool found;
255 
256  TwoPhaseState = ShmemInitStruct("Prepared Transaction Table",
258  &found);
259  if (!IsUnderPostmaster)
260  {
261  GlobalTransaction gxacts;
262  int i;
263 
264  Assert(!found);
265  TwoPhaseState->freeGXacts = NULL;
267 
268  /*
269  * Initialize the linked list of free GlobalTransactionData structs
270  */
271  gxacts = (GlobalTransaction)
272  ((char *) TwoPhaseState +
273  MAXALIGN(offsetof(TwoPhaseStateData, prepXacts) +
275  for (i = 0; i < max_prepared_xacts; i++)
276  {
277  /* insert into linked list */
278  gxacts[i].next = TwoPhaseState->freeGXacts;
279  TwoPhaseState->freeGXacts = &gxacts[i];
280 
281  /* associate it with a PGPROC assigned by InitProcGlobal */
283 
284  /*
285  * Assign a unique ID for each dummy proc, so that the range of
286  * dummy backend IDs immediately follows the range of normal
287  * backend IDs. We don't dare to assign a real backend ID to dummy
288  * procs, because prepared transactions don't take part in cache
289  * invalidation like a real backend ID would imply, but having a
290  * unique ID for them is nevertheless handy. This arrangement
291  * allows you to allocate an array of size (MaxBackends +
292  * max_prepared_xacts + 1), and have a slot for every backend and
293  * prepared transaction. Currently multixact.c uses that
294  * technique.
295  */
296  gxacts[i].dummyBackendId = MaxBackends + 1 + i;
297  }
298  }
299  else
300  Assert(found);
301 }
static TwoPhaseStateData * TwoPhaseState
Definition: twophase.c:191
GlobalTransaction freeGXacts
Definition: twophase.c:182
PGPROC * PreparedXactProcs
Definition: proc.c:82
Size TwoPhaseShmemSize(void)
Definition: twophase.c:236
GlobalTransaction next
Definition: twophase.c:151
struct GlobalTransactionData * GlobalTransaction
Definition: twophase.h:26
int max_prepared_xacts
Definition: twophase.c:117
void * ShmemInitStruct(const char *name, Size size, bool *foundPtr)
Definition: shmem.c:372
int MaxBackends
Definition: globals.c:134
bool IsUnderPostmaster
Definition: globals.c:108
#define Assert(condition)
Definition: c.h:699
#define MAXALIGN(LEN)
Definition: c.h:652
int pgprocno
Definition: proc.h:110
int i
#define offsetof(type, field)
Definition: c.h:622
BackendId dummyBackendId
Definition: twophase.c:153

◆ TwoPhaseShmemSize()

Size TwoPhaseShmemSize ( void  )

Definition at line 236 of file twophase.c.

References add_size(), max_prepared_xacts, MAXALIGN, mul_size(), and offsetof.

Referenced by CreateSharedMemoryAndSemaphores(), and TwoPhaseShmemInit().

237 {
238  Size size;
239 
240  /* Need the fixed struct, the array of pointers, and the GTD structs */
241  size = offsetof(TwoPhaseStateData, prepXacts);
242  size = add_size(size, mul_size(max_prepared_xacts,
243  sizeof(GlobalTransaction)));
244  size = MAXALIGN(size);
245  size = add_size(size, mul_size(max_prepared_xacts,
246  sizeof(GlobalTransactionData)));
247 
248  return size;
249 }
int max_prepared_xacts
Definition: twophase.c:117
Size mul_size(Size s1, Size s2)
Definition: shmem.c:492
Size add_size(Size s1, Size s2)
Definition: shmem.c:475
size_t Size
Definition: c.h:433
#define MAXALIGN(LEN)
Definition: c.h:652
#define offsetof(type, field)
Definition: c.h:622

Variable Documentation

◆ max_prepared_xacts