mirror of https://github.com/postgres/postgres
Rename ShmemVariableCache to TransamVariables
The old name was misleading: It's not a cache, the values kept in the struct are the authoritative source. Reviewed-by: Tristan Partin, Richard Guo Discussion: https://www.postgresql.org/message-id/6537d63d-4bb5-46f8-9b5d-73a8ba4720ab@iki.fi
This commit is contained in:
parent
15916ffb04
commit
b31ba5310b
|
@ -81,12 +81,12 @@ typedef struct ToastedAttribute
|
|||
typedef struct HeapCheckContext
|
||||
{
|
||||
/*
|
||||
* Cached copies of values from ShmemVariableCache and computed values
|
||||
* from them.
|
||||
* Cached copies of values from TransamVariables and computed values from
|
||||
* them.
|
||||
*/
|
||||
FullTransactionId next_fxid; /* ShmemVariableCache->nextXid */
|
||||
FullTransactionId next_fxid; /* TransamVariables->nextXid */
|
||||
TransactionId next_xid; /* 32-bit version of next_fxid */
|
||||
TransactionId oldest_xid; /* ShmemVariableCache->oldestXid */
|
||||
TransactionId oldest_xid; /* TransamVariables->oldestXid */
|
||||
FullTransactionId oldest_fxid; /* 64-bit version of oldest_xid, computed
|
||||
* relative to next_fxid */
|
||||
TransactionId safe_xmin; /* this XID and newer ones can't become
|
||||
|
@ -1924,8 +1924,8 @@ update_cached_xid_range(HeapCheckContext *ctx)
|
|||
{
|
||||
/* Make cached copies */
|
||||
LWLockAcquire(XidGenLock, LW_SHARED);
|
||||
ctx->next_fxid = ShmemVariableCache->nextXid;
|
||||
ctx->oldest_xid = ShmemVariableCache->oldestXid;
|
||||
ctx->next_fxid = TransamVariables->nextXid;
|
||||
ctx->oldest_xid = TransamVariables->oldestXid;
|
||||
LWLockRelease(XidGenLock);
|
||||
|
||||
/* And compute alternate versions of the same */
|
||||
|
@ -2062,7 +2062,7 @@ get_xid_status(TransactionId xid, HeapCheckContext *ctx,
|
|||
*status = XID_COMMITTED;
|
||||
LWLockAcquire(XactTruncationLock, LW_SHARED);
|
||||
clog_horizon =
|
||||
FullTransactionIdFromXidAndCtx(ShmemVariableCache->oldestClogXid,
|
||||
FullTransactionIdFromXidAndCtx(TransamVariables->oldestClogXid,
|
||||
ctx);
|
||||
if (FullTransactionIdPrecedesOrEquals(clog_horizon, fxid))
|
||||
{
|
||||
|
|
|
@ -758,12 +758,12 @@ ZeroCLOGPage(int64 pageno, bool writeXlog)
|
|||
|
||||
/*
|
||||
* This must be called ONCE during postmaster or standalone-backend startup,
|
||||
* after StartupXLOG has initialized ShmemVariableCache->nextXid.
|
||||
* after StartupXLOG has initialized TransamVariables->nextXid.
|
||||
*/
|
||||
void
|
||||
StartupCLOG(void)
|
||||
{
|
||||
TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
|
||||
TransactionId xid = XidFromFullTransactionId(TransamVariables->nextXid);
|
||||
int64 pageno = TransactionIdToPage(xid);
|
||||
|
||||
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
|
||||
|
@ -782,7 +782,7 @@ StartupCLOG(void)
|
|||
void
|
||||
TrimCLOG(void)
|
||||
{
|
||||
TransactionId xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
|
||||
TransactionId xid = XidFromFullTransactionId(TransamVariables->nextXid);
|
||||
int64 pageno = TransactionIdToPage(xid);
|
||||
|
||||
LWLockAcquire(XactSLRULock, LW_EXCLUSIVE);
|
||||
|
|
|
@ -211,8 +211,8 @@ TransactionTreeSetCommitTsData(TransactionId xid, int nsubxids,
|
|||
commitTsShared->dataLastCommit.nodeid = nodeid;
|
||||
|
||||
/* and move forwards our endpoint, if needed */
|
||||
if (TransactionIdPrecedes(ShmemVariableCache->newestCommitTsXid, newestXact))
|
||||
ShmemVariableCache->newestCommitTsXid = newestXact;
|
||||
if (TransactionIdPrecedes(TransamVariables->newestCommitTsXid, newestXact))
|
||||
TransamVariables->newestCommitTsXid = newestXact;
|
||||
LWLockRelease(CommitTsLock);
|
||||
}
|
||||
|
||||
|
@ -315,8 +315,8 @@ TransactionIdGetCommitTsData(TransactionId xid, TimestampTz *ts,
|
|||
return *ts != 0;
|
||||
}
|
||||
|
||||
oldestCommitTsXid = ShmemVariableCache->oldestCommitTsXid;
|
||||
newestCommitTsXid = ShmemVariableCache->newestCommitTsXid;
|
||||
oldestCommitTsXid = TransamVariables->oldestCommitTsXid;
|
||||
newestCommitTsXid = TransamVariables->newestCommitTsXid;
|
||||
/* neither is invalid, or both are */
|
||||
Assert(TransactionIdIsValid(oldestCommitTsXid) == TransactionIdIsValid(newestCommitTsXid));
|
||||
LWLockRelease(CommitTsLock);
|
||||
|
@ -593,7 +593,7 @@ ZeroCommitTsPage(int64 pageno, bool writeXlog)
|
|||
|
||||
/*
|
||||
* This must be called ONCE during postmaster or standalone-backend startup,
|
||||
* after StartupXLOG has initialized ShmemVariableCache->nextXid.
|
||||
* after StartupXLOG has initialized TransamVariables->nextXid.
|
||||
*/
|
||||
void
|
||||
StartupCommitTs(void)
|
||||
|
@ -683,7 +683,7 @@ ActivateCommitTs(void)
|
|||
}
|
||||
LWLockRelease(CommitTsLock);
|
||||
|
||||
xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
|
||||
xid = XidFromFullTransactionId(TransamVariables->nextXid);
|
||||
pageno = TransactionIdToCTsPage(xid);
|
||||
|
||||
/*
|
||||
|
@ -707,10 +707,10 @@ ActivateCommitTs(void)
|
|||
* Invalid temporarily.
|
||||
*/
|
||||
LWLockAcquire(CommitTsLock, LW_EXCLUSIVE);
|
||||
if (ShmemVariableCache->oldestCommitTsXid == InvalidTransactionId)
|
||||
if (TransamVariables->oldestCommitTsXid == InvalidTransactionId)
|
||||
{
|
||||
ShmemVariableCache->oldestCommitTsXid =
|
||||
ShmemVariableCache->newestCommitTsXid = ReadNextTransactionId();
|
||||
TransamVariables->oldestCommitTsXid =
|
||||
TransamVariables->newestCommitTsXid = ReadNextTransactionId();
|
||||
}
|
||||
LWLockRelease(CommitTsLock);
|
||||
|
||||
|
@ -759,8 +759,8 @@ DeactivateCommitTs(void)
|
|||
TIMESTAMP_NOBEGIN(commitTsShared->dataLastCommit.time);
|
||||
commitTsShared->dataLastCommit.nodeid = InvalidRepOriginId;
|
||||
|
||||
ShmemVariableCache->oldestCommitTsXid = InvalidTransactionId;
|
||||
ShmemVariableCache->newestCommitTsXid = InvalidTransactionId;
|
||||
TransamVariables->oldestCommitTsXid = InvalidTransactionId;
|
||||
TransamVariables->newestCommitTsXid = InvalidTransactionId;
|
||||
|
||||
LWLockRelease(CommitTsLock);
|
||||
|
||||
|
@ -874,18 +874,18 @@ SetCommitTsLimit(TransactionId oldestXact, TransactionId newestXact)
|
|||
* "future" or signal a disabled committs.
|
||||
*/
|
||||
LWLockAcquire(CommitTsLock, LW_EXCLUSIVE);
|
||||
if (ShmemVariableCache->oldestCommitTsXid != InvalidTransactionId)
|
||||
if (TransamVariables->oldestCommitTsXid != InvalidTransactionId)
|
||||
{
|
||||
if (TransactionIdPrecedes(ShmemVariableCache->oldestCommitTsXid, oldestXact))
|
||||
ShmemVariableCache->oldestCommitTsXid = oldestXact;
|
||||
if (TransactionIdPrecedes(newestXact, ShmemVariableCache->newestCommitTsXid))
|
||||
ShmemVariableCache->newestCommitTsXid = newestXact;
|
||||
if (TransactionIdPrecedes(TransamVariables->oldestCommitTsXid, oldestXact))
|
||||
TransamVariables->oldestCommitTsXid = oldestXact;
|
||||
if (TransactionIdPrecedes(newestXact, TransamVariables->newestCommitTsXid))
|
||||
TransamVariables->newestCommitTsXid = newestXact;
|
||||
}
|
||||
else
|
||||
{
|
||||
Assert(ShmemVariableCache->newestCommitTsXid == InvalidTransactionId);
|
||||
ShmemVariableCache->oldestCommitTsXid = oldestXact;
|
||||
ShmemVariableCache->newestCommitTsXid = newestXact;
|
||||
Assert(TransamVariables->newestCommitTsXid == InvalidTransactionId);
|
||||
TransamVariables->oldestCommitTsXid = oldestXact;
|
||||
TransamVariables->newestCommitTsXid = newestXact;
|
||||
}
|
||||
LWLockRelease(CommitTsLock);
|
||||
}
|
||||
|
@ -897,9 +897,9 @@ void
|
|||
AdvanceOldestCommitTsXid(TransactionId oldestXact)
|
||||
{
|
||||
LWLockAcquire(CommitTsLock, LW_EXCLUSIVE);
|
||||
if (ShmemVariableCache->oldestCommitTsXid != InvalidTransactionId &&
|
||||
TransactionIdPrecedes(ShmemVariableCache->oldestCommitTsXid, oldestXact))
|
||||
ShmemVariableCache->oldestCommitTsXid = oldestXact;
|
||||
if (TransamVariables->oldestCommitTsXid != InvalidTransactionId &&
|
||||
TransactionIdPrecedes(TransamVariables->oldestCommitTsXid, oldestXact))
|
||||
TransamVariables->oldestCommitTsXid = oldestXact;
|
||||
LWLockRelease(CommitTsLock);
|
||||
}
|
||||
|
||||
|
|
|
@ -250,7 +250,7 @@ ZeroSUBTRANSPage(int64 pageno)
|
|||
|
||||
/*
|
||||
* This must be called ONCE during postmaster or standalone-backend startup,
|
||||
* after StartupXLOG has initialized ShmemVariableCache->nextXid.
|
||||
* after StartupXLOG has initialized TransamVariables->nextXid.
|
||||
*
|
||||
* oldestActiveXID is the oldest XID of any prepared transaction, or nextXid
|
||||
* if there are none.
|
||||
|
@ -271,7 +271,7 @@ StartupSUBTRANS(TransactionId oldestActiveXID)
|
|||
LWLockAcquire(SubtransSLRULock, LW_EXCLUSIVE);
|
||||
|
||||
startPage = TransactionIdToPage(oldestActiveXID);
|
||||
nextXid = ShmemVariableCache->nextXid;
|
||||
nextXid = TransamVariables->nextXid;
|
||||
endPage = TransactionIdToPage(XidFromFullTransactionId(nextXid));
|
||||
|
||||
while (startPage != endPage)
|
||||
|
|
|
@ -958,7 +958,7 @@ AdjustToFullTransactionId(TransactionId xid)
|
|||
Assert(TransactionIdIsValid(xid));
|
||||
|
||||
LWLockAcquire(XidGenLock, LW_SHARED);
|
||||
nextFullXid = ShmemVariableCache->nextXid;
|
||||
nextFullXid = TransamVariables->nextXid;
|
||||
LWLockRelease(XidGenLock);
|
||||
|
||||
nextXid = XidFromFullTransactionId(nextFullXid);
|
||||
|
@ -1948,7 +1948,7 @@ restoreTwoPhaseData(void)
|
|||
*
|
||||
* Scan the shared memory entries of TwoPhaseState and determine the range
|
||||
* of valid XIDs present. This is run during database startup, after we
|
||||
* have completed reading WAL. ShmemVariableCache->nextXid has been set to
|
||||
* have completed reading WAL. TransamVariables->nextXid has been set to
|
||||
* one more than the highest XID for which evidence exists in WAL.
|
||||
*
|
||||
* We throw away any prepared xacts with main XID beyond nextXid --- if any
|
||||
|
@ -1967,7 +1967,7 @@ restoreTwoPhaseData(void)
|
|||
* backup should be rolled in.
|
||||
*
|
||||
* Our other responsibility is to determine and return the oldest valid XID
|
||||
* among the prepared xacts (if none, return ShmemVariableCache->nextXid).
|
||||
* among the prepared xacts (if none, return TransamVariables->nextXid).
|
||||
* This is needed to synchronize pg_subtrans startup properly.
|
||||
*
|
||||
* If xids_p and nxids_p are not NULL, pointer to a palloc'd array of all
|
||||
|
@ -1977,7 +1977,7 @@ restoreTwoPhaseData(void)
|
|||
TransactionId
|
||||
PrescanPreparedTransactions(TransactionId **xids_p, int *nxids_p)
|
||||
{
|
||||
FullTransactionId nextXid = ShmemVariableCache->nextXid;
|
||||
FullTransactionId nextXid = TransamVariables->nextXid;
|
||||
TransactionId origNextXid = XidFromFullTransactionId(nextXid);
|
||||
TransactionId result = origNextXid;
|
||||
TransactionId *xids = NULL;
|
||||
|
@ -2196,7 +2196,7 @@ RecoverPreparedTransactions(void)
|
|||
*
|
||||
* If setParent is true, set up subtransaction parent linkages.
|
||||
*
|
||||
* If setNextXid is true, set ShmemVariableCache->nextXid to the newest
|
||||
* If setNextXid is true, set TransamVariables->nextXid to the newest
|
||||
* value scanned.
|
||||
*/
|
||||
static char *
|
||||
|
@ -2205,7 +2205,7 @@ ProcessTwoPhaseBuffer(TransactionId xid,
|
|||
bool fromdisk,
|
||||
bool setParent, bool setNextXid)
|
||||
{
|
||||
FullTransactionId nextXid = ShmemVariableCache->nextXid;
|
||||
FullTransactionId nextXid = TransamVariables->nextXid;
|
||||
TransactionId origNextXid = XidFromFullTransactionId(nextXid);
|
||||
TransactionId *subxids;
|
||||
char *buf;
|
||||
|
|
|
@ -30,17 +30,17 @@
|
|||
/* Number of OIDs to prefetch (preallocate) per XLOG write */
|
||||
#define VAR_OID_PREFETCH 8192
|
||||
|
||||
/* pointer to "variable cache" in shared memory (set up by shmem.c) */
|
||||
VariableCache ShmemVariableCache = NULL;
|
||||
/* pointer to variables struct in shared memory */
|
||||
TransamVariablesData *TransamVariables = NULL;
|
||||
|
||||
|
||||
/*
|
||||
* Initialization of shared memory for ShmemVariableCache.
|
||||
* Initialization of shared memory for TransamVariables.
|
||||
*/
|
||||
Size
|
||||
VarsupShmemSize(void)
|
||||
{
|
||||
return sizeof(VariableCacheData);
|
||||
return sizeof(TransamVariablesData);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -49,13 +49,13 @@ VarsupShmemInit(void)
|
|||
bool found;
|
||||
|
||||
/* Initialize our shared state struct */
|
||||
ShmemVariableCache = ShmemInitStruct("ShmemVariableCache",
|
||||
sizeof(VariableCacheData),
|
||||
TransamVariables = ShmemInitStruct("TransamVariables",
|
||||
sizeof(TransamVariablesData),
|
||||
&found);
|
||||
if (!IsUnderPostmaster)
|
||||
{
|
||||
Assert(!found);
|
||||
memset(ShmemVariableCache, 0, sizeof(VariableCacheData));
|
||||
memset(TransamVariables, 0, sizeof(TransamVariablesData));
|
||||
}
|
||||
else
|
||||
Assert(found);
|
||||
|
@ -104,7 +104,7 @@ GetNewTransactionId(bool isSubXact)
|
|||
|
||||
LWLockAcquire(XidGenLock, LW_EXCLUSIVE);
|
||||
|
||||
full_xid = ShmemVariableCache->nextXid;
|
||||
full_xid = TransamVariables->nextXid;
|
||||
xid = XidFromFullTransactionId(full_xid);
|
||||
|
||||
/*----------
|
||||
|
@ -120,7 +120,7 @@ GetNewTransactionId(bool isSubXact)
|
|||
* Note that this coding also appears in GetNewMultiXactId.
|
||||
*----------
|
||||
*/
|
||||
if (TransactionIdFollowsOrEquals(xid, ShmemVariableCache->xidVacLimit))
|
||||
if (TransactionIdFollowsOrEquals(xid, TransamVariables->xidVacLimit))
|
||||
{
|
||||
/*
|
||||
* For safety's sake, we release XidGenLock while sending signals,
|
||||
|
@ -129,10 +129,10 @@ GetNewTransactionId(bool isSubXact)
|
|||
* possibility of deadlock while doing get_database_name(). First,
|
||||
* copy all the shared values we'll need in this path.
|
||||
*/
|
||||
TransactionId xidWarnLimit = ShmemVariableCache->xidWarnLimit;
|
||||
TransactionId xidStopLimit = ShmemVariableCache->xidStopLimit;
|
||||
TransactionId xidWrapLimit = ShmemVariableCache->xidWrapLimit;
|
||||
Oid oldest_datoid = ShmemVariableCache->oldestXidDB;
|
||||
TransactionId xidWarnLimit = TransamVariables->xidWarnLimit;
|
||||
TransactionId xidStopLimit = TransamVariables->xidStopLimit;
|
||||
TransactionId xidWrapLimit = TransamVariables->xidWrapLimit;
|
||||
Oid oldest_datoid = TransamVariables->oldestXidDB;
|
||||
|
||||
LWLockRelease(XidGenLock);
|
||||
|
||||
|
@ -188,7 +188,7 @@ GetNewTransactionId(bool isSubXact)
|
|||
|
||||
/* Re-acquire lock and start over */
|
||||
LWLockAcquire(XidGenLock, LW_EXCLUSIVE);
|
||||
full_xid = ShmemVariableCache->nextXid;
|
||||
full_xid = TransamVariables->nextXid;
|
||||
xid = XidFromFullTransactionId(full_xid);
|
||||
}
|
||||
|
||||
|
@ -211,7 +211,7 @@ GetNewTransactionId(bool isSubXact)
|
|||
* want the next incoming transaction to try it again. We cannot assign
|
||||
* more XIDs until there is CLOG space for them.
|
||||
*/
|
||||
FullTransactionIdAdvance(&ShmemVariableCache->nextXid);
|
||||
FullTransactionIdAdvance(&TransamVariables->nextXid);
|
||||
|
||||
/*
|
||||
* We must store the new XID into the shared ProcArray before releasing
|
||||
|
@ -290,7 +290,7 @@ ReadNextFullTransactionId(void)
|
|||
FullTransactionId fullXid;
|
||||
|
||||
LWLockAcquire(XidGenLock, LW_SHARED);
|
||||
fullXid = ShmemVariableCache->nextXid;
|
||||
fullXid = TransamVariables->nextXid;
|
||||
LWLockRelease(XidGenLock);
|
||||
|
||||
return fullXid;
|
||||
|
@ -315,7 +315,7 @@ AdvanceNextFullTransactionIdPastXid(TransactionId xid)
|
|||
Assert(AmStartupProcess() || !IsUnderPostmaster);
|
||||
|
||||
/* Fast return if this isn't an xid high enough to move the needle. */
|
||||
next_xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
|
||||
next_xid = XidFromFullTransactionId(TransamVariables->nextXid);
|
||||
if (!TransactionIdFollowsOrEquals(xid, next_xid))
|
||||
return;
|
||||
|
||||
|
@ -328,7 +328,7 @@ AdvanceNextFullTransactionIdPastXid(TransactionId xid)
|
|||
* point in the WAL stream.
|
||||
*/
|
||||
TransactionIdAdvance(xid);
|
||||
epoch = EpochFromFullTransactionId(ShmemVariableCache->nextXid);
|
||||
epoch = EpochFromFullTransactionId(TransamVariables->nextXid);
|
||||
if (unlikely(xid < next_xid))
|
||||
++epoch;
|
||||
newNextFullXid = FullTransactionIdFromEpochAndXid(epoch, xid);
|
||||
|
@ -338,7 +338,7 @@ AdvanceNextFullTransactionIdPastXid(TransactionId xid)
|
|||
* concurrent readers.
|
||||
*/
|
||||
LWLockAcquire(XidGenLock, LW_EXCLUSIVE);
|
||||
ShmemVariableCache->nextXid = newNextFullXid;
|
||||
TransamVariables->nextXid = newNextFullXid;
|
||||
LWLockRelease(XidGenLock);
|
||||
}
|
||||
|
||||
|
@ -355,10 +355,10 @@ void
|
|||
AdvanceOldestClogXid(TransactionId oldest_datfrozenxid)
|
||||
{
|
||||
LWLockAcquire(XactTruncationLock, LW_EXCLUSIVE);
|
||||
if (TransactionIdPrecedes(ShmemVariableCache->oldestClogXid,
|
||||
if (TransactionIdPrecedes(TransamVariables->oldestClogXid,
|
||||
oldest_datfrozenxid))
|
||||
{
|
||||
ShmemVariableCache->oldestClogXid = oldest_datfrozenxid;
|
||||
TransamVariables->oldestClogXid = oldest_datfrozenxid;
|
||||
}
|
||||
LWLockRelease(XactTruncationLock);
|
||||
}
|
||||
|
@ -441,13 +441,13 @@ SetTransactionIdLimit(TransactionId oldest_datfrozenxid, Oid oldest_datoid)
|
|||
|
||||
/* Grab lock for just long enough to set the new limit values */
|
||||
LWLockAcquire(XidGenLock, LW_EXCLUSIVE);
|
||||
ShmemVariableCache->oldestXid = oldest_datfrozenxid;
|
||||
ShmemVariableCache->xidVacLimit = xidVacLimit;
|
||||
ShmemVariableCache->xidWarnLimit = xidWarnLimit;
|
||||
ShmemVariableCache->xidStopLimit = xidStopLimit;
|
||||
ShmemVariableCache->xidWrapLimit = xidWrapLimit;
|
||||
ShmemVariableCache->oldestXidDB = oldest_datoid;
|
||||
curXid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
|
||||
TransamVariables->oldestXid = oldest_datfrozenxid;
|
||||
TransamVariables->xidVacLimit = xidVacLimit;
|
||||
TransamVariables->xidWarnLimit = xidWarnLimit;
|
||||
TransamVariables->xidStopLimit = xidStopLimit;
|
||||
TransamVariables->xidWrapLimit = xidWrapLimit;
|
||||
TransamVariables->oldestXidDB = oldest_datoid;
|
||||
curXid = XidFromFullTransactionId(TransamVariables->nextXid);
|
||||
LWLockRelease(XidGenLock);
|
||||
|
||||
/* Log the info */
|
||||
|
@ -523,10 +523,10 @@ ForceTransactionIdLimitUpdate(void)
|
|||
|
||||
/* Locking is probably not really necessary, but let's be careful */
|
||||
LWLockAcquire(XidGenLock, LW_SHARED);
|
||||
nextXid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
|
||||
xidVacLimit = ShmemVariableCache->xidVacLimit;
|
||||
oldestXid = ShmemVariableCache->oldestXid;
|
||||
oldestXidDB = ShmemVariableCache->oldestXidDB;
|
||||
nextXid = XidFromFullTransactionId(TransamVariables->nextXid);
|
||||
xidVacLimit = TransamVariables->xidVacLimit;
|
||||
oldestXid = TransamVariables->oldestXid;
|
||||
oldestXidDB = TransamVariables->oldestXidDB;
|
||||
LWLockRelease(XidGenLock);
|
||||
|
||||
if (!TransactionIdIsNormal(oldestXid))
|
||||
|
@ -576,37 +576,37 @@ GetNewObjectId(void)
|
|||
* available for automatic assignment during initdb, while ensuring they
|
||||
* will never conflict with user-assigned OIDs.
|
||||
*/
|
||||
if (ShmemVariableCache->nextOid < ((Oid) FirstNormalObjectId))
|
||||
if (TransamVariables->nextOid < ((Oid) FirstNormalObjectId))
|
||||
{
|
||||
if (IsPostmasterEnvironment)
|
||||
{
|
||||
/* wraparound, or first post-initdb assignment, in normal mode */
|
||||
ShmemVariableCache->nextOid = FirstNormalObjectId;
|
||||
ShmemVariableCache->oidCount = 0;
|
||||
TransamVariables->nextOid = FirstNormalObjectId;
|
||||
TransamVariables->oidCount = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* we may be bootstrapping, so don't enforce the full range */
|
||||
if (ShmemVariableCache->nextOid < ((Oid) FirstGenbkiObjectId))
|
||||
if (TransamVariables->nextOid < ((Oid) FirstGenbkiObjectId))
|
||||
{
|
||||
/* wraparound in standalone mode (unlikely but possible) */
|
||||
ShmemVariableCache->nextOid = FirstNormalObjectId;
|
||||
ShmemVariableCache->oidCount = 0;
|
||||
TransamVariables->nextOid = FirstNormalObjectId;
|
||||
TransamVariables->oidCount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* If we run out of logged for use oids then we must log more */
|
||||
if (ShmemVariableCache->oidCount == 0)
|
||||
if (TransamVariables->oidCount == 0)
|
||||
{
|
||||
XLogPutNextOid(ShmemVariableCache->nextOid + VAR_OID_PREFETCH);
|
||||
ShmemVariableCache->oidCount = VAR_OID_PREFETCH;
|
||||
XLogPutNextOid(TransamVariables->nextOid + VAR_OID_PREFETCH);
|
||||
TransamVariables->oidCount = VAR_OID_PREFETCH;
|
||||
}
|
||||
|
||||
result = ShmemVariableCache->nextOid;
|
||||
result = TransamVariables->nextOid;
|
||||
|
||||
(ShmemVariableCache->nextOid)++;
|
||||
(ShmemVariableCache->oidCount)--;
|
||||
(TransamVariables->nextOid)++;
|
||||
(TransamVariables->oidCount)--;
|
||||
|
||||
LWLockRelease(OidGenLock);
|
||||
|
||||
|
@ -629,12 +629,12 @@ SetNextObjectId(Oid nextOid)
|
|||
/* Taking the lock is, therefore, just pro forma; but do it anyway */
|
||||
LWLockAcquire(OidGenLock, LW_EXCLUSIVE);
|
||||
|
||||
if (ShmemVariableCache->nextOid > nextOid)
|
||||
if (TransamVariables->nextOid > nextOid)
|
||||
elog(ERROR, "too late to advance OID counter to %u, it is now %u",
|
||||
nextOid, ShmemVariableCache->nextOid);
|
||||
nextOid, TransamVariables->nextOid);
|
||||
|
||||
ShmemVariableCache->nextOid = nextOid;
|
||||
ShmemVariableCache->oidCount = 0;
|
||||
TransamVariables->nextOid = nextOid;
|
||||
TransamVariables->oidCount = 0;
|
||||
|
||||
LWLockRelease(OidGenLock);
|
||||
}
|
||||
|
@ -661,7 +661,7 @@ StopGeneratingPinnedObjectIds(void)
|
|||
* Assert that xid is between [oldestXid, nextXid], which is the range we
|
||||
* expect XIDs coming from tables etc to be in.
|
||||
*
|
||||
* As ShmemVariableCache->oldestXid could change just after this call without
|
||||
* As TransamVariables->oldestXid could change just after this call without
|
||||
* further precautions, and as a wrapped-around xid could again fall within
|
||||
* the valid range, this assertion can only detect if something is definitely
|
||||
* wrong, but not establish correctness.
|
||||
|
@ -696,8 +696,8 @@ AssertTransactionIdInAllowableRange(TransactionId xid)
|
|||
* before we see the updated nextXid value.
|
||||
*/
|
||||
pg_memory_barrier();
|
||||
oldest_xid = ShmemVariableCache->oldestXid;
|
||||
next_xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
|
||||
oldest_xid = TransamVariables->oldestXid;
|
||||
next_xid = XidFromFullTransactionId(TransamVariables->nextXid);
|
||||
|
||||
Assert(TransactionIdFollowsOrEquals(xid, oldest_xid) ||
|
||||
TransactionIdPrecedesOrEquals(xid, next_xid));
|
||||
|
|
|
@ -4819,9 +4819,9 @@ BootStrapXLOG(void)
|
|||
checkPoint.time = (pg_time_t) time(NULL);
|
||||
checkPoint.oldestActiveXid = InvalidTransactionId;
|
||||
|
||||
ShmemVariableCache->nextXid = checkPoint.nextXid;
|
||||
ShmemVariableCache->nextOid = checkPoint.nextOid;
|
||||
ShmemVariableCache->oidCount = 0;
|
||||
TransamVariables->nextXid = checkPoint.nextXid;
|
||||
TransamVariables->nextOid = checkPoint.nextOid;
|
||||
TransamVariables->oidCount = 0;
|
||||
MultiXactSetNextMXact(checkPoint.nextMulti, checkPoint.nextMultiOffset);
|
||||
AdvanceOldestClogXid(checkPoint.oldestXid);
|
||||
SetTransactionIdLimit(checkPoint.oldestXid, checkPoint.oldestXidDB);
|
||||
|
@ -5285,9 +5285,9 @@ StartupXLOG(void)
|
|||
checkPoint = ControlFile->checkPointCopy;
|
||||
|
||||
/* initialize shared memory variables from the checkpoint record */
|
||||
ShmemVariableCache->nextXid = checkPoint.nextXid;
|
||||
ShmemVariableCache->nextOid = checkPoint.nextOid;
|
||||
ShmemVariableCache->oidCount = 0;
|
||||
TransamVariables->nextXid = checkPoint.nextXid;
|
||||
TransamVariables->nextOid = checkPoint.nextOid;
|
||||
TransamVariables->oidCount = 0;
|
||||
MultiXactSetNextMXact(checkPoint.nextMulti, checkPoint.nextMultiOffset);
|
||||
AdvanceOldestClogXid(checkPoint.oldestXid);
|
||||
SetTransactionIdLimit(checkPoint.oldestXid, checkPoint.oldestXidDB);
|
||||
|
@ -5323,7 +5323,7 @@ StartupXLOG(void)
|
|||
StartupReorderBuffer();
|
||||
|
||||
/*
|
||||
* Startup CLOG. This must be done after ShmemVariableCache->nextXid has
|
||||
* Startup CLOG. This must be done after TransamVariables->nextXid has
|
||||
* been initialized and before we accept connections or begin WAL replay.
|
||||
*/
|
||||
StartupCLOG();
|
||||
|
@ -5512,7 +5512,7 @@ StartupXLOG(void)
|
|||
Assert(TransactionIdIsValid(oldestActiveXID));
|
||||
|
||||
/* Tell procarray about the range of xids it has to deal with */
|
||||
ProcArrayInitRecovery(XidFromFullTransactionId(ShmemVariableCache->nextXid));
|
||||
ProcArrayInitRecovery(XidFromFullTransactionId(TransamVariables->nextXid));
|
||||
|
||||
/*
|
||||
* Startup subtrans only. CLOG, MultiXact and commit timestamp
|
||||
|
@ -5786,8 +5786,8 @@ StartupXLOG(void)
|
|||
|
||||
/* also initialize latestCompletedXid, to nextXid - 1 */
|
||||
LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE);
|
||||
ShmemVariableCache->latestCompletedXid = ShmemVariableCache->nextXid;
|
||||
FullTransactionIdRetreat(&ShmemVariableCache->latestCompletedXid);
|
||||
TransamVariables->latestCompletedXid = TransamVariables->nextXid;
|
||||
FullTransactionIdRetreat(&TransamVariables->latestCompletedXid);
|
||||
LWLockRelease(ProcArrayLock);
|
||||
|
||||
/*
|
||||
|
@ -6779,20 +6779,20 @@ CreateCheckPoint(int flags)
|
|||
* there.
|
||||
*/
|
||||
LWLockAcquire(XidGenLock, LW_SHARED);
|
||||
checkPoint.nextXid = ShmemVariableCache->nextXid;
|
||||
checkPoint.oldestXid = ShmemVariableCache->oldestXid;
|
||||
checkPoint.oldestXidDB = ShmemVariableCache->oldestXidDB;
|
||||
checkPoint.nextXid = TransamVariables->nextXid;
|
||||
checkPoint.oldestXid = TransamVariables->oldestXid;
|
||||
checkPoint.oldestXidDB = TransamVariables->oldestXidDB;
|
||||
LWLockRelease(XidGenLock);
|
||||
|
||||
LWLockAcquire(CommitTsLock, LW_SHARED);
|
||||
checkPoint.oldestCommitTsXid = ShmemVariableCache->oldestCommitTsXid;
|
||||
checkPoint.newestCommitTsXid = ShmemVariableCache->newestCommitTsXid;
|
||||
checkPoint.oldestCommitTsXid = TransamVariables->oldestCommitTsXid;
|
||||
checkPoint.newestCommitTsXid = TransamVariables->newestCommitTsXid;
|
||||
LWLockRelease(CommitTsLock);
|
||||
|
||||
LWLockAcquire(OidGenLock, LW_SHARED);
|
||||
checkPoint.nextOid = ShmemVariableCache->nextOid;
|
||||
checkPoint.nextOid = TransamVariables->nextOid;
|
||||
if (!shutdown)
|
||||
checkPoint.nextOid += ShmemVariableCache->oidCount;
|
||||
checkPoint.nextOid += TransamVariables->oidCount;
|
||||
LWLockRelease(OidGenLock);
|
||||
|
||||
MultiXactGetCheckptMulti(shutdown,
|
||||
|
@ -7884,16 +7884,16 @@ xlog_redo(XLogReaderState *record)
|
|||
Oid nextOid;
|
||||
|
||||
/*
|
||||
* We used to try to take the maximum of ShmemVariableCache->nextOid
|
||||
* and the recorded nextOid, but that fails if the OID counter wraps
|
||||
* We used to try to take the maximum of TransamVariables->nextOid and
|
||||
* the recorded nextOid, but that fails if the OID counter wraps
|
||||
* around. Since no OID allocation should be happening during replay
|
||||
* anyway, better to just believe the record exactly. We still take
|
||||
* OidGenLock while setting the variable, just in case.
|
||||
*/
|
||||
memcpy(&nextOid, XLogRecGetData(record), sizeof(Oid));
|
||||
LWLockAcquire(OidGenLock, LW_EXCLUSIVE);
|
||||
ShmemVariableCache->nextOid = nextOid;
|
||||
ShmemVariableCache->oidCount = 0;
|
||||
TransamVariables->nextOid = nextOid;
|
||||
TransamVariables->oidCount = 0;
|
||||
LWLockRelease(OidGenLock);
|
||||
}
|
||||
else if (info == XLOG_CHECKPOINT_SHUTDOWN)
|
||||
|
@ -7904,11 +7904,11 @@ xlog_redo(XLogReaderState *record)
|
|||
memcpy(&checkPoint, XLogRecGetData(record), sizeof(CheckPoint));
|
||||
/* In a SHUTDOWN checkpoint, believe the counters exactly */
|
||||
LWLockAcquire(XidGenLock, LW_EXCLUSIVE);
|
||||
ShmemVariableCache->nextXid = checkPoint.nextXid;
|
||||
TransamVariables->nextXid = checkPoint.nextXid;
|
||||
LWLockRelease(XidGenLock);
|
||||
LWLockAcquire(OidGenLock, LW_EXCLUSIVE);
|
||||
ShmemVariableCache->nextOid = checkPoint.nextOid;
|
||||
ShmemVariableCache->oidCount = 0;
|
||||
TransamVariables->nextOid = checkPoint.nextOid;
|
||||
TransamVariables->oidCount = 0;
|
||||
LWLockRelease(OidGenLock);
|
||||
MultiXactSetNextMXact(checkPoint.nextMulti,
|
||||
checkPoint.nextMultiOffset);
|
||||
|
@ -8001,9 +8001,9 @@ xlog_redo(XLogReaderState *record)
|
|||
memcpy(&checkPoint, XLogRecGetData(record), sizeof(CheckPoint));
|
||||
/* In an ONLINE checkpoint, treat the XID counter as a minimum */
|
||||
LWLockAcquire(XidGenLock, LW_EXCLUSIVE);
|
||||
if (FullTransactionIdPrecedes(ShmemVariableCache->nextXid,
|
||||
if (FullTransactionIdPrecedes(TransamVariables->nextXid,
|
||||
checkPoint.nextXid))
|
||||
ShmemVariableCache->nextXid = checkPoint.nextXid;
|
||||
TransamVariables->nextXid = checkPoint.nextXid;
|
||||
LWLockRelease(XidGenLock);
|
||||
|
||||
/*
|
||||
|
@ -8028,7 +8028,7 @@ xlog_redo(XLogReaderState *record)
|
|||
*/
|
||||
MultiXactAdvanceOldest(checkPoint.oldestMulti,
|
||||
checkPoint.oldestMultiDB);
|
||||
if (TransactionIdPrecedes(ShmemVariableCache->oldestXid,
|
||||
if (TransactionIdPrecedes(TransamVariables->oldestXid,
|
||||
checkPoint.oldestXid))
|
||||
SetTransactionIdLimit(checkPoint.oldestXid,
|
||||
checkPoint.oldestXidDB);
|
||||
|
|
|
@ -2182,8 +2182,8 @@ XLogRecGetFullXid(XLogReaderState *record)
|
|||
Assert(AmStartupProcess() || !IsUnderPostmaster);
|
||||
|
||||
xid = XLogRecGetXid(record);
|
||||
next_xid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
|
||||
epoch = EpochFromFullTransactionId(ShmemVariableCache->nextXid);
|
||||
next_xid = XidFromFullTransactionId(TransamVariables->nextXid);
|
||||
epoch = EpochFromFullTransactionId(TransamVariables->nextXid);
|
||||
|
||||
/*
|
||||
* If xid is numerically greater than next_xid, it has to be from the last
|
||||
|
|
|
@ -1869,7 +1869,7 @@ ApplyWalRecord(XLogReaderState *xlogreader, XLogRecord *record, TimeLineID *repl
|
|||
error_context_stack = &errcallback;
|
||||
|
||||
/*
|
||||
* ShmemVariableCache->nextXid must be beyond record's xid.
|
||||
* TransamVariables->nextXid must be beyond record's xid.
|
||||
*/
|
||||
AdvanceNextFullTransactionIdPastXid(record->xl_xid);
|
||||
|
||||
|
|
|
@ -2640,8 +2640,8 @@ deleted:
|
|||
*
|
||||
* Even if we didn't vacuum anything, it may still be important to do
|
||||
* this, because one indirect effect of vac_update_datfrozenxid() is to
|
||||
* update ShmemVariableCache->xidVacLimit. That might need to be done
|
||||
* even if we haven't vacuumed anything, because relations with older
|
||||
* update TransamVariables->xidVacLimit. That might need to be done even
|
||||
* if we haven't vacuumed anything, because relations with older
|
||||
* relfrozenxid values or other databases with older datfrozenxid values
|
||||
* might have been dropped, allowing xidVacLimit to advance.
|
||||
*
|
||||
|
|
|
@ -180,7 +180,7 @@ struct GlobalVisState
|
|||
typedef struct ComputeXidHorizonsResult
|
||||
{
|
||||
/*
|
||||
* The value of ShmemVariableCache->latestCompletedXid when
|
||||
* The value of TransamVariables->latestCompletedXid when
|
||||
* ComputeXidHorizons() held ProcArrayLock.
|
||||
*/
|
||||
FullTransactionId latest_completed;
|
||||
|
@ -442,7 +442,7 @@ CreateSharedProcArray(void)
|
|||
procArray->lastOverflowedXid = InvalidTransactionId;
|
||||
procArray->replication_slot_xmin = InvalidTransactionId;
|
||||
procArray->replication_slot_catalog_xmin = InvalidTransactionId;
|
||||
ShmemVariableCache->xactCompletionCount = 1;
|
||||
TransamVariables->xactCompletionCount = 1;
|
||||
}
|
||||
|
||||
allProcs = ProcGlobal->allProcs;
|
||||
|
@ -591,7 +591,7 @@ ProcArrayRemove(PGPROC *proc, TransactionId latestXid)
|
|||
MaintainLatestCompletedXid(latestXid);
|
||||
|
||||
/* Same with xactCompletionCount */
|
||||
ShmemVariableCache->xactCompletionCount++;
|
||||
TransamVariables->xactCompletionCount++;
|
||||
|
||||
ProcGlobal->xids[myoff] = InvalidTransactionId;
|
||||
ProcGlobal->subxidStates[myoff].overflowed = false;
|
||||
|
@ -773,7 +773,7 @@ ProcArrayEndTransactionInternal(PGPROC *proc, TransactionId latestXid)
|
|||
MaintainLatestCompletedXid(latestXid);
|
||||
|
||||
/* Same with xactCompletionCount */
|
||||
ShmemVariableCache->xactCompletionCount++;
|
||||
TransamVariables->xactCompletionCount++;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -942,7 +942,7 @@ ProcArrayClearTransaction(PGPROC *proc)
|
|||
* otherwise could end up reusing the snapshot later. Which would be bad,
|
||||
* because it might not count the prepared transaction as running.
|
||||
*/
|
||||
ShmemVariableCache->xactCompletionCount++;
|
||||
TransamVariables->xactCompletionCount++;
|
||||
|
||||
/* Clear the subtransaction-XID cache too */
|
||||
Assert(ProcGlobal->subxidStates[pgxactoff].count == proc->subxidStatus.count &&
|
||||
|
@ -959,13 +959,13 @@ ProcArrayClearTransaction(PGPROC *proc)
|
|||
}
|
||||
|
||||
/*
|
||||
* Update ShmemVariableCache->latestCompletedXid to point to latestXid if
|
||||
* Update TransamVariables->latestCompletedXid to point to latestXid if
|
||||
* currently older.
|
||||
*/
|
||||
static void
|
||||
MaintainLatestCompletedXid(TransactionId latestXid)
|
||||
{
|
||||
FullTransactionId cur_latest = ShmemVariableCache->latestCompletedXid;
|
||||
FullTransactionId cur_latest = TransamVariables->latestCompletedXid;
|
||||
|
||||
Assert(FullTransactionIdIsValid(cur_latest));
|
||||
Assert(!RecoveryInProgress());
|
||||
|
@ -973,12 +973,12 @@ MaintainLatestCompletedXid(TransactionId latestXid)
|
|||
|
||||
if (TransactionIdPrecedes(XidFromFullTransactionId(cur_latest), latestXid))
|
||||
{
|
||||
ShmemVariableCache->latestCompletedXid =
|
||||
TransamVariables->latestCompletedXid =
|
||||
FullXidRelativeTo(cur_latest, latestXid);
|
||||
}
|
||||
|
||||
Assert(IsBootstrapProcessingMode() ||
|
||||
FullTransactionIdIsNormal(ShmemVariableCache->latestCompletedXid));
|
||||
FullTransactionIdIsNormal(TransamVariables->latestCompletedXid));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -987,7 +987,7 @@ MaintainLatestCompletedXid(TransactionId latestXid)
|
|||
static void
|
||||
MaintainLatestCompletedXidRecovery(TransactionId latestXid)
|
||||
{
|
||||
FullTransactionId cur_latest = ShmemVariableCache->latestCompletedXid;
|
||||
FullTransactionId cur_latest = TransamVariables->latestCompletedXid;
|
||||
FullTransactionId rel;
|
||||
|
||||
Assert(AmStartupProcess() || !IsUnderPostmaster);
|
||||
|
@ -998,17 +998,17 @@ MaintainLatestCompletedXidRecovery(TransactionId latestXid)
|
|||
* latestCompletedXid to be initialized in recovery. But in recovery it's
|
||||
* safe to access nextXid without a lock for the startup process.
|
||||
*/
|
||||
rel = ShmemVariableCache->nextXid;
|
||||
Assert(FullTransactionIdIsValid(ShmemVariableCache->nextXid));
|
||||
rel = TransamVariables->nextXid;
|
||||
Assert(FullTransactionIdIsValid(TransamVariables->nextXid));
|
||||
|
||||
if (!FullTransactionIdIsValid(cur_latest) ||
|
||||
TransactionIdPrecedes(XidFromFullTransactionId(cur_latest), latestXid))
|
||||
{
|
||||
ShmemVariableCache->latestCompletedXid =
|
||||
TransamVariables->latestCompletedXid =
|
||||
FullXidRelativeTo(rel, latestXid);
|
||||
}
|
||||
|
||||
Assert(FullTransactionIdIsNormal(ShmemVariableCache->latestCompletedXid));
|
||||
Assert(FullTransactionIdIsNormal(TransamVariables->latestCompletedXid));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1269,16 +1269,16 @@ ProcArrayApplyRecoveryInfo(RunningTransactions running)
|
|||
MaintainLatestCompletedXidRecovery(running->latestCompletedXid);
|
||||
|
||||
/*
|
||||
* NB: No need to increment ShmemVariableCache->xactCompletionCount here,
|
||||
* NB: No need to increment TransamVariables->xactCompletionCount here,
|
||||
* nobody can see it yet.
|
||||
*/
|
||||
|
||||
LWLockRelease(ProcArrayLock);
|
||||
|
||||
/* ShmemVariableCache->nextXid must be beyond any observed xid. */
|
||||
/* TransamVariables->nextXid must be beyond any observed xid. */
|
||||
AdvanceNextFullTransactionIdPastXid(latestObservedXid);
|
||||
|
||||
Assert(FullTransactionIdIsValid(ShmemVariableCache->nextXid));
|
||||
Assert(FullTransactionIdIsValid(TransamVariables->nextXid));
|
||||
|
||||
KnownAssignedXidsDisplay(trace_recovery(DEBUG3));
|
||||
if (standbyState == STANDBY_SNAPSHOT_READY)
|
||||
|
@ -1456,7 +1456,7 @@ TransactionIdIsInProgress(TransactionId xid)
|
|||
* target Xid is after that, it's surely still running.
|
||||
*/
|
||||
latestCompletedXid =
|
||||
XidFromFullTransactionId(ShmemVariableCache->latestCompletedXid);
|
||||
XidFromFullTransactionId(TransamVariables->latestCompletedXid);
|
||||
if (TransactionIdPrecedes(latestCompletedXid, xid))
|
||||
{
|
||||
LWLockRelease(ProcArrayLock);
|
||||
|
@ -1725,7 +1725,7 @@ ComputeXidHorizons(ComputeXidHorizonsResult *h)
|
|||
|
||||
LWLockAcquire(ProcArrayLock, LW_SHARED);
|
||||
|
||||
h->latest_completed = ShmemVariableCache->latestCompletedXid;
|
||||
h->latest_completed = TransamVariables->latestCompletedXid;
|
||||
|
||||
/*
|
||||
* We initialize the MIN() calculation with latestCompletedXid + 1. This
|
||||
|
@ -2082,7 +2082,7 @@ GetSnapshotDataReuse(Snapshot snapshot)
|
|||
if (unlikely(snapshot->snapXactCompletionCount == 0))
|
||||
return false;
|
||||
|
||||
curXactCompletionCount = ShmemVariableCache->xactCompletionCount;
|
||||
curXactCompletionCount = TransamVariables->xactCompletionCount;
|
||||
if (curXactCompletionCount != snapshot->snapXactCompletionCount)
|
||||
return false;
|
||||
|
||||
|
@ -2219,13 +2219,13 @@ GetSnapshotData(Snapshot snapshot)
|
|||
return snapshot;
|
||||
}
|
||||
|
||||
latest_completed = ShmemVariableCache->latestCompletedXid;
|
||||
latest_completed = TransamVariables->latestCompletedXid;
|
||||
mypgxactoff = MyProc->pgxactoff;
|
||||
myxid = other_xids[mypgxactoff];
|
||||
Assert(myxid == MyProc->xid);
|
||||
|
||||
oldestxid = ShmemVariableCache->oldestXid;
|
||||
curXactCompletionCount = ShmemVariableCache->xactCompletionCount;
|
||||
oldestxid = TransamVariables->oldestXid;
|
||||
curXactCompletionCount = TransamVariables->xactCompletionCount;
|
||||
|
||||
/* xmax is always latestCompletedXid + 1 */
|
||||
xmax = XidFromFullTransactionId(latest_completed);
|
||||
|
@ -2460,10 +2460,10 @@ GetSnapshotData(Snapshot snapshot)
|
|||
/*
|
||||
* Check if we know that we can initialize or increase the lower
|
||||
* bound. Currently the only cheap way to do so is to use
|
||||
* ShmemVariableCache->oldestXid as input.
|
||||
* TransamVariables->oldestXid as input.
|
||||
*
|
||||
* We should definitely be able to do better. We could e.g. put a
|
||||
* global lower bound value into ShmemVariableCache.
|
||||
* global lower bound value into TransamVariables.
|
||||
*/
|
||||
GlobalVisSharedRels.maybe_needed =
|
||||
FullTransactionIdNewer(GlobalVisSharedRels.maybe_needed,
|
||||
|
@ -2719,9 +2719,9 @@ GetRunningTransactionData(void)
|
|||
LWLockAcquire(XidGenLock, LW_SHARED);
|
||||
|
||||
latestCompletedXid =
|
||||
XidFromFullTransactionId(ShmemVariableCache->latestCompletedXid);
|
||||
XidFromFullTransactionId(TransamVariables->latestCompletedXid);
|
||||
oldestRunningXid =
|
||||
XidFromFullTransactionId(ShmemVariableCache->nextXid);
|
||||
XidFromFullTransactionId(TransamVariables->nextXid);
|
||||
|
||||
/*
|
||||
* Spin over procArray collecting all xids
|
||||
|
@ -2812,7 +2812,7 @@ GetRunningTransactionData(void)
|
|||
CurrentRunningXacts->xcnt = count - subcount;
|
||||
CurrentRunningXacts->subxcnt = subcount;
|
||||
CurrentRunningXacts->subxid_overflow = suboverflowed;
|
||||
CurrentRunningXacts->nextXid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
|
||||
CurrentRunningXacts->nextXid = XidFromFullTransactionId(TransamVariables->nextXid);
|
||||
CurrentRunningXacts->oldestRunningXid = oldestRunningXid;
|
||||
CurrentRunningXacts->latestCompletedXid = latestCompletedXid;
|
||||
|
||||
|
@ -2858,7 +2858,7 @@ GetOldestActiveTransactionId(void)
|
|||
* have already completed), when we spin over it.
|
||||
*/
|
||||
LWLockAcquire(XidGenLock, LW_SHARED);
|
||||
oldestRunningXid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
|
||||
oldestRunningXid = XidFromFullTransactionId(TransamVariables->nextXid);
|
||||
LWLockRelease(XidGenLock);
|
||||
|
||||
/*
|
||||
|
@ -2924,7 +2924,7 @@ GetOldestSafeDecodingTransactionId(bool catalogOnly)
|
|||
* a safe, albeit pessimal, value.
|
||||
*/
|
||||
LWLockAcquire(XidGenLock, LW_SHARED);
|
||||
oldestSafeXid = XidFromFullTransactionId(ShmemVariableCache->nextXid);
|
||||
oldestSafeXid = XidFromFullTransactionId(TransamVariables->nextXid);
|
||||
|
||||
/*
|
||||
* If there's already a slot pegging the xmin horizon, we can start with
|
||||
|
@ -3968,7 +3968,7 @@ XidCacheRemoveRunningXids(TransactionId xid,
|
|||
MaintainLatestCompletedXid(latestXid);
|
||||
|
||||
/* ... and xactCompletionCount */
|
||||
ShmemVariableCache->xactCompletionCount++;
|
||||
TransamVariables->xactCompletionCount++;
|
||||
|
||||
LWLockRelease(ProcArrayLock);
|
||||
}
|
||||
|
@ -4390,7 +4390,7 @@ RecordKnownAssignedTransactionIds(TransactionId xid)
|
|||
*/
|
||||
latestObservedXid = xid;
|
||||
|
||||
/* ShmemVariableCache->nextXid must be beyond any observed xid */
|
||||
/* TransamVariables->nextXid must be beyond any observed xid */
|
||||
AdvanceNextFullTransactionIdPastXid(latestObservedXid);
|
||||
}
|
||||
}
|
||||
|
@ -4418,7 +4418,7 @@ ExpireTreeKnownAssignedTransactionIds(TransactionId xid, int nsubxids,
|
|||
MaintainLatestCompletedXidRecovery(max_xid);
|
||||
|
||||
/* ... and xactCompletionCount */
|
||||
ShmemVariableCache->xactCompletionCount++;
|
||||
TransamVariables->xactCompletionCount++;
|
||||
|
||||
LWLockRelease(ProcArrayLock);
|
||||
}
|
||||
|
|
|
@ -3390,7 +3390,7 @@ ReleasePredicateLocks(bool isCommit, bool isReadOnlySafe)
|
|||
* transaction to complete before freeing some RAM; correctness of visible
|
||||
* behavior is not affected.
|
||||
*/
|
||||
MySerializableXact->finishedBefore = XidFromFullTransactionId(ShmemVariableCache->nextXid);
|
||||
MySerializableXact->finishedBefore = XidFromFullTransactionId(TransamVariables->nextXid);
|
||||
|
||||
/*
|
||||
* If it's not a commit it's either a rollback or a read-only transaction
|
||||
|
|
|
@ -126,8 +126,8 @@ TransactionIdInRecentPast(FullTransactionId fxid, TransactionId *extracted_xid)
|
|||
(unsigned long long) U64FromFullTransactionId(fxid))));
|
||||
|
||||
/*
|
||||
* ShmemVariableCache->oldestClogXid is protected by XactTruncationLock,
|
||||
* but we don't acquire that lock here. Instead, we require the caller to
|
||||
* TransamVariables->oldestClogXid is protected by XactTruncationLock, but
|
||||
* we don't acquire that lock here. Instead, we require the caller to
|
||||
* acquire it, because the caller is presumably going to look up the
|
||||
* returned XID. If we took and released the lock within this function, a
|
||||
* CLOG truncation could occur before the caller finished with the XID.
|
||||
|
@ -137,12 +137,12 @@ TransactionIdInRecentPast(FullTransactionId fxid, TransactionId *extracted_xid)
|
|||
/*
|
||||
* If the transaction ID has wrapped around, it's definitely too old to
|
||||
* determine the commit status. Otherwise, we can compare it to
|
||||
* ShmemVariableCache->oldestClogXid to determine whether the relevant
|
||||
* CLOG entry is guaranteed to still exist.
|
||||
* TransamVariables->oldestClogXid to determine whether the relevant CLOG
|
||||
* entry is guaranteed to still exist.
|
||||
*/
|
||||
if (xid_epoch + 1 < now_epoch
|
||||
|| (xid_epoch + 1 == now_epoch && xid < now_epoch_next_xid)
|
||||
|| TransactionIdPrecedes(xid, ShmemVariableCache->oldestClogXid))
|
||||
|| TransactionIdPrecedes(xid, TransamVariables->oldestClogXid))
|
||||
return false;
|
||||
|
||||
return true;
|
||||
|
|
|
@ -197,7 +197,7 @@ FullTransactionIdAdvance(FullTransactionId *dest)
|
|||
#define FirstNormalObjectId 16384
|
||||
|
||||
/*
|
||||
* VariableCache is a data structure in shared memory that is used to track
|
||||
* TransamVariables is a data structure in shared memory that is used to track
|
||||
* OID and XID assignment state. For largely historical reasons, there is
|
||||
* just one struct with different fields that are protected by different
|
||||
* LWLocks.
|
||||
|
@ -206,7 +206,7 @@ FullTransactionIdAdvance(FullTransactionId *dest)
|
|||
* used just to generate useful messages when xidWarnLimit or xidStopLimit
|
||||
* are exceeded.
|
||||
*/
|
||||
typedef struct VariableCacheData
|
||||
typedef struct TransamVariablesData
|
||||
{
|
||||
/*
|
||||
* These fields are protected by OidGenLock.
|
||||
|
@ -252,9 +252,7 @@ typedef struct VariableCacheData
|
|||
*/
|
||||
TransactionId oldestClogXid; /* oldest it's safe to look up in clog */
|
||||
|
||||
} VariableCacheData;
|
||||
|
||||
typedef VariableCacheData *VariableCache;
|
||||
} TransamVariablesData;
|
||||
|
||||
|
||||
/* ----------------
|
||||
|
@ -266,7 +264,7 @@ typedef VariableCacheData *VariableCache;
|
|||
extern bool TransactionStartedDuringRecovery(void);
|
||||
|
||||
/* in transam/varsup.c */
|
||||
extern PGDLLIMPORT VariableCache ShmemVariableCache;
|
||||
extern PGDLLIMPORT TransamVariablesData *TransamVariables;
|
||||
|
||||
/*
|
||||
* prototypes for functions in transam/transam.c
|
||||
|
|
|
@ -80,7 +80,7 @@ typedef struct RunningTransactionsData
|
|||
int xcnt; /* # of xact ids in xids[] */
|
||||
int subxcnt; /* # of subxact ids in xids[] */
|
||||
bool subxid_overflow; /* snapshot overflowed, subxids missing */
|
||||
TransactionId nextXid; /* xid from ShmemVariableCache->nextXid */
|
||||
TransactionId nextXid; /* xid from TransamVariables->nextXid */
|
||||
TransactionId oldestRunningXid; /* *not* oldestXmin */
|
||||
TransactionId latestCompletedXid; /* so we can set xmax */
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ typedef struct xl_running_xacts
|
|||
int xcnt; /* # of xact ids in xids[] */
|
||||
int subxcnt; /* # of subxact ids in xids[] */
|
||||
bool subxid_overflow; /* snapshot overflowed, subxids missing */
|
||||
TransactionId nextXid; /* xid from ShmemVariableCache->nextXid */
|
||||
TransactionId nextXid; /* xid from TransamVariables->nextXid */
|
||||
TransactionId oldestRunningXid; /* *not* oldestXmin */
|
||||
TransactionId latestCompletedXid; /* so we can set xmax */
|
||||
|
||||
|
|
|
@ -203,7 +203,7 @@ consume_xids_shortcut(void)
|
|||
uint32 consumed;
|
||||
|
||||
LWLockAcquire(XidGenLock, LW_EXCLUSIVE);
|
||||
nextXid = ShmemVariableCache->nextXid;
|
||||
nextXid = TransamVariables->nextXid;
|
||||
|
||||
/*
|
||||
* Go slow near the "interesting values". The interesting zones include 5
|
||||
|
@ -211,7 +211,7 @@ consume_xids_shortcut(void)
|
|||
*/
|
||||
consumed = XidSkip(nextXid);
|
||||
if (consumed > 0)
|
||||
ShmemVariableCache->nextXid.value += (uint64) consumed;
|
||||
TransamVariables->nextXid.value += (uint64) consumed;
|
||||
|
||||
LWLockRelease(XidGenLock);
|
||||
|
||||
|
|
|
@ -2831,6 +2831,7 @@ TocEntry
|
|||
TokenAuxData
|
||||
TokenizedAuthLine
|
||||
TrackItem
|
||||
TransamVariablesData
|
||||
TransApplyAction
|
||||
TransInvalidationInfo
|
||||
TransState
|
||||
|
@ -2961,8 +2962,6 @@ VarString
|
|||
VarStringSortSupport
|
||||
Variable
|
||||
VariableAssignHook
|
||||
VariableCache
|
||||
VariableCacheData
|
||||
VariableSetKind
|
||||
VariableSetStmt
|
||||
VariableShowStmt
|
||||
|
|
Loading…
Reference in New Issue