mirror of
https://github.com/postgres/postgres.git
synced 2025-11-24 00:23:06 +03:00
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:
@@ -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),
|
||||
&found);
|
||||
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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user