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, bool lock_held)
 
BackendId TwoPhaseGetDummyBackendId (TransactionId xid, bool lock_held)
 
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 318 of file twophase.c.

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

Referenced by AbortTransaction(), and AtProcExit_Twophase().

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

◆ CheckPointTwoPhase()

void CheckPointTwoPhase ( XLogRecPtr  redo_horizon)

Definition at line 1751 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().

1752 {
1753  int i;
1754  int serialized_xacts = 0;
1755 
1756  if (max_prepared_xacts <= 0)
1757  return; /* nothing to do */
1758 
1759  TRACE_POSTGRESQL_TWOPHASE_CHECKPOINT_START();
1760 
1761  /*
1762  * We are expecting there to be zero GXACTs that need to be copied to
1763  * disk, so we perform all I/O while holding TwoPhaseStateLock for
1764  * simplicity. This prevents any new xacts from preparing while this
1765  * occurs, which shouldn't be a problem since the presence of long-lived
1766  * prepared xacts indicates the transaction manager isn't active.
1767  *
1768  * It's also possible to move I/O out of the lock, but on every error we
1769  * should check whether somebody committed our transaction in different
1770  * backend. Let's leave this optimization for future, if somebody will
1771  * spot that this place cause bottleneck.
1772  *
1773  * Note that it isn't possible for there to be a GXACT with a
1774  * prepare_end_lsn set prior to the last checkpoint yet is marked invalid,
1775  * because of the efforts with delayChkpt.
1776  */
1777  LWLockAcquire(TwoPhaseStateLock, LW_SHARED);
1778  for (i = 0; i < TwoPhaseState->numPrepXacts; i++)
1779  {
1780  /*
1781  * Note that we are using gxact not pgxact so this works in recovery
1782  * also
1783  */
1785 
1786  if ((gxact->valid || gxact->inredo) &&
1787  !gxact->ondisk &&
1788  gxact->prepare_end_lsn <= redo_horizon)
1789  {
1790  char *buf;
1791  int len;
1792 
1793  XlogReadTwoPhaseData(gxact->prepare_start_lsn, &buf, &len);
1794  RecreateTwoPhaseFile(gxact->xid, buf, len);
1795  gxact->ondisk = true;
1798  pfree(buf);
1799  serialized_xacts++;
1800  }
1801  }
1802  LWLockRelease(TwoPhaseStateLock);
1803 
1804  /*
1805  * Flush unconditionally the parent directory to make any information
1806  * durable on disk. Two-phase files could have been removed and those
1807  * removals need to be made persistent as well as any files newly created
1808  * previously since the last checkpoint.
1809  */
1810  fsync_fname(TWOPHASE_DIR, true);
1811 
1812  TRACE_POSTGRESQL_TWOPHASE_CHECKPOINT_DONE();
1813 
1814  if (log_checkpoints && serialized_xacts > 0)
1815  ereport(LOG,
1816  (errmsg_plural("%u two-phase state file was written "
1817  "for a long-running prepared transaction",
1818  "%u two-phase state files were written "
1819  "for long-running prepared transactions",
1820  serialized_xacts,
1821  serialized_xacts)));
1822 }
bool log_checkpoints
Definition: xlog.c:101
#define InvalidXLogRecPtr
Definition: xlogdefs.h:28
static TwoPhaseStateData * TwoPhaseState
Definition: twophase.c:192
int errmsg_plural(const char *fmt_singular, const char *fmt_plural, unsigned long n,...)
Definition: elog.c:837
void fsync_fname(const char *fname, bool isdir)
Definition: fd.c:582
#define LOG
Definition: elog.h:26
XLogRecPtr prepare_start_lsn
Definition: twophase.c:164
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1726
void pfree(void *pointer)
Definition: mcxt.c:1031
int max_prepared_xacts
Definition: twophase.c:118
static char * buf
Definition: pg_test_fsync.c:68
#define ereport(elevel, rest)
Definition: elog.h:141
GlobalTransaction prepXacts[FLEXIBLE_ARRAY_MEMBER]
Definition: twophase.c:189
static void RecreateTwoPhaseFile(TransactionId xid, void *content, int len)
Definition: twophase.c:1671
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1122
#define TWOPHASE_DIR
Definition: twophase.c:115
TransactionId xid
Definition: twophase.c:166
static void XlogReadTwoPhaseData(XLogRecPtr lsn, char **buf, int *len)
Definition: twophase.c:1383
int i
XLogRecPtr prepare_end_lsn
Definition: twophase.c:165

◆ EndPrepare()

void EndPrepare ( GlobalTransaction  gxact)

Definition at line 1077 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().

