PostgreSQL Source Code git master
Loading...
Searching...
No Matches
varsup.c File Reference
#include "postgres.h"
#include "access/clog.h"
#include "access/commit_ts.h"
#include "access/subtrans.h"
#include "access/transam.h"
#include "access/xact.h"
#include "access/xlogutils.h"
#include "miscadmin.h"
#include "postmaster/autovacuum.h"
#include "storage/pmsignal.h"
#include "storage/proc.h"
#include "utils/lsyscache.h"
#include "utils/syscache.h"
Include dependency graph for varsup.c:

Go to the source code of this file.

Macros

#define VAR_OID_PREFETCH   8192
 

Functions

Size VarsupShmemSize (void)
 
void VarsupShmemInit (void)
 
FullTransactionId GetNewTransactionId (bool isSubXact)
 
FullTransactionId ReadNextFullTransactionId (void)
 
void AdvanceNextFullTransactionIdPastXid (TransactionId xid)
 
void AdvanceOldestClogXid (TransactionId oldest_datfrozenxid)
 
void SetTransactionIdLimit (TransactionId oldest_datfrozenxid, Oid oldest_datoid)
 
bool ForceTransactionIdLimitUpdate (void)
 
Oid GetNewObjectId (void)
 
static void SetNextObjectId (Oid nextOid)
 
void StopGeneratingPinnedObjectIds (void)
 

Variables

TransamVariablesDataTransamVariables = NULL
 

Macro Definition Documentation

◆ VAR_OID_PREFETCH

#define VAR_OID_PREFETCH   8192

Definition at line 31 of file varsup.c.

Function Documentation

◆ AdvanceNextFullTransactionIdPastXid()

void AdvanceNextFullTransactionIdPastXid ( TransactionId  xid)

Definition at line 308 of file varsup.c.

309{
311 TransactionId next_xid;
313
314 /*
315 * It is safe to read nextXid without a lock, because this is only called
316 * from the startup process or single-process mode, meaning that no other
317 * process can modify it.
318 */
320
321 /* Fast return if this isn't an xid high enough to move the needle. */
323 if (!TransactionIdFollowsOrEquals(xid, next_xid))
324 return;
325
326 /*
327 * Compute the FullTransactionId that comes after the given xid. To do
328 * this, we preserve the existing epoch, but detect when we've wrapped
329 * into a new epoch. This is necessary because WAL records and 2PC state
330 * currently contain 32 bit xids. The wrap logic is safe in those cases
331 * because the span of active xids cannot exceed one epoch at any given
332 * point in the WAL stream.
333 */
336 if (unlikely(xid < next_xid))
337 ++epoch;
339
340 /*
341 * We still need to take a lock to modify the value when there are
342 * concurrent readers.
343 */
347}
#define Assert(condition)
Definition c.h:945
#define unlikely(x)
Definition c.h:432
uint32_t uint32
Definition c.h:618
uint32 TransactionId
Definition c.h:738
bool IsUnderPostmaster
Definition globals.c:120
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
Definition lwlock.c:1177
void LWLockRelease(LWLock *lock)
Definition lwlock.c:1794
@ LW_EXCLUSIVE
Definition lwlock.h:112
#define AmStartupProcess()
Definition miscadmin.h:390
static int fb(int x)
FullTransactionId nextXid
Definition transam.h:220
#define EpochFromFullTransactionId(x)
Definition transam.h:47
static bool TransactionIdFollowsOrEquals(TransactionId id1, TransactionId id2)
Definition transam.h:312
#define XidFromFullTransactionId(x)
Definition transam.h:48
static FullTransactionId FullTransactionIdFromEpochAndXid(uint32 epoch, TransactionId xid)
Definition transam.h:71
#define TransactionIdAdvance(dest)
Definition transam.h:91
TransamVariablesData * TransamVariables
Definition varsup.c:34
static const unsigned __int64 epoch

References AmStartupProcess, Assert, epoch, EpochFromFullTransactionId, fb(), FullTransactionIdFromEpochAndXid(), IsUnderPostmaster, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), TransamVariablesData::nextXid, TransactionIdAdvance, TransactionIdFollowsOrEquals(), TransamVariables, unlikely, and XidFromFullTransactionId.

