PostgreSQL Source Code  git master
varsup.c
Go to the documentation of this file.
1 /*-------------------------------------------------------------------------
2  *
3  * varsup.c
4  * postgres OID & XID variables support routines
5  *
6  * Copyright (c) 2000-2020, PostgreSQL Global Development Group
7  *
8  * IDENTIFICATION
9  * src/backend/access/transam/varsup.c
10  *
11  *-------------------------------------------------------------------------
12  */
13 
14 #include "postgres.h"
15 
16 #include "access/clog.h"
17 #include "access/commit_ts.h"
18 #include "access/subtrans.h"
19 #include "access/transam.h"
20 #include "access/xact.h"
21 #include "access/xlog.h"
22 #include "commands/dbcommands.h"
23 #include "miscadmin.h"
24 #include "postmaster/autovacuum.h"
25 #include "storage/pmsignal.h"
26 #include "storage/proc.h"
27 #include "utils/syscache.h"
28 
29 
30 /* Number of OIDs to prefetch (preallocate) per XLOG write */
31 #define VAR_OID_PREFETCH 8192
32 
33 /* pointer to "variable cache" in shared memory (set up by shmem.c) */
35 
36 
37 /*
38  * Allocate the next FullTransactionId for a new transaction or
39  * subtransaction.
40  *
41  * The new XID is also stored into MyProc->xid/ProcGlobal->xids[] before
42  * returning.
43  *
44  * Note: when this is called, we are actually already inside a valid
45  * transaction, since XIDs are now not allocated until the transaction
46  * does something. So it is safe to do a database lookup if we want to
47  * issue a warning about XID wrap.
48  */
50 GetNewTransactionId(bool isSubXact)
51 {
52  FullTransactionId full_xid;
53  TransactionId xid;
54 
55  /*
56  * Workers synchronize transaction state at the beginning of each parallel
57  * operation, so we can't account for new XIDs after that point.
58  */
59  if (IsInParallelMode())
60  elog(ERROR, "cannot assign TransactionIds during a parallel operation");
61 
62  /*
63  * During bootstrap initialization, we return the special bootstrap
64  * transaction id.
65  */
67  {
68  Assert(!isSubXact);
72  }
73 
74  /* safety check, we should never get this far in a HS standby */
75  if (RecoveryInProgress())
76  elog(ERROR, "cannot assign TransactionIds during recovery");
77 
78  LWLockAcquire(XidGenLock, LW_EXCLUSIVE);
79 
80  full_xid = ShmemVariableCache->nextXid;
81  xid = XidFromFullTransactionId(full_xid);
82 
83  /*----------
84  * Check to see if it's safe to assign another XID. This protects against
85  * catastrophic data loss due to XID wraparound. The basic rules are:
86  *
87  * If we're past xidVacLimit, start trying to force autovacuum cycles.
88  * If we're past xidWarnLimit, start issuing warnings.
89  * If we're past xidStopLimit, refuse to execute transactions, unless
90  * we are running in single-user mode (which gives an escape hatch
91  * to the DBA who somehow got past the earlier defenses).
92  *
93  * Note that this coding also appears in GetNewMultiXactId.
94  *----------
95  */
96  if (TransactionIdFollowsOrEquals(xid, ShmemVariableCache->xidVacLimit))
97  {
98  /*
99  * For safety's sake, we release XidGenLock while sending signals,
100  * warnings, etc. This is not so much because we care about
101  * preserving concurrency in this situation, as to avoid any
102  * possibility of deadlock while doing get_database_name(). First,
103  * copy all the shared values we'll need in this path.
104  */
105  TransactionId xidWarnLimit = ShmemVariableCache->xidWarnLimit;
106  TransactionId xidStopLimit = ShmemVariableCache->xidStopLimit;
107  TransactionId xidWrapLimit = ShmemVariableCache->xidWrapLimit;
108  Oid oldest_datoid = ShmemVariableCache->oldestXidDB;
109 
110  LWLockRelease(XidGenLock);
111 
112  /*
113  * To avoid swamping the postmaster with signals, we issue the autovac
114  * request only once per 64K transaction starts. This still gives
115  * plenty of chances before we get into real trouble.
116  */
117  if (IsUnderPostmaster && (xid % 65536) == 0)
119 
120  if (IsUnderPostmaster &&
121  TransactionIdFollowsOrEquals(xid, xidStopLimit))
122  {
123  char *oldest_datname = get_database_name(oldest_datoid);
124 
125  /* complain even if that DB has disappeared */
126  if (oldest_datname)
127  ereport(ERROR,
128  (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
129  errmsg("database is not accepting commands to avoid wraparound data loss in database \"%s\"",
130  oldest_datname),
131  errhint("Stop the postmaster and vacuum that database in single-user mode.\n"
132  "You might also need to commit or roll back old prepared transactions, or drop stale replication slots.")));
133  else
134  ereport(ERROR,
135  (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
136  errmsg("database is not accepting commands to avoid wraparound data loss in database with OID %u",
137  oldest_datoid),
138  errhint("Stop the postmaster and vacuum that database in single-user mode.\n"
139  "You might also need to commit or roll back old prepared transactions, or drop stale replication slots.")));
140  }
141  else if (TransactionIdFollowsOrEquals(xid, xidWarnLimit))
142  {
143  char *oldest_datname = get_database_name(oldest_datoid);
144 
145  /* complain even if that DB has disappeared */
146  if (oldest_datname)
148  (errmsg("database \"%s\" must be vacuumed within %u transactions",
149  oldest_datname,
150  xidWrapLimit - xid),
151  errhint("To avoid a database shutdown, execute a database-wide VACUUM in that database.\n"
152  "You might also need to commit or roll back old prepared transactions, or drop stale replication slots.")));
153  else
155  (errmsg("database with OID %u must be vacuumed within %u transactions",
156  oldest_datoid,
157  xidWrapLimit - xid),
158  errhint("To avoid a database shutdown, execute a database-wide VACUUM in that database.\n"
159  "You might also need to commit or roll back old prepared transactions, or drop stale replication slots.")));
160  }
161 
162  /* Re-acquire lock and start over */
163  LWLockAcquire(XidGenLock, LW_EXCLUSIVE);
164  full_xid = ShmemVariableCache->nextXid;
165  xid = XidFromFullTransactionId(full_xid);
166  }
167 
168  /*
169  * If we are allocating the first XID of a new page of the commit log,
170  * zero out that commit-log page before returning. We must do this while
171  * holding XidGenLock, else another xact could acquire and commit a later
172  * XID before we zero the page. Fortunately, a page of the commit log
173  * holds 32K or more transactions, so we don't have to do this very often.
174  *
175  * Extend pg_subtrans and pg_commit_ts too.
176  */
177  ExtendCLOG(xid);
178  ExtendCommitTs(xid);
179  ExtendSUBTRANS(xid);
180 
181  /*
182  * Now advance the nextXid counter. This must not happen until after
183  * we have successfully completed ExtendCLOG() --- if that routine fails,
184  * we want the next incoming transaction to try it again. We cannot
185  * assign more XIDs until there is CLOG space for them.
186  */
187  FullTransactionIdAdvance(&ShmemVariableCache->nextXid);
188 
189  /*
190  * We must store the new XID into the shared ProcArray before releasing
191  * XidGenLock. This ensures that every active XID older than
192  * latestCompletedXid is present in the ProcArray, which is essential for
193  * correct OldestXmin tracking; see src/backend/access/transam/README.
194  *
195  * Note that readers of ProcGlobal->xids/PGPROC->xid should be careful
196  * to fetch the value for each proc only once, rather than assume they can
197  * read a value multiple times and get the same answer each time. Note we
198  * are assuming that TransactionId and int fetch/store are atomic.
199  *
200  * The same comments apply to the subxact xid count and overflow fields.
201  *
202  * Use of a write barrier prevents dangerous code rearrangement in this
203  * function; other backends could otherwise e.g. be examining my subxids
204  * info concurrently, and we don't want them to see an invalid
205  * intermediate state, such as an incremented nxids before the array entry
206  * is filled.
207  *
208  * Other processes that read nxids should do so before reading xids
209  * elements with a pg_read_barrier() in between, so that they can be sure
210  * not to read an uninitialized array element; see
211  * src/backend/storage/lmgr/README.barrier.
212  *
213  * If there's no room to fit a subtransaction XID into PGPROC, set the
214  * cache-overflowed flag instead. This forces readers to look in
215  * pg_subtrans to map subtransaction XIDs up to top-level XIDs. There is a
216  * race-condition window, in that the new XID will not appear as running
217  * until its parent link has been placed into pg_subtrans. However, that
218  * will happen before anyone could possibly have a reason to inquire about
219  * the status of the XID, so it seems OK. (Snapshots taken during this
220  * window *will* include the parent XID, so they will deliver the correct
221  * answer later on when someone does have a reason to inquire.)
222  */
223  if (!isSubXact)
224  {
229 
230  /* LWLockRelease acts as barrier */
231  MyProc->xid = xid;
232  ProcGlobal->xids[MyProc->pgxactoff] = xid;
233  }
234  else
235  {
237  int nxids = MyProc->subxidStatus.count;
238 
239  Assert(substat->count == MyProc->subxidStatus.count);
241 
242  if (nxids < PGPROC_MAX_CACHED_SUBXIDS)
243  {
244  MyProc->subxids.xids[nxids] = xid;
246  MyProc->subxidStatus.count = substat->count = nxids + 1;
247  }
248  else
249  MyProc->subxidStatus.overflowed = substat->overflowed = true;
250  }
251 
252  LWLockRelease(XidGenLock);
253 
254  return full_xid;
255 }
256 
257 /*
258  * Read nextXid but don't allocate it.
259  */
262 {
263  FullTransactionId fullXid;
264 
265  LWLockAcquire(XidGenLock, LW_SHARED);
266  fullXid = ShmemVariableCache->nextXid;
267  LWLockRelease(XidGenLock);
268 
269  return fullXid;
270 }
271 
272 /*
273  * Advance nextXid to the value after a given xid. The epoch is inferred.
274  * This must only be called during recovery or from two-phase start-up code.
275  */
276 void
278 {
279  FullTransactionId newNextFullXid;
280  TransactionId next_xid;
281  uint32 epoch;
282 
283  /*
284  * It is safe to read nextXid without a lock, because this is only
285  * called from the startup process or single-process mode, meaning that no
286  * other process can modify it.
287  */
289 
290  /* Fast return if this isn't an xid high enough to move the needle. */
291  next_xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
292  if (!TransactionIdFollowsOrEquals(xid, next_xid))
293  return;
294 
295  /*
296  * Compute the FullTransactionId that comes after the given xid. To do
297  * this, we preserve the existing epoch, but detect when we've wrapped
298  * into a new epoch. This is necessary because WAL records and 2PC state
299  * currently contain 32 bit xids. The wrap logic is safe in those cases
300  * because the span of active xids cannot exceed one epoch at any given
301  * point in the WAL stream.
302  */
304  epoch = EpochFromFullTransactionId(ShmemVariableCache->nextXid);
305  if (unlikely(xid < next_xid))
306  ++epoch;
307  newNextFullXid = FullTransactionIdFromEpochAndXid(epoch, xid);
308 
309  /*
310  * We still need to take a lock to modify the value when there are
311  * concurrent readers.
312  */
313  LWLockAcquire(XidGenLock, LW_EXCLUSIVE);
314  ShmemVariableCache->nextXid = newNextFullXid;
315  LWLockRelease(XidGenLock);
316 }
317 
318 /*
319  * Advance the cluster-wide value for the oldest valid clog entry.
320  *
321  * We must acquire XactTruncationLock to advance the oldestClogXid. It's not
322  * necessary to hold the lock during the actual clog truncation, only when we
323  * advance the limit, as code looking up arbitrary xids is required to hold
324  * XactTruncationLock from when it tests oldestClogXid through to when it
325  * completes the clog lookup.
326  */
327 void
329 {
330  LWLockAcquire(XactTruncationLock, LW_EXCLUSIVE);
331  if (TransactionIdPrecedes(ShmemVariableCache->oldestClogXid,
332  oldest_datfrozenxid))
333  {
334  ShmemVariableCache->oldestClogXid = oldest_datfrozenxid;
335  }
336  LWLockRelease(XactTruncationLock);
337 }
338 
339 /*
340  * Determine the last safe XID to allocate using the currently oldest
341  * datfrozenxid (ie, the oldest XID that might exist in any database
342  * of our cluster), and the OID of the (or a) database with that value.
343  */
344 void
345 SetTransactionIdLimit(TransactionId oldest_datfrozenxid, Oid oldest_datoid)
346 {
347  TransactionId xidVacLimit;
348  TransactionId xidWarnLimit;
349  TransactionId xidStopLimit;
350  TransactionId xidWrapLimit;
351  TransactionId curXid;
352 
353  Assert(TransactionIdIsNormal(oldest_datfrozenxid));
354 
355  /*
356  * The place where we actually get into deep trouble is halfway around
357  * from the oldest potentially-existing XID. (This calculation is
358  * probably off by one or two counts, because the special XIDs reduce the
359  * size of the loop a little bit. But we throw in plenty of slop below,
360  * so it doesn't matter.)
361  */
362  xidWrapLimit = oldest_datfrozenxid + (MaxTransactionId >> 1);
363  if (xidWrapLimit < FirstNormalTransactionId)
364  xidWrapLimit += FirstNormalTransactionId;
365 
366  /*
367  * We'll refuse to continue assigning XIDs in interactive mode once we get
368  * within 3M transactions of data loss. This leaves lots of room for the
369  * DBA to fool around fixing things in a standalone backend, while not
370  * being significant compared to total XID space. (VACUUM requires an XID
371  * if it truncates at wal_level!=minimal. "VACUUM (ANALYZE)", which a DBA
372  * might do by reflex, assigns an XID. Hence, we had better be sure
373  * there's lots of XIDs left...) Also, at default BLCKSZ, this leaves two
374  * completely-idle segments. In the event of edge-case bugs involving
375  * page or segment arithmetic, idle segments render the bugs unreachable
376  * outside of single-user mode.
377  */
378  xidStopLimit = xidWrapLimit - 3000000;
379  if (xidStopLimit < FirstNormalTransactionId)
380  xidStopLimit -= FirstNormalTransactionId;
381 
382  /*
383  * We'll start complaining loudly when we get within 40M transactions of
384  * data loss. This is kind of arbitrary, but if you let your gas gauge
385  * get down to 2% of full, would you be looking for the next gas station?
386  * We need to be fairly liberal about this number because there are lots
387  * of scenarios where most transactions are done by automatic clients that
388  * won't pay attention to warnings. (No, we're not gonna make this
389  * configurable. If you know enough to configure it, you know enough to
390  * not get in this kind of trouble in the first place.)
391  */
392  xidWarnLimit = xidWrapLimit - 40000000;
393  if (xidWarnLimit < FirstNormalTransactionId)
394  xidWarnLimit -= FirstNormalTransactionId;
395 
396  /*
397  * We'll start trying to force autovacuums when oldest_datfrozenxid gets
398  * to be more than autovacuum_freeze_max_age transactions old.
399  *
400  * Note: guc.c ensures that autovacuum_freeze_max_age is in a sane range,
401  * so that xidVacLimit will be well before xidWarnLimit.
402  *
403  * Note: autovacuum_freeze_max_age is a PGC_POSTMASTER parameter so that
404  * we don't have to worry about dealing with on-the-fly changes in its
405  * value. It doesn't look practical to update shared state from a GUC
406  * assign hook (too many processes would try to execute the hook,
407  * resulting in race conditions as well as crashes of those not connected
408  * to shared memory). Perhaps this can be improved someday. See also
409  * SetMultiXactIdLimit.
410  */
411  xidVacLimit = oldest_datfrozenxid + autovacuum_freeze_max_age;
412  if (xidVacLimit < FirstNormalTransactionId)
413  xidVacLimit += FirstNormalTransactionId;
414 
415  /* Grab lock for just long enough to set the new limit values */
416  LWLockAcquire(XidGenLock, LW_EXCLUSIVE);
417  ShmemVariableCache->oldestXid = oldest_datfrozenxid;
418  ShmemVariableCache->xidVacLimit = xidVacLimit;
419  ShmemVariableCache->xidWarnLimit = xidWarnLimit;
420  ShmemVariableCache->xidStopLimit = xidStopLimit;
421  ShmemVariableCache->xidWrapLimit = xidWrapLimit;
422  ShmemVariableCache->oldestXidDB = oldest_datoid;
423  curXid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
424  LWLockRelease(XidGenLock);
425 
426  /* Log the info */
427  ereport(DEBUG1,
428  (errmsg("transaction ID wrap limit is %u, limited by database with OID %u",
429  xidWrapLimit, oldest_datoid)));
430 
431  /*
432  * If past the autovacuum force point, immediately signal an autovac
433  * request. The reason for this is that autovac only processes one
434  * database per invocation. Once it's finished cleaning up the oldest
435  * database, it'll call here, and we'll signal the postmaster to start
436  * another iteration immediately if there are still any old databases.
437  */
438  if (TransactionIdFollowsOrEquals(curXid, xidVacLimit) &&
441 
442  /* Give an immediate warning if past the wrap warn point */
443  if (TransactionIdFollowsOrEquals(curXid, xidWarnLimit) && !InRecovery)
444  {
445  char *oldest_datname;
446 
447  /*
448  * We can be called when not inside a transaction, for example during
449  * StartupXLOG(). In such a case we cannot do database access, so we
450  * must just report the oldest DB's OID.
451  *
452  * Note: it's also possible that get_database_name fails and returns
453  * NULL, for example because the database just got dropped. We'll
454  * still warn, even though the warning might now be unnecessary.
455  */
456  if (IsTransactionState())
457  oldest_datname = get_database_name(oldest_datoid);
458  else
459  oldest_datname = NULL;
460 
461  if (oldest_datname)
463  (errmsg("database \"%s\" must be vacuumed within %u transactions",
464  oldest_datname,
465  xidWrapLimit - curXid),
466  errhint("To avoid a database shutdown, execute a database-wide VACUUM in that database.\n"
467  "You might also need to commit or roll back old prepared transactions, or drop stale replication slots.")));
468  else
470  (errmsg("database with OID %u must be vacuumed within %u transactions",
471  oldest_datoid,
472  xidWrapLimit - curXid),
473  errhint("To avoid a database shutdown, execute a database-wide VACUUM in that database.\n"
474  "You might also need to commit or roll back old prepared transactions, or drop stale replication slots.")));
475  }
476 }
477 
478 
479 /*
480  * ForceTransactionIdLimitUpdate -- does the XID wrap-limit data need updating?
481  *
482  * We primarily check whether oldestXidDB is valid. The cases we have in
483  * mind are that that database was dropped, or the field was reset to zero
484  * by pg_resetwal. In either case we should force recalculation of the
485  * wrap limit. Also do it if oldestXid is old enough to be forcing
486  * autovacuums or other actions; this ensures we update our state as soon
487  * as possible once extra overhead is being incurred.
488  */
489 bool
491 {
492  TransactionId nextXid;
493  TransactionId xidVacLimit;
494  TransactionId oldestXid;
495  Oid oldestXidDB;
496 
497  /* Locking is probably not really necessary, but let's be careful */
498  LWLockAcquire(XidGenLock, LW_SHARED);
499  nextXid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
500  xidVacLimit = ShmemVariableCache->xidVacLimit;
501  oldestXid = ShmemVariableCache->oldestXid;
502  oldestXidDB = ShmemVariableCache->oldestXidDB;
503  LWLockRelease(XidGenLock);
504 
505  if (!TransactionIdIsNormal(oldestXid))
506  return true; /* shouldn't happen, but just in case */
507  if (!TransactionIdIsValid(xidVacLimit))
508  return true; /* this shouldn't happen anymore either */
509  if (TransactionIdFollowsOrEquals(nextXid, xidVacLimit))
510  return true; /* past xidVacLimit, don't delay updating */
512  return true; /* could happen, per comments above */
513  return false;
514 }
515 
516 
517 /*
518  * GetNewObjectId -- allocate a new OID
519  *
520  * OIDs are generated by a cluster-wide counter. Since they are only 32 bits
521  * wide, counter wraparound will occur eventually, and therefore it is unwise
522  * to assume they are unique unless precautions are taken to make them so.
523  * Hence, this routine should generally not be used directly. The only direct
524  * callers should be GetNewOidWithIndex() and GetNewRelFileNode() in
525  * catalog/catalog.c.
526  */
527 Oid
529 {
530  Oid result;
531 
532  /* safety check, we should never get this far in a HS standby */
533  if (RecoveryInProgress())
534  elog(ERROR, "cannot assign OIDs during recovery");
535 
536  LWLockAcquire(OidGenLock, LW_EXCLUSIVE);
537 
538  /*
539  * Check for wraparound of the OID counter. We *must* not return 0
540  * (InvalidOid), and in normal operation we mustn't return anything below
541  * FirstNormalObjectId since that range is reserved for initdb (see
542  * IsCatalogRelationOid()). Note we are relying on unsigned comparison.
543  *
544  * During initdb, we start the OID generator at FirstBootstrapObjectId, so
545  * we only wrap if before that point when in bootstrap or standalone mode.
546  * The first time through this routine after normal postmaster start, the
547  * counter will be forced up to FirstNormalObjectId. This mechanism
548  * leaves the OIDs between FirstBootstrapObjectId and FirstNormalObjectId
549  * available for automatic assignment during initdb, while ensuring they
550  * will never conflict with user-assigned OIDs.
551  */
552  if (ShmemVariableCache->nextOid < ((Oid) FirstNormalObjectId))
553  {
555  {
556  /* wraparound, or first post-initdb assignment, in normal mode */
557  ShmemVariableCache->nextOid = FirstNormalObjectId;
558  ShmemVariableCache->oidCount = 0;
559  }
560  else
561  {
562  /* we may be bootstrapping, so don't enforce the full range */
563  if (ShmemVariableCache->nextOid < ((Oid) FirstBootstrapObjectId))
564  {
565  /* wraparound in standalone mode (unlikely but possible) */
566  ShmemVariableCache->nextOid = FirstNormalObjectId;
567  ShmemVariableCache->oidCount = 0;
568  }
569  }
570  }
571 
572  /* If we run out of logged for use oids then we must log more */
573  if (ShmemVariableCache->oidCount == 0)
574  {
575  XLogPutNextOid(ShmemVariableCache->nextOid + VAR_OID_PREFETCH);
576  ShmemVariableCache->oidCount = VAR_OID_PREFETCH;
577  }
578 
579  result = ShmemVariableCache->nextOid;
580 
581  (ShmemVariableCache->nextOid)++;
582  (ShmemVariableCache->oidCount)--;
583 
584  LWLockRelease(OidGenLock);
585 
586  return result;
587 }
588 
589 
590 #ifdef USE_ASSERT_CHECKING
591 
592 /*
593  * Assert that xid is between [oldestXid, nextXid], which is the range we
594  * expect XIDs coming from tables etc to be in.
595  *
596  * As ShmemVariableCache->oldestXid could change just after this call without
597  * further precautions, and as a wrapped-around xid could again fall within
598  * the valid range, this assertion can only detect if something is definitely
599  * wrong, but not establish correctness.
600  *
601  * This intentionally does not expose a return value, to avoid code being
602  * introduced that depends on the return value.
603  */
604 void
606 {
607  TransactionId oldest_xid;
608  TransactionId next_xid;
609 
611 
612  /* we may see bootstrap / frozen */
613  if (!TransactionIdIsNormal(xid))
614  return;
615 
616  /*
617  * We can't acquire XidGenLock, as this may be called with XidGenLock
618  * already held (or with other locks that don't allow XidGenLock to be
619  * nested). That's ok for our purposes though, since we already rely on
620  * 32bit reads to be atomic. While nextXid is 64 bit, we only look at
621  * the lower 32bit, so a skewed read doesn't hurt.
622  *
623  * There's no increased danger of falling outside [oldest, next] by
624  * accessing them without a lock. xid needs to have been created with
625  * GetNewTransactionId() in the originating session, and the locks there
626  * pair with the memory barrier below. We do however accept xid to be <=
627  * to next_xid, instead of just <, as xid could be from the procarray,
628  * before we see the updated nextXid value.
629  */
631  oldest_xid = ShmemVariableCache->oldestXid;
632  next_xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
633 
634  Assert(TransactionIdFollowsOrEquals(xid, oldest_xid) ||
635  TransactionIdPrecedesOrEquals(xid, next_xid));
636 }
637 #endif
#define TransactionIdAdvance(dest)
Definition: transam.h:91
#define AmStartupProcess()
Definition: miscadmin.h:431
bool IsPostmasterEnvironment
Definition: globals.c:108
#define DEBUG1
Definition: elog.h:25
int errhint(const char *fmt,...)
Definition: elog.c:1071
uint32 TransactionId
Definition: c.h:520
void AdvanceNextFullTransactionIdPastXid(TransactionId xid)
Definition: varsup.c:277
uint32 oidCount
Definition: transam.h:208
XidCacheStatus * subxidStates
Definition: proc.h:315
PGPROC * MyProc
Definition: proc.c:67
#define VAR_OID_PREFETCH
Definition: varsup.c:31
void ExtendCLOG(TransactionId newestXact)
Definition: clog.c:859
bool InRecovery
Definition: xlog.c:205
bool TransactionIdFollowsOrEquals(TransactionId id1, TransactionId id2)
Definition: transam.c:349
TransactionId oldestXid
Definition: transam.h:215
int errcode(int sqlerrcode)
Definition: elog.c:610
PROC_HDR * ProcGlobal
Definition: proc.c:79
unsigned int Oid
Definition: postgres_ext.h:31
bool RecoveryInProgress(void)
Definition: xlog.c:8074
FullTransactionId nextXid
Definition: transam.h:213
XidCacheStatus subxidStatus
Definition: proc.h:198
TransactionId xidVacLimit
Definition: transam.h:216
#define FirstNormalObjectId
Definition: transam.h:190
bool overflowed
Definition: proc.h:43
#define XidFromFullTransactionId(x)
Definition: transam.h:48
void LWLockRelease(LWLock *lock)
Definition: lwlock.c:1812
bool ForceTransactionIdLimitUpdate(void)
Definition: varsup.c:490
Oid GetNewObjectId(void)
Definition: varsup.c:528
#define SearchSysCacheExists1(cacheId, key1)
Definition: syscache.h:183
void AdvanceOldestClogXid(TransactionId oldest_datfrozenxid)
Definition: varsup.c:328
#define AssertTransactionIdInAllowableRange(xid)
Definition: transam.h:294
bool IsInParallelMode(void)
Definition: xact.c:1012
bool TransactionIdPrecedesOrEquals(TransactionId id1, TransactionId id2)
Definition: transam.c:319
#define FirstNormalTransactionId
Definition: transam.h:34
#define ObjectIdGetDatum(X)
Definition: postgres.h:507
#define ERROR
Definition: elog.h:43
int autovacuum_freeze_max_age
Definition: autovacuum.c:124
void ExtendSUBTRANS(TransactionId newestXact)
Definition: subtrans.c:326
void XLogPutNextOid(Oid nextOid)
Definition: xlog.c:9646
char * get_database_name(Oid dbid)
Definition: dbcommands.c:2155
#define BootstrapTransactionId
Definition: transam.h:32
TransactionId xidStopLimit
Definition: transam.h:218
bool IsUnderPostmaster
Definition: globals.c:109
TransactionId oldestClogXid
Definition: transam.h:246
VariableCache ShmemVariableCache
Definition: varsup.c:34
TransactionId * xids
Definition: proc.h:309
unsigned int uint32
Definition: c.h:374
#define FirstBootstrapObjectId
Definition: transam.h:189
struct XidCache subxids
Definition: proc.h:200
bool TransactionIdPrecedes(TransactionId id1, TransactionId id2)
Definition: transam.c:300
FullTransactionId ReadNextFullTransactionId(void)
Definition: varsup.c:261
#define WARNING
Definition: elog.h:40
#define MaxTransactionId
Definition: transam.h:35
#define EpochFromFullTransactionId(x)
Definition: transam.h:47
#define PGPROC_MAX_CACHED_SUBXIDS
Definition: proc.h:36
#define ereport(elevel,...)
Definition: elog.h:144
#define pg_memory_barrier()
Definition: atomics.h:145
TransactionId xids[PGPROC_MAX_CACHED_SUBXIDS]
Definition: proc.h:48
#define Assert(condition)
Definition: c.h:745
void ExtendCommitTs(TransactionId newestXact)
Definition: commit_ts.c:845
void SetTransactionIdLimit(TransactionId oldest_datfrozenxid, Oid oldest_datoid)
Definition: varsup.c:345
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition: lwlock.c:1208
static FullTransactionId FullTransactionIdFromEpochAndXid(uint32 epoch, TransactionId xid)
Definition: transam.h:71
bool IsTransactionState(void)
Definition: xact.c:371
uint8 count
Definition: proc.h:41
TransactionId xid
Definition: proc.h:124
#define IsBootstrapProcessingMode()
Definition: miscadmin.h:393
TransactionId xidWarnLimit
Definition: transam.h:217
int errmsg(const char *fmt,...)
Definition: elog.c:824
#define elog(elevel,...)
Definition: elog.h:214
static const unsigned __int64 epoch
Definition: gettimeofday.c:34
int pgxactoff
Definition: proc.h:139
TransactionId xidWrapLimit
Definition: transam.h:219
#define pg_write_barrier()
Definition: atomics.h:159
FullTransactionId GetNewTransactionId(bool isSubXact)
Definition: varsup.c:50
#define unlikely(x)
Definition: c.h:206
void SendPostmasterSignal(PMSignalReason reason)
Definition: pmsignal.c:146
#define TransactionIdIsValid(xid)
Definition: transam.h:41
#define TransactionIdIsNormal(xid)
Definition: transam.h:42
static void FullTransactionIdAdvance(FullTransactionId *dest)
Definition: transam.h:128