1078 {
1079  TwoPhaseFileHeader *hdr;
1080  StateFileChunk *record;
1081  bool replorigin;
1082 
1083  /* Add the end sentinel to the list of 2PC records */
1085  NULL, 0);
1086 
1087  /* Go back and fill in total_len in the file header record */
1088  hdr = (TwoPhaseFileHeader *) records.head->data;
1089  Assert(hdr->magic == TWOPHASE_MAGIC);
1090  hdr->total_len = records.total_len + sizeof(pg_crc32c);
1091 
1092  replorigin = (replorigin_session_origin != InvalidRepOriginId &&
1094 
1095  if (replorigin)
1096  {
1100  }
1101  else
1102  {
1104  hdr->origin_timestamp = 0;
1105  }
1106 
1107  /*
1108  * If the data size exceeds MaxAllocSize, we won't be able to read it in
1109  * ReadTwoPhaseFile. Check for that now, rather than fail in the case
1110  * where we write data to file and then re-read at commit time.
1111  */
1112  if (hdr->total_len > MaxAllocSize)
1113  ereport(ERROR,
1114  (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
1115  errmsg("two-phase state file maximum length exceeded")));
1116 
1117  /*
1118  * Now writing 2PC state data to WAL. We let the WAL's CRC protection
1119  * cover us, so no need to calculate a separate CRC.
1120  *
1121  * We have to set delayChkpt here, too; otherwise a checkpoint starting
1122  * immediately after the WAL record is inserted could complete without
1123  * fsync'ing our state file. (This is essentially the same kind of race
1124  * condition as the COMMIT-to-clog-write case that RecordTransactionCommit
1125  * uses delayChkpt for; see notes there.)
1126  *
1127  * We save the PREPARE record's location in the gxact for later use by
1128  * CheckPointTwoPhase.
1129  */
1131 
1133 
1134  MyPgXact->delayChkpt = true;
1135 
1136  XLogBeginInsert();
1137  for (record = records.head; record != NULL; record = record->next)
1138  XLogRegisterData(record->data, record->len);
1139 
1141 
1142  gxact->prepare_end_lsn = XLogInsert(RM_XACT_ID, XLOG_XACT_PREPARE);
1143 
1144  if (replorigin)
1145  {
1146  /* Move LSNs forward for this replication origin */
1148  gxact->prepare_end_lsn);
1149  }
1150 
1151  XLogFlush(gxact->prepare_end_lsn);
1152 
1153  /* If we crash now, we have prepared: WAL replay will fix things */
1154 
1155  /* Store record's start location to read that later on Commit */
1157 
1158  /*
1159  * Mark the prepared transaction as valid. As soon as xact.c marks
1160  * MyPgXact as not running our XID (which it will do immediately after
1161  * this function returns), others can commit/rollback the xact.
1162  *
1163  * NB: a side effect of this is to make a dummy ProcArray entry for the
1164  * prepared XID. This must happen before we clear the XID from MyPgXact,
1165  * else there is a window where the XID is not running according to
1166  * TransactionIdIsInProgress, and onlookers would be entitled to assume
1167  * the xact crashed. Instead we have a window where the same XID appears
1168  * twice in ProcArray, which is OK.
1169  */
1170  MarkAsPrepared(gxact, false);
1171 
1172  /*
1173  * Now we can mark ourselves as out of the commit critical section: a
1174  * checkpoint starting after this will certainly see the gxact as a
1175  * candidate for fsyncing.
1176  */
1177  MyPgXact->delayChkpt = false;
1178 
1179  /*
1180  * Remember that we have this GlobalTransaction entry locked for us. If
1181  * we crash after this point, it's too late to abort, but we must unlock
1182  * it so that the prepared transaction can be committed or rolled back.
1183  */
1184  MyLockedGxact = gxact;
1185 
1186  END_CRIT_SECTION();
1187 
1188  /*
1189  * Wait for synchronous replication, if required.
1190  *
1191  * Note that at this stage we have marked the prepare, but still show as
1192  * running in the procarray (twice!) and continue to hold locks.
1193  */
1194  SyncRepWaitForLSN(gxact->prepare_end_lsn, false);
1195 
1196  records.tail = records.head = NULL;
1197  records.num_chunks = 0;
1198 }
#define InvalidXLogRecPtr
Definition: xlogdefs.h:28
#define XLOG_XACT_PREPARE
Definition: xact.h:144
#define DoNotReplicateId
Definition: origin.h:35
StateFileChunk * tail
Definition: twophase.c:960
uint32 pg_crc32c
Definition: pg_crc32c.h:38
XLogRecPtr ProcLastRecPtr
Definition: xlog.c:352
void SyncRepWaitForLSN(XLogRecPtr lsn, bool commit)
Definition: syncrep.c:146
#define END_CRIT_SECTION()
Definition: miscadmin.h:134
#define START_CRIT_SECTION()
Definition: miscadmin.h:132
int errcode(int sqlerrcode)
Definition: elog.c:570
#define TWOPHASE_RM_END_ID
Definition: twophase_rmgr.h:24
#define XLOG_INCLUDE_ORIGIN
Definition: xlog.h:228
uint32 num_chunks
Definition: twophase.c:961
void XLogFlush(XLogRecPtr record)
Definition: xlog.c:2799
void RegisterTwoPhaseRecord(TwoPhaseRmgrId rmid, uint16 info, const void *data, uint32 len)
Definition: twophase.c:1204
PGXACT * MyPgXact
Definition: proc.c:69
XLogRecPtr prepare_start_lsn
Definition: twophase.c:164
char * data
Definition: twophase.c:952
#define ERROR
Definition: elog.h:43
TimestampTz origin_timestamp
Definition: twophase.c:929
XLogRecPtr replorigin_session_origin_lsn
Definition: origin.c:156
TimestampTz replorigin_session_origin_timestamp
Definition: origin.c:157
uint32 len
Definition: twophase.c:953
void XLogSetRecordFlags(uint8 flags)
Definition: xloginsert.c:397
#define ereport(elevel, rest)
Definition: elog.h:141
bool delayChkpt
Definition: proc.h:235
static struct xllist records
uint32 total_len
Definition: twophase.c:963
#define MaxAllocSize
Definition: memutils.h:40
struct StateFileChunk * next
Definition: twophase.c:954
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:912
StateFileChunk * head
Definition: twophase.c:959
#define Assert(condition)
Definition: c.h:732
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:1173
static void MarkAsPrepared(GlobalTransaction gxact, bool lock_held)
Definition: twophase.c:537
#define InvalidRepOriginId
Definition: origin.h:34
int errmsg(const char *fmt,...)
Definition: elog.c:784
static GlobalTransaction MyLockedGxact
Definition: twophase.c:200
XLogRecPtr origin_lsn
Definition: twophase.c:928
void XLogBeginInsert(void)
Definition: xloginsert.c:120
XLogRecPtr prepare_end_lsn
Definition: twophase.c:165

◆ FinishPreparedTransaction()

void FinishPreparedTransaction ( const char *  gid,
bool  isCommit 
)

Definition at line 1455 of file twophase.c.

References PROC_HDR::allPgXact, PROC_HDR::allProcs, Assert, AtEOXact_PgStat(), buf, DropRelationFiles(), GetUserId(), TwoPhaseFileHeader::gidlen, HOLD_INTERRUPTS, TwoPhaseFileHeader::initfileinval, 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(), TransactionIdEquals, TransactionIdLatest(), twophase_postabort_callbacks, twophase_postcommit_callbacks, GlobalTransactionData::valid, GlobalTransactionData::xid, PGXACT::xid, TwoPhaseFileHeader::xid, and XlogReadTwoPhaseData().

Referenced by standard_ProcessUtility().