Referenced by ApplyWalRecord(), multixact_redo(), ProcArrayApplyRecoveryInfo(), ProcessTwoPhaseBuffer(), RecordKnownAssignedTransactionIds(), xact_redo_abort(), and xact_redo_commit().

◆ AdvanceOldestClogXid()

void AdvanceOldestClogXid ( TransactionId  oldest_datfrozenxid)

◆ ForceTransactionIdLimitUpdate()

bool ForceTransactionIdLimitUpdate ( void  )

Definition at line 525 of file varsup.c.

526{
527 TransactionId nextXid;
528 TransactionId xidVacLimit;
529 TransactionId oldestXid;
530 Oid oldestXidDB;
531
532 /* Locking is probably not really necessary, but let's be careful */
535 xidVacLimit = TransamVariables->xidVacLimit;
536 oldestXid = TransamVariables->oldestXid;
537 oldestXidDB = TransamVariables->oldestXidDB;
539
540 if (!TransactionIdIsNormal(oldestXid))
541 return true; /* shouldn't happen, but just in case */
542 if (!TransactionIdIsValid(xidVacLimit))
543 return true; /* this shouldn't happen anymore either */
544 if (TransactionIdFollowsOrEquals(nextXid, xidVacLimit))
545 return true; /* past xidVacLimit, don't delay updating */
547 return true; /* could happen, per comments above */
548 return false;
549}
@ LW_SHARED
Definition lwlock.h:113
static Datum ObjectIdGetDatum(Oid X)
Definition postgres.h:252
unsigned int Oid
TransactionId xidVacLimit
Definition transam.h:223
TransactionId oldestXid
Definition transam.h:222
#define SearchSysCacheExists1(cacheId, key1)
Definition syscache.h:100
#define TransactionIdIsValid(xid)
Definition transam.h:41
#define TransactionIdIsNormal(xid)
Definition transam.h:42

References fb(), LW_SHARED, LWLockAcquire(), LWLockRelease(), TransamVariablesData::nextXid, ObjectIdGetDatum(), TransamVariablesData::oldestXid, TransamVariablesData::oldestXidDB, SearchSysCacheExists1, TransactionIdFollowsOrEquals(), TransactionIdIsNormal, TransactionIdIsValid, TransamVariables, XidFromFullTransactionId, and TransamVariablesData::xidVacLimit.

Referenced by vac_update_datfrozenxid().

◆ GetNewObjectId()

Oid GetNewObjectId ( void  )

Definition at line 563 of file varsup.c.

564{
565 Oid result;
566
567 /* safety check, we should never get this far in a HS standby */
568 if (RecoveryInProgress())
569 elog(ERROR, "cannot assign OIDs during recovery");
570
572
573 /*
574 * Check for wraparound of the OID counter. We *must* not return 0
575 * (InvalidOid), and in normal operation we mustn't return anything below
576 * FirstNormalObjectId since that range is reserved for initdb (see
577 * IsCatalogRelationOid()). Note we are relying on unsigned comparison.
578 *
579 * During initdb, we start the OID generator at FirstGenbkiObjectId, so we
580 * only wrap if before that point when in bootstrap or standalone mode.
581 * The first time through this routine after normal postmaster start, the
582 * counter will be forced up to FirstNormalObjectId. This mechanism
583 * leaves the OIDs between FirstGenbkiObjectId and FirstNormalObjectId
584 * available for automatic assignment during initdb, while ensuring they
585 * will never conflict with user-assigned OIDs.
586 */
588 {
590 {
591 /* wraparound, or first post-initdb assignment, in normal mode */
594 }
595 else
596 {
597 /* we may be bootstrapping, so don't enforce the full range */
599 {
600 /* wraparound in standalone mode (unlikely but possible) */
603 }
604 }
605 }
606
607 /* If we run out of logged for use oids then we must log more */
608 if (TransamVariables->oidCount == 0)
609 {
612 }
613
614 result = TransamVariables->nextOid;
615
618
620
621 return result;
622}
#define ERROR
Definition elog.h:39
#define elog(elevel,...)
Definition elog.h:226
bool IsPostmasterEnvironment
Definition globals.c:119
#define FirstGenbkiObjectId
Definition transam.h:195
#define FirstNormalObjectId
Definition transam.h:197
#define VAR_OID_PREFETCH
Definition varsup.c:31
bool RecoveryInProgress(void)
Definition xlog.c:6444
void XLogPutNextOid(Oid nextOid)
Definition xlog.c:8152

