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