1456 {
1457  GlobalTransaction gxact;
1458  PGPROC *proc;
1459  PGXACT *pgxact;
1460  TransactionId xid;
1461  char *buf;
1462  char *bufptr;
1463  TwoPhaseFileHeader *hdr;
1464  TransactionId latestXid;
1465  TransactionId *children;
1466  RelFileNode *commitrels;
1467  RelFileNode *abortrels;
1468  RelFileNode *delrels;
1469  int ndelrels;
1470  SharedInvalidationMessage *invalmsgs;
1471 
1472  /*
1473  * Validate the GID, and lock the GXACT to ensure that two backends do not
1474  * try to commit the same GID at once.
1475  */
1476  gxact = LockGXact(gid, GetUserId());
1477  proc = &ProcGlobal->allProcs[gxact->pgprocno];
1478  pgxact = &ProcGlobal->allPgXact[gxact->pgprocno];
1479  xid = pgxact->xid;
1480 
1481  /*
1482  * Read and validate 2PC state data. State data will typically be stored
1483  * in WAL files if the LSN is after the last checkpoint record, or moved
1484  * to disk if for some reason they have lived for a long time.
1485  */
1486  if (gxact->ondisk)
1487  buf = ReadTwoPhaseFile(xid, false);
1488  else
1489  XlogReadTwoPhaseData(gxact->prepare_start_lsn, &buf, NULL);
1490 
1491 
1492  /*
1493  * Disassemble the header area
1494  */
1495  hdr = (TwoPhaseFileHeader *) buf;
1496  Assert(TransactionIdEquals(hdr->xid, xid));
1497  bufptr = buf + MAXALIGN(sizeof(TwoPhaseFileHeader));
1498  bufptr += MAXALIGN(hdr->gidlen);
1499  children = (TransactionId *) bufptr;
1500  bufptr += MAXALIGN(hdr->nsubxacts * sizeof(TransactionId));
1501  commitrels = (RelFileNode *) bufptr;
1502  bufptr += MAXALIGN(hdr->ncommitrels * sizeof(RelFileNode));
1503  abortrels = (RelFileNode *) bufptr;
1504  bufptr += MAXALIGN(hdr->nabortrels * sizeof(RelFileNode));
1505  invalmsgs = (SharedInvalidationMessage *) bufptr;
1506  bufptr += MAXALIGN(hdr->ninvalmsgs * sizeof(SharedInvalidationMessage));
1507 
1508  /* compute latestXid among all children */
1509  latestXid = TransactionIdLatest(xid, hdr->nsubxacts, children);
1510 
1511  /* Prevent cancel/die interrupt while cleaning up */
1512  HOLD_INTERRUPTS();
1513 
1514  /*
1515  * The order of operations here is critical: make the XLOG entry for
1516  * commit or abort, then mark the transaction committed or aborted in
1517  * pg_xact, then remove its PGPROC from the global ProcArray (which means
1518  * TransactionIdIsInProgress will stop saying the prepared xact is in
1519  * progress), then run the post-commit or post-abort callbacks. The
1520  * callbacks will release the locks the transaction held.
1521  */
1522  if (isCommit)
1524  hdr->nsubxacts, children,
1525  hdr->ncommitrels, commitrels,
1526  hdr->ninvalmsgs, invalmsgs,
1527  hdr->initfileinval, gid);
1528  else
1530  hdr->nsubxacts, children,
1531  hdr->nabortrels, abortrels,
1532  gid);
1533 
1534  ProcArrayRemove(proc, latestXid);
1535 
1536  /*
1537  * In case we fail while running the callbacks, mark the gxact invalid so
1538  * no one else will try to commit/rollback, and so it will be recycled if
1539  * we fail after this point. It is still locked by our backend so it
1540  * won't go away yet.
1541  *
1542  * (We assume it's safe to do this without taking TwoPhaseStateLock.)
1543  */
1544  gxact->valid = false;
1545 
1546  /*
1547  * We have to remove any files that were supposed to be dropped. For
1548  * consistency with the regular xact.c code paths, must do this before
1549  * releasing locks, so do it before running the callbacks.
1550  *
1551  * NB: this code knows that we couldn't be dropping any temp rels ...
1552  */
1553  if (isCommit)
1554  {
1555  delrels = commitrels;
1556  ndelrels = hdr->ncommitrels;
1557  }
1558  else
1559  {
1560  delrels = abortrels;
1561  ndelrels = hdr->nabortrels;
1562  }
1563 
1564  /* Make sure files supposed to be dropped are dropped */
1565  DropRelationFiles(delrels, ndelrels, false);
1566 
1567  /*
1568  * Handle cache invalidation messages.
1569  *
1570  * Relcache init file invalidation requires processing both before and
1571  * after we send the SI messages. See AtEOXact_Inval()
1572  */
1573  if (hdr->initfileinval)
1575  SendSharedInvalidMessages(invalmsgs, hdr->ninvalmsgs);
1576  if (hdr->initfileinval)
1578 
1579  /*
1580  * Acquire the two-phase lock. We want to work on the two-phase callbacks
1581  * while holding it to avoid potential conflicts with other transactions
1582  * attempting to use the same GID, so the lock is released once the shared
1583  * memory state is cleared.
1584  */
1585  LWLockAcquire(TwoPhaseStateLock, LW_EXCLUSIVE);
1586 
1587  /* And now do the callbacks */
1588  if (isCommit)
1590  else
1592 
1593  PredicateLockTwoPhaseFinish(xid, isCommit);
1594 
1595  /* Clear shared memory state */
1596  RemoveGXact(gxact);
1597 
1598  /*
1599  * Release the lock as all callbacks are called and shared memory cleanup
1600  * is done.
1601  */
1602  LWLockRelease(TwoPhaseStateLock);
1603 
1604  /* Count the prepared xact as committed or aborted */
1605  AtEOXact_PgStat(isCommit, false);
1606 
1607  /*
1608  * And now we can clean up any files we may have left.
1609  */
1610  if (gxact->ondisk)
1611  RemoveTwoPhaseFile(xid, true);
1612 
1613  MyLockedGxact = NULL;
1614 
1616 
1617  pfree(buf);
1618 }
static void RecordTransactionAbortPrepared(TransactionId xid, int nchildren, TransactionId *children, int nrels, RelFileNode *rels, const char *gid)
Definition: twophase.c:2332
#define TransactionIdEquals(id1, id2)
Definition: transam.h:43
uint32 TransactionId
Definition: c.h:507
Definition: proc.h:222
Oid GetUserId(void)
Definition: miscinit.c:380
PGXACT * allPgXact
Definition: proc.h:249
TransactionId xid
Definition: proc.h:224
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:1624
const TwoPhaseCallback twophase_postcommit_callbacks[TWOPHASE_RM_MAX_ID+1]
Definition: twophase_rmgr.c:33
PROC_HDR * ProcGlobal
Definition: proc.c:81
static char * ReadTwoPhaseFile(TransactionId xid, bool missing_ok)
Definition: twophase.c:1227
TransactionId xid
Definition: twophase.c:918
XLogRecPtr prepare_start_lsn
Definition: twophase.c:164
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1726
#define RESUME_INTERRUPTS()
Definition: miscadmin.h:118
void pfree(void *pointer)
Definition: mcxt.c:1031
static GlobalTransaction LockGXact(const char *gid, Oid user)
Definition: twophase.c:559
void ProcArrayRemove(PGPROC *proc, TransactionId latestXid)
Definition: procarray.c:334
static void RemoveGXact(GlobalTransaction gxact)
Definition: twophase.c:635
void DropRelationFiles(RelFileNode *delrels, int ndelrels, bool isRedo)
Definition: md.c:976
void AtEOXact_PgStat(bool isCommit, bool parallel)
Definition: pgstat.c:2094
void PredicateLockTwoPhaseFinish(TransactionId xid, bool isCommit)
Definition: predicate.c:5022
static char * buf
Definition: pg_test_fsync.c:68
const TwoPhaseCallback twophase_postabort_callbacks[TWOPHASE_RM_MAX_ID+1]
Definition: twophase_rmgr.c:42
void RelationCacheInitFilePostInvalidate(void)
Definition: relcache.c:6069
static void RemoveTwoPhaseFile(TransactionId xid, bool giveWarning)
Definition: twophase.c:1652
void RelationCacheInitFilePreInvalidate(void)
Definition: relcache.c:6044
#define Assert(condition)
Definition: c.h:732
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1122
#define MAXALIGN(LEN)
Definition: c.h:685
void SendSharedInvalidMessages(const SharedInvalidationMessage *msgs, int n)
Definition: sinval.c:49
static void XlogReadTwoPhaseData(XLogRecPtr lsn, char **buf, int *len)
Definition: twophase.c:1383
static GlobalTransaction MyLockedGxact
Definition: twophase.c:200
#define HOLD_INTERRUPTS()
Definition: miscadmin.h:116
PGPROC * allProcs
Definition: proc.h:247
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:2238