References elog, ERROR, fb(), FirstGenbkiObjectId, FirstNormalObjectId, IsPostmasterEnvironment, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), TransamVariablesData::nextOid, TransamVariablesData::oidCount, RecoveryInProgress(), TransamVariables, VAR_OID_PREFETCH, and XLogPutNextOid().

Referenced by GetNewOidWithIndex(), and GetNewRelFileNumber().

◆ GetNewTransactionId()

FullTransactionId GetNewTransactionId ( bool  isSubXact)

Definition at line 77 of file varsup.c.

78{
80 TransactionId xid;
81
82 /*
83 * Workers synchronize transaction state at the beginning of each parallel
84 * operation, so we can't account for new XIDs after that point.
85 */
86 if (IsInParallelMode())
87 elog(ERROR, "cannot assign TransactionIds during a parallel operation");
88
89 /*
90 * During bootstrap initialization, we return the special bootstrap
91 * transaction id.
92 */
94 {
99 }
100
101 /* safety check, we should never get this far in a HS standby */
102 if (RecoveryInProgress())
103 elog(ERROR, "cannot assign TransactionIds during recovery");
104
106
109
110 /*----------
111 * Check to see if it's safe to assign another XID. This protects against
112 * catastrophic data loss due to XID wraparound. The basic rules are:
113 *
114 * If we're past xidVacLimit, start trying to force autovacuum cycles.
115 * If we're past xidWarnLimit, start issuing warnings.
116 * If we're past xidStopLimit, refuse to execute transactions, unless
117 * we are running in single-user mode (which gives an escape hatch
118 * to the DBA who somehow got past the earlier defenses).
119 *
120 * Note that this coding also appears in GetNewMultiXactId.
121 *----------
122 */
124 {
125 /*
126 * For safety's sake, we release XidGenLock while sending signals,
127 * warnings, etc. This is not so much because we care about
128 * preserving concurrency in this situation, as to avoid any
129 * possibility of deadlock while doing get_database_name(). First,
130 * copy all the shared values we'll need in this path.
131 */
136
138
139 /*
140 * To avoid swamping the postmaster with signals, we issue the autovac
141 * request only once per 64K transaction starts. This still gives
142 * plenty of chances before we get into real trouble.
143 */
144 if (IsUnderPostmaster && (xid % 65536) == 0)
146
147 if (IsUnderPostmaster &&
148 TransactionIdFollowsOrEquals(xid, xidStopLimit))
149 {
151
152 /* complain even if that DB has disappeared */
153 if (oldest_datname)
156 errmsg("database is not accepting commands that assign new transaction IDs to avoid wraparound data loss in database \"%s\"",
158 errhint("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 else
163 errmsg("database is not accepting commands that assign new transaction IDs to avoid wraparound data loss in database with OID %u",
165 errhint("Execute a database-wide VACUUM in that database.\n"
166 "You might also need to commit or roll back old prepared transactions, or drop stale replication slots.")));
167 }
168 else if (TransactionIdFollowsOrEquals(xid, xidWarnLimit))
169 {
171
172 /* complain even if that DB has disappeared */
173 if (oldest_datname)
175 (errmsg("database \"%s\" must be vacuumed within %u transactions",
177 xidWrapLimit - xid),
178 errdetail("Approximately %.2f%% of transaction IDs are available for use.",
179 (double) (xidWrapLimit - xid) / (MaxTransactionId / 2) * 100),
180 errhint("To avoid transaction ID assignment failures, execute a database-wide VACUUM in that database.\n"
181 "You might also need to commit or roll back old prepared transactions, or drop stale replication slots.")));
182 else
184 (errmsg("database with OID %u must be vacuumed within %u transactions",
186 xidWrapLimit - xid),
187 errdetail("Approximately %.2f%% of transaction IDs are available for use.",
188 (double) (xidWrapLimit - xid) / (MaxTransactionId / 2) * 100),
189 errhint("To avoid XID assignment failures, execute a database-wide VACUUM in that database.\n"
190 "You might also need to commit or roll back old prepared transactions, or drop stale replication slots.")));
191 }
192
193 /* Re-acquire lock and start over */
197 }
198
199 /*
200 * If we are allocating the first XID of a new page of the commit log,
201 * zero out that commit-log page before returning. We must do this while
202 * holding XidGenLock, else another xact could acquire and commit a later
203 * XID before we zero the page. Fortunately, a page of the commit log
204 * holds 32K or more transactions, so we don't have to do this very often.
205 *
206 * Extend pg_subtrans and pg_commit_ts too.
207 */
208 ExtendCLOG(xid);
209 ExtendCommitTs(xid);
210 ExtendSUBTRANS(xid);
211
212 /*
213 * Now advance the nextXid counter. This must not happen until after we
214 * have successfully completed ExtendCLOG() --- if that routine fails, we
215 * want the next incoming transaction to try it again. We cannot assign
216 * more XIDs until there is CLOG space for them.
217 */
219
220 /*
221 * We must store the new XID into the shared ProcArray before releasing
222 * XidGenLock. This ensures that every active XID older than
223 * latestCompletedXid is present in the ProcArray, which is essential for
224 * correct OldestXmin tracking; see src/backend/access/transam/README.
225 *
226 * Note that readers of ProcGlobal->xids/PGPROC->xid should be careful to
227 * fetch the value for each proc only once, rather than assume they can
228 * read a value multiple times and get the same answer each time. Note we
229 * are assuming that TransactionId and int fetch/store are atomic.
230 *
231 * The same comments apply to the subxact xid count and overflow fields.
232 *
233 * Use of a write barrier prevents dangerous code rearrangement in this
234 * function; other backends could otherwise e.g. be examining my subxids
235 * info concurrently, and we don't want them to see an invalid
236 * intermediate state, such as an incremented nxids before the array entry
237 * is filled.
238 *
239 * Other processes that read nxids should do so before reading xids
240 * elements with a pg_read_barrier() in between, so that they can be sure
241 * not to read an uninitialized array element; see
242 * src/backend/storage/lmgr/README.barrier.
243 *
244 * If there's no room to fit a subtransaction XID into PGPROC, set the
245 * cache-overflowed flag instead. This forces readers to look in
246 * pg_subtrans to map subtransaction XIDs up to top-level XIDs. There is a
247 * race-condition window, in that the new XID will not appear as running
248 * until its parent link has been placed into pg_subtrans. However, that
249 * will happen before anyone could possibly have a reason to inquire about
250 * the status of the XID, so it seems OK. (Snapshots taken during this
251 * window *will* include the parent XID, so they will deliver the correct
252 * answer later on when someone does have a reason to inquire.)
253 */
254 if (!isSubXact)
255 {
260
261 /* LWLockRelease acts as barrier */
262 MyProc->xid = xid;
264 }
265 else
266 {
269
272
274 {
275 MyProc->subxids.xids[nxids] = xid;
277 MyProc->subxidStatus.count = substat->count = nxids + 1;
278 }
279 else
280 MyProc->subxidStatus.overflowed = substat->overflowed = true;
281 }
282
284
285 return full_xid;
286}
#define pg_write_barrier()
Definition atomics.h:155
void ExtendCLOG(TransactionId newestXact)
Definition clog.c:927
void ExtendCommitTs(TransactionId newestXact)
Definition commit_ts.c:818
int errcode(int sqlerrcode)
Definition elog.c:874
int errhint(const char *fmt,...) pg_attribute_printf(1
int errdetail(const char *fmt,...) pg_attribute_printf(1
#define WARNING
Definition elog.h:36
#define ereport(elevel,...)
Definition elog.h:150
char * get_database_name(Oid dbid)
Definition lsyscache.c:1312
#define IsBootstrapProcessingMode()
Definition miscadmin.h:477
static char * errmsg
void SendPostmasterSignal(PMSignalReason reason)
Definition pmsignal.c:165
@ PMSIGNAL_START_AUTOVAC_LAUNCHER
Definition pmsignal.h:39
#define PGPROC_MAX_CACHED_SUBXIDS
Definition proc.h:40
PGPROC * MyProc
Definition proc.c:68
PROC_HDR * ProcGlobal
Definition proc.c:71
int pgxactoff
Definition proc.h:204
XidCacheStatus subxidStatus
Definition proc.h:244
TransactionId xid
Definition proc.h:234
struct XidCache subxids
Definition proc.h:246
XidCacheStatus * subxidStates
Definition proc.h:447
TransactionId * xids
Definition proc.h:441
TransactionId xidStopLimit
Definition transam.h:225
TransactionId xidWarnLimit
Definition transam.h:224
TransactionId xidWrapLimit
Definition transam.h:226
bool overflowed
Definition proc.h:47
uint8 count
Definition proc.h:45
TransactionId xids[PGPROC_MAX_CACHED_SUBXIDS]
Definition proc.h:52
void ExtendSUBTRANS(TransactionId newestXact)
Definition subtrans.c:355
#define BootstrapTransactionId
Definition transam.h:32
static void FullTransactionIdAdvance(FullTransactionId *dest)
Definition transam.h:128
#define MaxTransactionId
Definition transam.h:35
bool IsInParallelMode(void)
Definition xact.c:1091

References Assert, BootstrapTransactionId, XidCacheStatus::count, elog, ereport, errcode(), errdetail(), errhint(), errmsg, ERROR, ExtendCLOG(), ExtendCommitTs(), ExtendSUBTRANS(), fb(), FullTransactionIdAdvance(), FullTransactionIdFromEpochAndXid(), get_database_name(), IsBootstrapProcessingMode, IsInParallelMode(), IsUnderPostmaster, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), MaxTransactionId, MyProc, TransamVariablesData::nextXid, TransamVariablesData::oldestXidDB, XidCacheStatus::overflowed, pg_write_barrier, PGPROC_MAX_CACHED_SUBXIDS, PGPROC::pgxactoff, PMSIGNAL_START_AUTOVAC_LAUNCHER, ProcGlobal, RecoveryInProgress(), SendPostmasterSignal(), PGPROC::subxids, PROC_HDR::subxidStates, PGPROC::subxidStatus, TransactionIdFollowsOrEquals(), TransamVariables, WARNING, PGPROC::xid, XidFromFullTransactionId, XidCache::xids, PROC_HDR::xids, TransamVariablesData::xidStopLimit, TransamVariablesData::xidVacLimit, TransamVariablesData::xidWarnLimit, and TransamVariablesData::xidWrapLimit.

Referenced by AssignTransactionId(), and consume_xids_common().

◆ ReadNextFullTransactionId()

◆ SetNextObjectId()

static void SetNextObjectId ( Oid  nextOid)
static

Definition at line 631 of file varsup.c.

632{
633 /* Safety check, this is only allowable during initdb */
635 elog(ERROR, "cannot advance OID counter anymore");
636
637 /* Taking the lock is, therefore, just pro forma; but do it anyway */
639
640 if (TransamVariables->nextOid > nextOid)
641 elog(ERROR, "too late to advance OID counter to %u, it is now %u",
642 nextOid, TransamVariables->nextOid);
643
644 TransamVariables->nextOid = nextOid;
646
648}

References elog, ERROR, fb(), IsPostmasterEnvironment, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), TransamVariablesData::nextOid, TransamVariablesData::oidCount, and TransamVariables.