◆ MarkAsPreparing()

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

Definition at line 373 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().

375 {
376  GlobalTransaction gxact;
377  int i;
378 
379  if (strlen(gid) >= GIDSIZE)
380  ereport(ERROR,
381  (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
382  errmsg("transaction identifier \"%s\" is too long",
383  gid)));
384 
385  /* fail immediately if feature is disabled */
386  if (max_prepared_xacts == 0)
387  ereport(ERROR,
388  (errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
389  errmsg("prepared transactions are disabled"),
390  errhint("Set max_prepared_transactions to a nonzero value.")));
391 
392  /* on first call, register the exit hook */
394  {
396  twophaseExitRegistered = true;
397  }
398 
399  LWLockAcquire(TwoPhaseStateLock, LW_EXCLUSIVE);
400 
401  /* Check for conflicting GID */
402  for (i = 0; i < TwoPhaseState->numPrepXacts; i++)
403  {
404  gxact = TwoPhaseState->prepXacts[i];
405  if (strcmp(gxact->gid, gid) == 0)
406  {
407  ereport(ERROR,
409  errmsg("transaction identifier \"%s\" is already in use",
410  gid)));
411  }
412  }
413 
414  /* Get a free gxact from the freelist */
415  if (TwoPhaseState->freeGXacts == NULL)
416  ereport(ERROR,
417  (errcode(ERRCODE_OUT_OF_MEMORY),
418  errmsg("maximum number of prepared transactions reached"),
419  errhint("Increase max_prepared_transactions (currently %d).",
421  gxact = TwoPhaseState->freeGXacts;
422  TwoPhaseState->freeGXacts = gxact->next;
423 
424  MarkAsPreparingGuts(gxact, xid, gid, prepared_at, owner, databaseid);
425 
426  gxact->ondisk = false;
427 
428  /* And insert it into the active array */
431 
432  LWLockRelease(TwoPhaseStateLock);
433 
434  return gxact;
435 }
int errhint(const char *fmt,...)
Definition: elog.c:974
static TwoPhaseStateData * TwoPhaseState
Definition: twophase.c:192
GlobalTransaction freeGXacts
Definition: twophase.c:183
int errcode(int sqlerrcode)
Definition: elog.c:570
static bool twophaseExitRegistered
Definition: twophase.c:202
GlobalTransaction next
Definition: twophase.c:152
char gid[GIDSIZE]
Definition: twophase.c:173
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1726
static void MarkAsPreparingGuts(GlobalTransaction gxact, TransactionId xid, const char *gid, TimestampTz prepared_at, Oid owner, Oid databaseid)
Definition: twophase.c:447
#define ERROR
Definition: elog.h:43
int max_prepared_xacts
Definition: twophase.c:118
#define GIDSIZE
Definition: xact.h:31
void before_shmem_exit(pg_on_exit_callback function, Datum arg)
Definition: ipc.c:333
#define ereport(elevel, rest)
Definition: elog.h:141
GlobalTransaction prepXacts[FLEXIBLE_ARRAY_MEMBER]
Definition: twophase.c:189
#define Assert(condition)
Definition: c.h:732
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1122
int errmsg(const char *fmt,...)
Definition: elog.c:784
int i
static void AtProcExit_Twophase(int code, Datum arg)
Definition: twophase.c:308
#define ERRCODE_DUPLICATE_OBJECT
Definition: streamutil.c:33

◆ ParsePrepareRecord()

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

Definition at line 1339 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.

1340 {
1341  TwoPhaseFileHeader *hdr;
1342  char *bufptr;
1343 
1344  hdr = (TwoPhaseFileHeader *) xlrec;
1345  bufptr = xlrec + MAXALIGN(sizeof(TwoPhaseFileHeader));
1346 
1347  parsed->origin_lsn = hdr->origin_lsn;
1348  parsed->origin_timestamp = hdr->origin_timestamp;
1349  parsed->twophase_xid = hdr->xid;
1350  parsed->dbId = hdr->database;
1351  parsed->nsubxacts = hdr->nsubxacts;
1352  parsed->nrels = hdr->ncommitrels;
1353  parsed->nabortrels = hdr->nabortrels;
1354  parsed->nmsgs = hdr->ninvalmsgs;
1355 
1356  strncpy(parsed->twophase_gid, bufptr, hdr->gidlen);
1357  bufptr += MAXALIGN(hdr->gidlen);
1358 
1359  parsed->subxacts = (TransactionId *) bufptr;
1360  bufptr += MAXALIGN(hdr->nsubxacts * sizeof(TransactionId));
1361 
1362  parsed->xnodes = (RelFileNode *) bufptr;
1363  bufptr += MAXALIGN(hdr->ncommitrels * sizeof(RelFileNode));
1364 
1365  parsed->abortnodes = (RelFileNode *) bufptr;
1366  bufptr += MAXALIGN(hdr->nabortrels * sizeof(RelFileNode));
1367 
1368  parsed->msgs = (SharedInvalidationMessage *) bufptr;
1369  bufptr += MAXALIGN(hdr->ninvalmsgs * sizeof(SharedInvalidationMessage));
1370 }
RelFileNode * xnodes
Definition: xact.h:312
uint32 TransactionId
Definition: c.h:507
TimestampTz origin_timestamp
Definition: xact.h:323
TransactionId twophase_xid
Definition: xact.h:317
TransactionId * subxacts
Definition: xact.h:309
SharedInvalidationMessage * msgs
Definition: xact.h:315
XLogRecPtr origin_lsn
Definition: xact.h:322
TransactionId xid
Definition: twophase.c:918
TimestampTz origin_timestamp
Definition: twophase.c:929
RelFileNode * abortnodes
Definition: xact.h:320
#define MAXALIGN(LEN)
Definition: c.h:685
XLogRecPtr origin_lsn
Definition: twophase.c:928
char twophase_gid[GIDSIZE]
Definition: xact.h:318

◆ PostPrepare_Twophase()

void PostPrepare_Twophase ( void  )

Definition at line 358 of file twophase.c.

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

Referenced by PrepareTransaction(), and RecoverPreparedTransactions().

359 {
360  LWLockAcquire(TwoPhaseStateLock, LW_EXCLUSIVE);
362  LWLockRelease(TwoPhaseStateLock);
363 
364  MyLockedGxact = NULL;
365 }
BackendId locking_backend
Definition: twophase.c:169
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1726
#define InvalidBackendId
Definition: backendid.h:23
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1122
static GlobalTransaction MyLockedGxact
Definition: twophase.c:200

◆ PrepareRedoAdd()

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

Definition at line 2391 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().

2393 {
2395  char *bufptr;
2396  const char *gid;
2397  GlobalTransaction gxact;
2398 
2399  Assert(LWLockHeldByMeInMode(TwoPhaseStateLock, LW_EXCLUSIVE));
2401 
2402  bufptr = buf + MAXALIGN(sizeof(TwoPhaseFileHeader));
2403  gid = (const char *) bufptr;
2404 
2405  /*
2406  * Reserve the GID for the given transaction in the redo code path.
2407  *
2408  * This creates a gxact struct and puts it into the active array.
2409  *
2410  * In redo, this struct is mainly used to track PREPARE/COMMIT entries in
2411  * shared memory. Hence, we only fill up the bare minimum contents here.
2412  * The gxact also gets marked with gxact->inredo set to true to indicate
2413  * that it got added in the redo phase
2414  */
2415 
2416  /* Get a free gxact from the freelist */
2417  if (TwoPhaseState->freeGXacts == NULL)
2418  ereport(ERROR,
2419  (errcode(ERRCODE_OUT_OF_MEMORY),
2420  errmsg("maximum number of prepared transactions reached"),
2421  errhint("Increase max_prepared_transactions (currently %d).",
2422  max_prepared_xacts)));
2423  gxact = TwoPhaseState->freeGXacts;
2424  TwoPhaseState->freeGXacts = gxact->next;
2425 
2426  gxact->prepared_at = hdr->prepared_at;
2427  gxact->prepare_start_lsn = start_lsn;
2428  gxact->prepare_end_lsn = end_lsn;
2429  gxact->xid = hdr->xid;
2430  gxact->owner = hdr->owner;
2432  gxact->valid = false;
2433  gxact->ondisk = XLogRecPtrIsInvalid(start_lsn);
2434  gxact->inredo = true; /* yes, added in redo */
2435  strcpy(gxact->gid, gid);
2436 
2437  /* And insert it into the active array */
2440 
2441  if (origin_id != InvalidRepOriginId)
2442  {
2443  /* recover apply progress */
2444  replorigin_advance(origin_id, hdr->origin_lsn, end_lsn,
2445  false /* backward */ , false /* WAL */ );
2446  }
2447 
2448  elog(DEBUG2, "added 2PC data in shared memory for transaction %u", gxact->xid);
2449 }
bool LWLockHeldByMeInMode(LWLock *l, LWLockMode mode)
Definition: lwlock.c:1860
int errhint(const char *fmt,...)
Definition: elog.c:974
static TwoPhaseStateData * TwoPhaseState
Definition: twophase.c:192
GlobalTransaction freeGXacts
Definition: twophase.c:183
int errcode(int sqlerrcode)
Definition: elog.c:570
TransactionId xid
Definition: twophase.c:918
void replorigin_advance(RepOriginId node, XLogRecPtr remote_commit, XLogRecPtr local_commit, bool go_backward, bool wal_log)
Definition: origin.c:860
GlobalTransaction next
Definition: twophase.c:152
bool RecoveryInProgress(void)
Definition: xlog.c:7884
char gid[GIDSIZE]
Definition: twophase.c:173
BackendId locking_backend
Definition: twophase.c:169
XLogRecPtr prepare_start_lsn
Definition: twophase.c:164
#define ERROR
Definition: elog.h:43
int max_prepared_xacts
Definition: twophase.c:118
#define DEBUG2
Definition: elog.h:24
static char * buf
Definition: pg_test_fsync.c:68
#define ereport(elevel, rest)
Definition: elog.h:141
GlobalTransaction prepXacts[FLEXIBLE_ARRAY_MEMBER]
Definition: twophase.c:189
#define XLogRecPtrIsInvalid(r)
Definition: xlogdefs.h:29
#define InvalidBackendId
Definition: backendid.h:23
#define Assert(condition)
Definition: c.h:732
#define MAXALIGN(LEN)
Definition: c.h:685
#define InvalidRepOriginId
Definition: origin.h:34
TransactionId xid
Definition: twophase.c:166
TimestampTz prepared_at
Definition: twophase.c:155
int errmsg(const char *fmt,...)
Definition: elog.c:784
#define elog(elevel,...)
Definition: elog.h:226
XLogRecPtr origin_lsn
Definition: twophase.c:928
TimestampTz prepared_at
Definition: twophase.c:920
XLogRecPtr prepare_end_lsn
Definition: twophase.c:165

◆ PrepareRedoRemove()

void PrepareRedoRemove ( TransactionId  xid,
bool  giveWarning 
)

Definition at line 2461 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().

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

◆ PrescanPreparedTransactions()

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

Definition at line 1895 of file twophase.c.

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

Referenced by StartupXLOG(), and xlog_redo().

1896 {
1898  TransactionId origNextXid = XidFromFullTransactionId(nextFullXid);
1899  TransactionId result = origNextXid;
1900  TransactionId *xids = NULL;
1901  int nxids = 0;
1902  int allocsize = 0;
1903  int i;
1904 
1905  LWLockAcquire(TwoPhaseStateLock, LW_EXCLUSIVE);
1906  for (i = 0; i < TwoPhaseState->numPrepXacts; i++)
1907  {
1908  TransactionId xid;
1909  char *buf;
1911 
1912  Assert(gxact->inredo);
1913 
1914  xid = gxact->xid;
1915 
1916  buf = ProcessTwoPhaseBuffer(xid,
1917  gxact->prepare_start_lsn,
1918  gxact->ondisk, false, true);
1919 
1920  if (buf == NULL)
1921  continue;
1922 
1923  /*
1924  * OK, we think this file is valid. Incorporate xid into the
1925  * running-minimum result.
1926  */
1927  if (TransactionIdPrecedes(xid, result))
1928  result = xid;
1929 
1930  if (xids_p)
1931  {
1932  if (nxids == allocsize)
1933  {
1934  if (nxids == 0)
1935  {
1936  allocsize = 10;
1937  xids = palloc(allocsize * sizeof(TransactionId));
1938  }
1939  else
1940  {
1941  allocsize = allocsize * 2;
1942  xids = repalloc(xids, allocsize * sizeof(TransactionId));
1943  }
1944  }
1945  xids[nxids++] = xid;
1946  }
1947 
1948  pfree(buf);
1949  }
1950  LWLockRelease(TwoPhaseStateLock);
1951 
1952  if (xids_p)
1953  {
1954  *xids_p = xids;
1955  *nxids_p = nxids;
1956  }
1957 
1958  return result;
1959 }
static TwoPhaseStateData * TwoPhaseState
Definition: twophase.c:192
uint32 TransactionId
Definition: c.h:507
FullTransactionId nextFullXid
Definition: transam.h:164
XLogRecPtr prepare_start_lsn
Definition: twophase.c:164
#define XidFromFullTransactionId(x)
Definition: transam.h:48
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1726
void pfree(void *pointer)
Definition: mcxt.c:1031
static char * buf
Definition: pg_test_fsync.c:68
VariableCache ShmemVariableCache
Definition: varsup.c:34
GlobalTransaction prepXacts[FLEXIBLE_ARRAY_MEMBER]
Definition: twophase.c:189
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:2118
#define Assert(condition)
Definition: c.h:732
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1122
void * repalloc(void *pointer, Size size)
Definition: mcxt.c:1044
TransactionId xid
Definition: twophase.c:166
void * palloc(Size size)
Definition: mcxt.c:924
int i

◆ RecoverPreparedTransactions()

void RecoverPreparedTransactions ( void  )

Definition at line 2017 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().

2018 {
2019  int i;
2020 
2021  LWLockAcquire(TwoPhaseStateLock, LW_EXCLUSIVE);
2022  for (i = 0; i < TwoPhaseState->numPrepXacts; i++)
2023  {
2024  TransactionId xid;
2025  char *buf;
2027  char *bufptr;
2028  TwoPhaseFileHeader *hdr;
2029  TransactionId *subxids;
2030  const char *gid;
2031 
2032  xid = gxact->xid;
2033 
2034  /*
2035  * Reconstruct subtrans state for the transaction --- needed because
2036  * pg_subtrans is not preserved over a restart. Note that we are
2037  * linking all the subtransactions directly to the top-level XID;
2038  * there may originally have been a more complex hierarchy, but
2039  * there's no need to restore that exactly. It's possible that
2040  * SubTransSetParent has been set before, if the prepared transaction
2041  * generated xid assignment records.
2042  */
2043  buf = ProcessTwoPhaseBuffer(xid,
2044  gxact->prepare_start_lsn,
2045  gxact->ondisk, true, false);
2046  if (buf == NULL)
2047  continue;
2048 
2049  ereport(LOG,
2050  (errmsg("recovering prepared transaction %u from shared memory", xid)));
2051 
2052  hdr = (TwoPhaseFileHeader *) buf;
2053  Assert(TransactionIdEquals(hdr->xid, xid));
2054  bufptr = buf + MAXALIGN(sizeof(TwoPhaseFileHeader));
2055  gid = (const char *) bufptr;
2056  bufptr += MAXALIGN(hdr->gidlen);
2057  subxids = (TransactionId *) bufptr;
2058  bufptr += MAXALIGN(hdr->nsubxacts * sizeof(TransactionId));
2059  bufptr += MAXALIGN(hdr->ncommitrels * sizeof(RelFileNode));
2060  bufptr += MAXALIGN(hdr->nabortrels * sizeof(RelFileNode));
2061  bufptr += MAXALIGN(hdr->ninvalmsgs * sizeof(SharedInvalidationMessage));
2062 
2063  /*
2064  * Recreate its GXACT and dummy PGPROC. But, check whether it was
2065  * added in redo and already has a shmem entry for it.
2066  */
2067  MarkAsPreparingGuts(gxact, xid, gid,
2068  hdr->prepared_at,
2069  hdr->owner, hdr->database);
2070 
2071  /* recovered, so reset the flag for entries generated by redo */
2072  gxact->inredo = false;
2073 
2074  GXactLoadSubxactData(gxact, hdr->nsubxacts, subxids);
2075  MarkAsPrepared(gxact, true);
2076 
2077  LWLockRelease(TwoPhaseStateLock);
2078 
2079  /*
2080  * Recover other state (notably locks) using resource managers.
2081  */
2083 
2084  /*
2085  * Release locks held by the standby process after we process each
2086  * prepared transaction. As a result, we don't need too many
2087  * additional locks at any one time.
2088  */
2089  if (InHotStandby)
2090  StandbyReleaseLockTree(xid, hdr->nsubxacts, subxids);
2091 
2092  /*
2093  * We're done with recovering this transaction. Clear MyLockedGxact,
2094  * like we do in PrepareTransaction() during normal operation.
2095  */
2097 
2098  pfree(buf);
2099 
2100  LWLockAcquire(TwoPhaseStateLock, LW_EXCLUSIVE);
2101  }
2102 
2103  LWLockRelease(TwoPhaseStateLock);
2104 }
static TwoPhaseStateData * TwoPhaseState
Definition: twophase.c:192
#define TransactionIdEquals(id1, id2)
Definition: transam.h:43
uint32 TransactionId
Definition: c.h:507
static void ProcessRecords(char *bufptr, TransactionId xid, const TwoPhaseCallback callbacks[])
Definition: twophase.c:1624
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:918
#define LOG
Definition: elog.h:26
XLogRecPtr prepare_start_lsn
Definition: twophase.c:164
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1726
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:447
static void GXactLoadSubxactData(GlobalTransaction gxact, int nsubxacts, TransactionId *children)
Definition: twophase.c:510
static char * buf
Definition: pg_test_fsync.c:68
void StandbyReleaseLockTree(TransactionId xid, int nsubxids, TransactionId *subxids)
Definition: standby.c:716
#define ereport(elevel, rest)
Definition: elog.h:141
GlobalTransaction prepXacts[FLEXIBLE_ARRAY_MEMBER]
Definition: twophase.c:189
static char * ProcessTwoPhaseBuffer(TransactionId xid, XLogRecPtr prepare_start_lsn, bool fromdisk, bool setParent, bool setNextXid)
Definition: twophase.c:2118
#define Assert(condition)
Definition: c.h:732
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1122
#define MAXALIGN(LEN)
Definition: c.h:685
static void MarkAsPrepared(GlobalTransaction gxact, bool lock_held)
Definition: twophase.c:537
TransactionId xid
Definition: twophase.c:166
int errmsg(const char *fmt,...)
Definition: elog.c:784
void PostPrepare_Twophase(void)
Definition: twophase.c:358
int i
TimestampTz prepared_at
Definition: twophase.c:920

◆ restoreTwoPhaseData()

void restoreTwoPhaseData ( void  )

Definition at line 1833 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().

1834 {
1835  DIR *cldir;
1836  struct dirent *clde;
1837 
1838  LWLockAcquire(TwoPhaseStateLock, LW_EXCLUSIVE);
1839  cldir = AllocateDir(TWOPHASE_DIR);
1840  while ((clde = ReadDir(cldir, TWOPHASE_DIR)) != NULL)
1841  {
1842  if (strlen(clde->d_name) == 8 &&
1843  strspn(clde->d_name, "0123456789ABCDEF") == 8)
1844  {
1845  TransactionId xid;
1846  char *buf;
1847 
1848  xid = (TransactionId) strtoul(clde->d_name, NULL, 16);
1849 
1851  true, false, false);
1852  if (buf == NULL)
1853  continue;
1854 
1857  }
1858  }
1859  LWLockRelease(TwoPhaseStateLock);
1860  FreeDir(cldir);
1861 }
#define InvalidXLogRecPtr
Definition: xlogdefs.h:28
uint32 TransactionId
Definition: c.h:507
Definition: dirent.h:9
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1726
Definition: dirent.c:25
static char * buf
Definition: pg_test_fsync.c:68
DIR * AllocateDir(const char *dirname)
Definition: fd.c:2472
static char * ProcessTwoPhaseBuffer(TransactionId xid, XLogRecPtr prepare_start_lsn, bool fromdisk, bool setParent, bool setNextXid)
Definition: twophase.c:2118
void PrepareRedoAdd(char *buf, XLogRecPtr start_lsn, XLogRecPtr end_lsn, RepOriginId origin_id)
Definition: twophase.c:2391
struct dirent * ReadDir(DIR *dir, const char *dirname)
Definition: fd.c:2538
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1122
#define InvalidRepOriginId
Definition: origin.h:34
#define TWOPHASE_DIR
Definition: twophase.c:115
char d_name[MAX_PATH]
Definition: dirent.h:14
int FreeDir(DIR *dir)
Definition: fd.c:2590

◆ StandbyRecoverPreparedTransactions()

void StandbyRecoverPreparedTransactions ( void  )

Definition at line 1976 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().

1977 {
1978  int i;
1979 
1980  LWLockAcquire(TwoPhaseStateLock, LW_EXCLUSIVE);
1981  for (i = 0; i < TwoPhaseState->numPrepXacts; i++)
1982  {
1983  TransactionId xid;
1984  char *buf;
1986 
1987  Assert(gxact->inredo);
1988 
1989  xid = gxact->xid;
1990 
1991  buf = ProcessTwoPhaseBuffer(xid,
1992  gxact->prepare_start_lsn,
1993  gxact->ondisk, false, false);
1994  if (buf != NULL)
1995  pfree(buf);
1996  }
1997  LWLockRelease(TwoPhaseStateLock);
1998 }
static TwoPhaseStateData * TwoPhaseState
Definition: twophase.c:192
uint32 TransactionId
Definition: c.h:507
XLogRecPtr prepare_start_lsn
Definition: twophase.c:164
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1726
void pfree(void *pointer)
Definition: mcxt.c:1031
static char * buf
Definition: pg_test_fsync.c:68
GlobalTransaction prepXacts[FLEXIBLE_ARRAY_MEMBER]
Definition: twophase.c:189
static char * ProcessTwoPhaseBuffer(TransactionId xid, XLogRecPtr prepare_start_lsn, bool fromdisk, bool setParent, bool setNextXid)
Definition: twophase.c:2118
#define Assert(condition)
Definition: c.h:732
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1122
TransactionId xid
Definition: twophase.c:166
int i

◆ StandbyTransactionIdIsPrepared()

bool StandbyTransactionIdIsPrepared ( TransactionId  xid)

Definition at line 1427 of file twophase.c.

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

Referenced by KnownAssignedXidsRemovePreceding(), and StandbyReleaseOldLocks().

1428 {
1429  char *buf;
1430  TwoPhaseFileHeader *hdr;
1431  bool result;
1432 
1434 
1435  if (max_prepared_xacts <= 0)
1436  return false; /* nothing to do */
1437 
1438  /* Read and validate file */
1439  buf = ReadTwoPhaseFile(xid, true);
1440  if (buf == NULL)
1441  return false;
1442 
1443  /* Check header also */
1444  hdr = (TwoPhaseFileHeader *) buf;
1445  result = TransactionIdEquals(hdr->xid, xid);
1446  pfree(buf);
1447 
1448  return result;
1449 }
#define TransactionIdEquals(id1, id2)
Definition: transam.h:43
static char * ReadTwoPhaseFile(TransactionId xid, bool missing_ok)
Definition: twophase.c:1227
TransactionId xid
Definition: twophase.c:918
void pfree(void *pointer)
Definition: mcxt.c:1031
int max_prepared_xacts
Definition: twophase.c:118
static char * buf
Definition: pg_test_fsync.c:68
#define Assert(condition)
Definition: c.h:732
#define TransactionIdIsValid(xid)
Definition: transam.h:41

◆ StartPrepare()

void StartPrepare ( GlobalTransaction  gxact)

Definition at line 1004 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().

1005 {
1006  PGPROC *proc = &ProcGlobal->allProcs[gxact->pgprocno];
1007  PGXACT *pgxact = &ProcGlobal->allPgXact[gxact->pgprocno];
1008  TransactionId xid = pgxact->xid;
1009  TwoPhaseFileHeader hdr;
1010  TransactionId *children;
1011  RelFileNode *commitrels;
1012  RelFileNode *abortrels;
1013  SharedInvalidationMessage *invalmsgs;
1014 
1015  /* Initialize linked list */
1016  records.head = palloc0(sizeof(StateFileChunk));
1017  records.head->len = 0;
1018  records.head->next = NULL;
1019 
1020  records.bytes_free = Max(sizeof(TwoPhaseFileHeader), 512);
1022 
1024  records.num_chunks = 1;
1025 
1026  records.total_len = 0;
1027 
1028  /* Create header */
1029  hdr.magic = TWOPHASE_MAGIC;
1030  hdr.total_len = 0; /* EndPrepare will fill this in */
1031  hdr.xid = xid;
1032  hdr.database = proc->databaseId;
1033  hdr.prepared_at = gxact->prepared_at;
1034  hdr.owner = gxact->owner;
1035  hdr.nsubxacts = xactGetCommittedChildren(&children);
1036  hdr.ncommitrels = smgrGetPendingDeletes(true, &commitrels);
1037  hdr.nabortrels = smgrGetPendingDeletes(false, &abortrels);
1039  &hdr.initfileinval);
1040  hdr.gidlen = strlen(gxact->gid) + 1; /* Include '\0' */
1041 
1042  save_state_data(&hdr, sizeof(TwoPhaseFileHeader));
1043  save_state_data(gxact->gid, hdr.gidlen);
1044 
1045  /*
1046  * Add the additional info about subxacts, deletable files and cache
1047  * invalidation messages.
1048  */
1049  if (hdr.nsubxacts > 0)
1050  {
1051  save_state_data(children, hdr.nsubxacts * sizeof(TransactionId));
1052  /* While we have the child-xact data, stuff it in the gxact too */
1053  GXactLoadSubxactData(gxact, hdr.nsubxacts, children);
1054  }
1055  if (hdr.ncommitrels > 0)
1056  {
1057  save_state_data(commitrels, hdr.ncommitrels * sizeof(RelFileNode));
1058  pfree(commitrels);
1059  }
1060  if (hdr.nabortrels > 0)
1061  {
1062  save_state_data(abortrels, hdr.nabortrels * sizeof(RelFileNode));
1063  pfree(abortrels);
1064  }
1065  if (hdr.ninvalmsgs > 0)
1066  {
1067  save_state_data(invalmsgs,
1068  hdr.ninvalmsgs * sizeof(SharedInvalidationMessage));
1069  pfree(invalmsgs);
1070  }
1071 }
int xactGetCommittedChildren(TransactionId **ptr)
Definition: xact.c:5410
uint32 TransactionId
Definition: c.h:507
Definition: proc.h:222
PGXACT * allPgXact
Definition: proc.h:249
TransactionId xid
Definition: proc.h:224
StateFileChunk * tail
Definition: twophase.c:960
PROC_HDR * ProcGlobal
Definition: proc.c:81
TransactionId xid
Definition: twophase.c:918
uint32 num_chunks
Definition: twophase.c:961
char gid[GIDSIZE]
Definition: twophase.c:173
char * data
Definition: twophase.c:952
void pfree(void *pointer)
Definition: mcxt.c:1031
static void GXactLoadSubxactData(GlobalTransaction gxact, int nsubxacts, TransactionId *children)
Definition: twophase.c:510
uint32 bytes_free
Definition: twophase.c:962
int smgrGetPendingDeletes(bool forCommit, RelFileNode **ptr)
Definition: storage.c:476
uint32 len
Definition: twophase.c:953
Oid databaseId
Definition: proc.h:114
static struct xllist records
uint32 total_len
Definition: twophase.c:963
struct StateFileChunk * next
Definition: twophase.c:954
void * palloc0(Size size)
Definition: mcxt.c:955
#define TWOPHASE_MAGIC
Definition: twophase.c:912
#define Max(x, y)
Definition: c.h:884
StateFileChunk * head
Definition: twophase.c:959
static void save_state_data(const void *data, uint32 len)
Definition: twophase.c:976
TimestampTz prepared_at
Definition: twophase.c:155
void * palloc(Size size)
Definition: mcxt.c:924
int xactGetCommittedInvalidationMessages(SharedInvalidationMessage **msgs, bool *RelcacheInitFileInval)
Definition: inval.c:828
PGPROC * allProcs
Definition: proc.h:247
TimestampTz prepared_at
Definition: twophase.c:920
Definition: proc.h:95

◆ TwoPhaseGetDummyBackendId()

BackendId TwoPhaseGetDummyBackendId ( TransactionId  xid,
bool  lock_held 
)

Definition at line 864 of file twophase.c.

References GlobalTransactionData::dummyBackendId, and TwoPhaseGetGXact().

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

865 {
866  GlobalTransaction gxact = TwoPhaseGetGXact(xid, lock_held);
867 
868  return gxact->dummyBackendId;
869 }
static GlobalTransaction TwoPhaseGetGXact(TransactionId xid, bool lock_held)
Definition: twophase.c:810
BackendId dummyBackendId
Definition: twophase.c:154

◆ TwoPhaseGetDummyProc()

PGPROC* TwoPhaseGetDummyProc ( TransactionId  xid,
bool  lock_held 
)

Definition at line 879 of file twophase.c.

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

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

880 {
881  GlobalTransaction gxact = TwoPhaseGetGXact(xid, lock_held);
882 
883  return &ProcGlobal->allProcs[gxact->pgprocno];
884 }
PROC_HDR * ProcGlobal
Definition: proc.c:81
static GlobalTransaction TwoPhaseGetGXact(TransactionId xid, bool lock_held)
Definition: twophase.c:810
PGPROC * allProcs
Definition: proc.h:247

◆ TwoPhaseShmemInit()

void TwoPhaseShmemInit ( void  )

Definition at line 253 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().

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

◆ TwoPhaseShmemSize()

Size TwoPhaseShmemSize ( void  )

Definition at line 237 of file twophase.c.

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

Referenced by CreateSharedMemoryAndSemaphores(), and TwoPhaseShmemInit().

238 {
239  Size size;
240 
241  /* Need the fixed struct, the array of pointers, and the GTD structs */
242  size = offsetof(TwoPhaseStateData, prepXacts);
243  size = add_size(size, mul_size(max_prepared_xacts,
244  sizeof(GlobalTransaction)));
245  size = MAXALIGN(size);
246  size = add_size(size, mul_size(max_prepared_xacts,
247  sizeof(GlobalTransactionData)));
248 
249  return size;
250 }
int max_prepared_xacts
Definition: twophase.c:118
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:466
#define MAXALIGN(LEN)
Definition: c.h:685
#define offsetof(type, field)
Definition: c.h:655

Variable Documentation

◆ max_prepared_xacts