Referenced by StopGeneratingPinnedObjectIds().

◆ SetTransactionIdLimit()

void SetTransactionIdLimit ( TransactionId  oldest_datfrozenxid,
Oid  oldest_datoid 
)

Definition at line 376 of file varsup.c.

377{
378 TransactionId xidVacLimit;
379 TransactionId xidWarnLimit;
380 TransactionId xidStopLimit;
381 TransactionId xidWrapLimit;
383
385
386 /*
387 * The place where we actually get into deep trouble is halfway around
388 * from the oldest potentially-existing XID. (This calculation is
389 * probably off by one or two counts, because the special XIDs reduce the
390 * size of the loop a little bit. But we throw in plenty of slop below,
391 * so it doesn't matter.)
392 */
393 xidWrapLimit = oldest_datfrozenxid + (MaxTransactionId >> 1);
394 if (xidWrapLimit < FirstNormalTransactionId)
395 xidWrapLimit += FirstNormalTransactionId;
396
397 /*
398 * We'll refuse to continue assigning XIDs in interactive mode once we get
399 * within 3M transactions of data loss. This leaves lots of room for the
400 * DBA to fool around fixing things in a standalone backend, while not
401 * being significant compared to total XID space. (VACUUM requires an XID
402 * if it truncates at wal_level!=minimal. "VACUUM (ANALYZE)", which a DBA
403 * might do by reflex, assigns an XID. Hence, we had better be sure
404 * there's lots of XIDs left...) Also, at default BLCKSZ, this leaves two
405 * completely-idle segments. In the event of edge-case bugs involving
406 * page or segment arithmetic, idle segments render the bugs unreachable
407 * outside of single-user mode.
408 */
409 xidStopLimit = xidWrapLimit - 3000000;
410 if (xidStopLimit < FirstNormalTransactionId)
411 xidStopLimit -= FirstNormalTransactionId;
412
413 /*
414 * We'll start complaining loudly when we get within 100M transactions of
415 * data loss. This is kind of arbitrary, but if you let your gas gauge
416 * get down to 5% of full, would you be looking for the next gas station?
417 * We need to be fairly liberal about this number because there are lots
418 * of scenarios where most transactions are done by automatic clients that
419 * won't pay attention to warnings. (No, we're not gonna make this
420 * configurable. If you know enough to configure it, you know enough to
421 * not get in this kind of trouble in the first place.)
422 */
423 xidWarnLimit = xidWrapLimit - 100000000;
424 if (xidWarnLimit < FirstNormalTransactionId)
425 xidWarnLimit -= FirstNormalTransactionId;
426
427 /*
428 * We'll start trying to force autovacuums when oldest_datfrozenxid gets
429 * to be more than autovacuum_freeze_max_age transactions old.
430 *
431 * Note: guc.c ensures that autovacuum_freeze_max_age is in a sane range,
432 * so that xidVacLimit will be well before xidWarnLimit.
433 *
434 * Note: autovacuum_freeze_max_age is a PGC_POSTMASTER parameter so that
435 * we don't have to worry about dealing with on-the-fly changes in its
436 * value. It doesn't look practical to update shared state from a GUC
437 * assign hook (too many processes would try to execute the hook,
438 * resulting in race conditions as well as crashes of those not connected
439 * to shared memory). Perhaps this can be improved someday. See also
440 * SetMultiXactIdLimit.
441 */
443 if (xidVacLimit < FirstNormalTransactionId)
444 xidVacLimit += FirstNormalTransactionId;
445
446 /* Grab lock for just long enough to set the new limit values */
449 TransamVariables->xidVacLimit = xidVacLimit;
450 TransamVariables->xidWarnLimit = xidWarnLimit;
451 TransamVariables->xidStopLimit = xidStopLimit;
452 TransamVariables->xidWrapLimit = xidWrapLimit;
456
457 /* Log the info */
459 (errmsg_internal("transaction ID wrap limit is %u, limited by database with OID %u",
460 xidWrapLimit, oldest_datoid)));
461
462 /*
463 * If past the autovacuum force point, immediately signal an autovac
464 * request. The reason for this is that autovac only processes one
465 * database per invocation. Once it's finished cleaning up the oldest
466 * database, it'll call here, and we'll signal the postmaster to start
467 * another iteration immediately if there are still any old databases.
468 */
469 if (TransactionIdFollowsOrEquals(curXid, xidVacLimit) &&
472
473 /* Give an immediate warning if past the wrap warn point */
474 if (TransactionIdFollowsOrEquals(curXid, xidWarnLimit) && !InRecovery)
475 {
476 char *oldest_datname;
477
478 /*
479 * We can be called when not inside a transaction, for example during
480 * StartupXLOG(). In such a case we cannot do database access, so we
481 * must just report the oldest DB's OID.
482 *
483 * Note: it's also possible that get_database_name fails and returns
484 * NULL, for example because the database just got dropped. We'll
485 * still warn, even though the warning might now be unnecessary.
486 */
487 if (IsTransactionState())
489 else
491
492 if (oldest_datname)
494 (errmsg("database \"%s\" must be vacuumed within %u transactions",
496 xidWrapLimit - curXid),
497 errdetail("Approximately %.2f%% of transaction IDs are available for use.",
498 (double) (xidWrapLimit - curXid) / (MaxTransactionId / 2) * 100),
499 errhint("To avoid XID assignment failures, execute a database-wide VACUUM in that database.\n"
500 "You might also need to commit or roll back old prepared transactions, or drop stale replication slots.")));
501 else
503 (errmsg("database with OID %u must be vacuumed within %u transactions",
505 xidWrapLimit - curXid),
506 errdetail("Approximately %.2f%% of transaction IDs are available for use.",
507 (double) (xidWrapLimit - curXid) / (MaxTransactionId / 2) * 100),
508 errhint("To avoid XID assignment failures, execute a database-wide VACUUM in that database.\n"
509 "You might also need to commit or roll back old prepared transactions, or drop stale replication slots.")));
510 }
511}
int autovacuum_freeze_max_age
Definition autovacuum.c:131
int int errmsg_internal(const char *fmt,...) pg_attribute_printf(1
#define DEBUG1
Definition elog.h:30
#define FirstNormalTransactionId
Definition transam.h:34
bool IsTransactionState(void)
Definition xact.c:389
bool InRecovery
Definition xlogutils.c:50

References Assert, autovacuum_freeze_max_age, DEBUG1, ereport, errdetail(), errhint(), errmsg, errmsg_internal(), fb(), FirstNormalTransactionId, get_database_name(), InRecovery, IsTransactionState(), IsUnderPostmaster, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), MaxTransactionId, TransamVariablesData::nextXid, TransamVariablesData::oldestXid, TransamVariablesData::oldestXidDB, PMSIGNAL_START_AUTOVAC_LAUNCHER, SendPostmasterSignal(), TransactionIdFollowsOrEquals(), TransactionIdIsNormal, TransamVariables, WARNING, XidFromFullTransactionId, TransamVariablesData::xidStopLimit, TransamVariablesData::xidVacLimit, TransamVariablesData::xidWarnLimit, and TransamVariablesData::xidWrapLimit.

Referenced by BootStrapXLOG(), StartupXLOG(), vac_truncate_clog(), and xlog_redo().

◆ StopGeneratingPinnedObjectIds()

void StopGeneratingPinnedObjectIds ( void  )

Definition at line 660 of file varsup.c.

661{
663}
#define FirstUnpinnedObjectId
Definition transam.h:196
static void SetNextObjectId(Oid nextOid)
Definition varsup.c:631

References FirstUnpinnedObjectId, and SetNextObjectId().

Referenced by pg_stop_making_pinned_objects().

◆ VarsupShmemInit()

void VarsupShmemInit ( void  )

Definition at line 47 of file varsup.c.

48{
49 bool found;
50
51 /* Initialize our shared state struct */
52 TransamVariables = ShmemInitStruct("TransamVariables",
54 &found);
56 {
57 Assert(!found);
59 }
60 else
61 Assert(found);
62}
void * ShmemInitStruct(const char *name, Size size, bool *foundPtr)
Definition shmem.c:381

References Assert, fb(), IsUnderPostmaster, ShmemInitStruct(), and TransamVariables.

Referenced by CreateOrAttachShmemStructs().

◆ VarsupShmemSize()

Size VarsupShmemSize ( void  )

Definition at line 41 of file varsup.c.

42{
43 return sizeof(TransamVariablesData);
44}

Referenced by CalculateShmemSize().

Variable Documentation

◆ TransamVariables