Commit cd9c1b3e authored by Alvaro Herrera's avatar Alvaro Herrera

Rename PGPROC->vacuumFlags to statusFlags

With more flags associated to a PGPROC entry that are not related to
vacuum (currently existing or planned), the name "statusFlags" describes
its purpose better.

(The same is done to the mirroring PROC_HDR->vacuumFlags.)

No functional changes in this commit.

This was suggested first by Hari Babu Kommi in [1] and then by Michael
Paquier at [2].

[1] https://postgr.es/m/CAJrrPGcsDC-oy1AhqH0JkXYa0Z2AgbuXzHPpByLoBGMxfOZMEQ@mail.gmail.com
[2] https://postgr.es/m/20200820060929.GB3730@paquier.xyz

Author: Dmitry Dolgov <9erthalion6@gmail.com>
Reviewed-by: default avatarÁlvaro Herrera <alvherre@alvh.no-ip.org>
Discussion: https://postgr.es/m/20201116182446.qcg3o6szo2zookyr@localhost
parent 4025e6c4
...@@ -464,7 +464,7 @@ MarkAsPreparingGuts(GlobalTransaction gxact, TransactionId xid, const char *gid, ...@@ -464,7 +464,7 @@ MarkAsPreparingGuts(GlobalTransaction gxact, TransactionId xid, const char *gid,
proc->xid = xid; proc->xid = xid;
Assert(proc->xmin == InvalidTransactionId); Assert(proc->xmin == InvalidTransactionId);
proc->delayChkpt = false; proc->delayChkpt = false;
proc->vacuumFlags = 0; proc->statusFlags = 0;
proc->pid = 0; proc->pid = 0;
proc->backendId = InvalidBackendId; proc->backendId = InvalidBackendId;
proc->databaseId = databaseid; proc->databaseId = databaseid;
......
...@@ -1742,10 +1742,10 @@ vacuum_rel(Oid relid, RangeVar *relation, VacuumParams *params) ...@@ -1742,10 +1742,10 @@ vacuum_rel(Oid relid, RangeVar *relation, VacuumParams *params)
* might appear to go backwards, which is probably Not Good. * might appear to go backwards, which is probably Not Good.
*/ */
LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE); LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE);
MyProc->vacuumFlags |= PROC_IN_VACUUM; MyProc->statusFlags |= PROC_IN_VACUUM;
if (params->is_wraparound) if (params->is_wraparound)
MyProc->vacuumFlags |= PROC_VACUUM_FOR_WRAPAROUND; MyProc->statusFlags |= PROC_VACUUM_FOR_WRAPAROUND;
ProcGlobal->vacuumFlags[MyProc->pgxactoff] = MyProc->vacuumFlags; ProcGlobal->statusFlags[MyProc->pgxactoff] = MyProc->statusFlags;
LWLockRelease(ProcArrayLock); LWLockRelease(ProcArrayLock);
} }
......
...@@ -2509,7 +2509,7 @@ do_autovacuum(void) ...@@ -2509,7 +2509,7 @@ do_autovacuum(void)
tab->at_datname, tab->at_nspname, tab->at_relname); tab->at_datname, tab->at_nspname, tab->at_relname);
EmitErrorReport(); EmitErrorReport();
/* this resets ProcGlobal->vacuumFlags[i] too */ /* this resets ProcGlobal->statusFlags[i] too */
AbortOutOfAnyTransaction(); AbortOutOfAnyTransaction();
FlushErrorState(); FlushErrorState();
MemoryContextResetAndDeleteChildren(PortalContext); MemoryContextResetAndDeleteChildren(PortalContext);
...@@ -2525,7 +2525,7 @@ do_autovacuum(void) ...@@ -2525,7 +2525,7 @@ do_autovacuum(void)
did_vacuum = true; did_vacuum = true;
/* ProcGlobal->vacuumFlags[i] are reset at the next end of xact */ /* ProcGlobal->statusFlags[i] are reset at the next end of xact */
/* be tidy */ /* be tidy */
deleted: deleted:
...@@ -2702,7 +2702,7 @@ perform_work_item(AutoVacuumWorkItem *workitem) ...@@ -2702,7 +2702,7 @@ perform_work_item(AutoVacuumWorkItem *workitem)
cur_datname, cur_nspname, cur_relname); cur_datname, cur_nspname, cur_relname);
EmitErrorReport(); EmitErrorReport();
/* this resets ProcGlobal->vacuumFlags[i] too */ /* this resets ProcGlobal->statusFlags[i] too */
AbortOutOfAnyTransaction(); AbortOutOfAnyTransaction();
FlushErrorState(); FlushErrorState();
MemoryContextResetAndDeleteChildren(PortalContext); MemoryContextResetAndDeleteChildren(PortalContext);
......
...@@ -182,8 +182,8 @@ StartupDecodingContext(List *output_plugin_options, ...@@ -182,8 +182,8 @@ StartupDecodingContext(List *output_plugin_options,
if (!IsTransactionOrTransactionBlock()) if (!IsTransactionOrTransactionBlock())
{ {
LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE); LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE);
MyProc->vacuumFlags |= PROC_IN_LOGICAL_DECODING; MyProc->statusFlags |= PROC_IN_LOGICAL_DECODING;
ProcGlobal->vacuumFlags[MyProc->pgxactoff] = MyProc->vacuumFlags; ProcGlobal->statusFlags[MyProc->pgxactoff] = MyProc->statusFlags;
LWLockRelease(ProcArrayLock); LWLockRelease(ProcArrayLock);
} }
......
...@@ -528,8 +528,8 @@ ReplicationSlotRelease(void) ...@@ -528,8 +528,8 @@ ReplicationSlotRelease(void)
/* might not have been set when we've been a plain slot */ /* might not have been set when we've been a plain slot */
LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE); LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE);
MyProc->vacuumFlags &= ~PROC_IN_LOGICAL_DECODING; MyProc->statusFlags &= ~PROC_IN_LOGICAL_DECODING;
ProcGlobal->vacuumFlags[MyProc->pgxactoff] = MyProc->vacuumFlags; ProcGlobal->statusFlags[MyProc->pgxactoff] = MyProc->statusFlags;
LWLockRelease(ProcArrayLock); LWLockRelease(ProcArrayLock);
} }
......
...@@ -488,13 +488,13 @@ ProcArrayAdd(PGPROC *proc) ...@@ -488,13 +488,13 @@ ProcArrayAdd(PGPROC *proc)
(arrayP->numProcs - index) * sizeof(*ProcGlobal->xids)); (arrayP->numProcs - index) * sizeof(*ProcGlobal->xids));
memmove(&ProcGlobal->subxidStates[index + 1], &ProcGlobal->subxidStates[index], memmove(&ProcGlobal->subxidStates[index + 1], &ProcGlobal->subxidStates[index],
(arrayP->numProcs - index) * sizeof(*ProcGlobal->subxidStates)); (arrayP->numProcs - index) * sizeof(*ProcGlobal->subxidStates));
memmove(&ProcGlobal->vacuumFlags[index + 1], &ProcGlobal->vacuumFlags[index], memmove(&ProcGlobal->statusFlags[index + 1], &ProcGlobal->statusFlags[index],
(arrayP->numProcs - index) * sizeof(*ProcGlobal->vacuumFlags)); (arrayP->numProcs - index) * sizeof(*ProcGlobal->statusFlags));
arrayP->pgprocnos[index] = proc->pgprocno; arrayP->pgprocnos[index] = proc->pgprocno;
ProcGlobal->xids[index] = proc->xid; ProcGlobal->xids[index] = proc->xid;
ProcGlobal->subxidStates[index] = proc->subxidStatus; ProcGlobal->subxidStates[index] = proc->subxidStatus;
ProcGlobal->vacuumFlags[index] = proc->vacuumFlags; ProcGlobal->statusFlags[index] = proc->statusFlags;
arrayP->numProcs++; arrayP->numProcs++;
...@@ -562,7 +562,7 @@ ProcArrayRemove(PGPROC *proc, TransactionId latestXid) ...@@ -562,7 +562,7 @@ ProcArrayRemove(PGPROC *proc, TransactionId latestXid)
Assert(TransactionIdIsValid(ProcGlobal->xids[proc->pgxactoff] == 0)); Assert(TransactionIdIsValid(ProcGlobal->xids[proc->pgxactoff] == 0));
Assert(TransactionIdIsValid(ProcGlobal->subxidStates[proc->pgxactoff].count == 0)); Assert(TransactionIdIsValid(ProcGlobal->subxidStates[proc->pgxactoff].count == 0));
Assert(TransactionIdIsValid(ProcGlobal->subxidStates[proc->pgxactoff].overflowed == false)); Assert(TransactionIdIsValid(ProcGlobal->subxidStates[proc->pgxactoff].overflowed == false));
ProcGlobal->vacuumFlags[proc->pgxactoff] = 0; ProcGlobal->statusFlags[proc->pgxactoff] = 0;
for (index = 0; index < arrayP->numProcs; index++) for (index = 0; index < arrayP->numProcs; index++)
{ {
...@@ -575,8 +575,8 @@ ProcArrayRemove(PGPROC *proc, TransactionId latestXid) ...@@ -575,8 +575,8 @@ ProcArrayRemove(PGPROC *proc, TransactionId latestXid)
(arrayP->numProcs - index - 1) * sizeof(*ProcGlobal->xids)); (arrayP->numProcs - index - 1) * sizeof(*ProcGlobal->xids));
memmove(&ProcGlobal->subxidStates[index], &ProcGlobal->subxidStates[index + 1], memmove(&ProcGlobal->subxidStates[index], &ProcGlobal->subxidStates[index + 1],
(arrayP->numProcs - index - 1) * sizeof(*ProcGlobal->subxidStates)); (arrayP->numProcs - index - 1) * sizeof(*ProcGlobal->subxidStates));
memmove(&ProcGlobal->vacuumFlags[index], &ProcGlobal->vacuumFlags[index + 1], memmove(&ProcGlobal->statusFlags[index], &ProcGlobal->statusFlags[index + 1],
(arrayP->numProcs - index - 1) * sizeof(*ProcGlobal->vacuumFlags)); (arrayP->numProcs - index - 1) * sizeof(*ProcGlobal->statusFlags));
arrayP->pgprocnos[arrayP->numProcs - 1] = -1; /* for debugging */ arrayP->pgprocnos[arrayP->numProcs - 1] = -1; /* for debugging */
arrayP->numProcs--; arrayP->numProcs--;
...@@ -660,13 +660,13 @@ ProcArrayEndTransaction(PGPROC *proc, TransactionId latestXid) ...@@ -660,13 +660,13 @@ ProcArrayEndTransaction(PGPROC *proc, TransactionId latestXid)
/* must be cleared with xid/xmin: */ /* must be cleared with xid/xmin: */
/* avoid unnecessarily dirtying shared cachelines */ /* avoid unnecessarily dirtying shared cachelines */
if (proc->vacuumFlags & PROC_VACUUM_STATE_MASK) if (proc->statusFlags & PROC_VACUUM_STATE_MASK)
{ {
Assert(!LWLockHeldByMe(ProcArrayLock)); Assert(!LWLockHeldByMe(ProcArrayLock));
LWLockAcquire(ProcArrayLock, LW_SHARED); LWLockAcquire(ProcArrayLock, LW_SHARED);
Assert(proc->vacuumFlags == ProcGlobal->vacuumFlags[proc->pgxactoff]); Assert(proc->statusFlags == ProcGlobal->statusFlags[proc->pgxactoff]);
proc->vacuumFlags &= ~PROC_VACUUM_STATE_MASK; proc->statusFlags &= ~PROC_VACUUM_STATE_MASK;
ProcGlobal->vacuumFlags[proc->pgxactoff] = proc->vacuumFlags; ProcGlobal->statusFlags[proc->pgxactoff] = proc->statusFlags;
LWLockRelease(ProcArrayLock); LWLockRelease(ProcArrayLock);
} }
} }
...@@ -695,10 +695,10 @@ ProcArrayEndTransactionInternal(PGPROC *proc, TransactionId latestXid) ...@@ -695,10 +695,10 @@ ProcArrayEndTransactionInternal(PGPROC *proc, TransactionId latestXid)
/* must be cleared with xid/xmin: */ /* must be cleared with xid/xmin: */
/* avoid unnecessarily dirtying shared cachelines */ /* avoid unnecessarily dirtying shared cachelines */
if (proc->vacuumFlags & PROC_VACUUM_STATE_MASK) if (proc->statusFlags & PROC_VACUUM_STATE_MASK)
{ {
proc->vacuumFlags &= ~PROC_VACUUM_STATE_MASK; proc->statusFlags &= ~PROC_VACUUM_STATE_MASK;
ProcGlobal->vacuumFlags[proc->pgxactoff] = proc->vacuumFlags; ProcGlobal->statusFlags[proc->pgxactoff] = proc->statusFlags;
} }
/* Clear the subtransaction-XID cache too while holding the lock */ /* Clear the subtransaction-XID cache too while holding the lock */
...@@ -875,7 +875,7 @@ ProcArrayClearTransaction(PGPROC *proc) ...@@ -875,7 +875,7 @@ ProcArrayClearTransaction(PGPROC *proc)
proc->xmin = InvalidTransactionId; proc->xmin = InvalidTransactionId;
proc->recoveryConflictPending = false; proc->recoveryConflictPending = false;
Assert(!(proc->vacuumFlags & PROC_VACUUM_STATE_MASK)); Assert(!(proc->statusFlags & PROC_VACUUM_STATE_MASK));
Assert(!proc->delayChkpt); Assert(!proc->delayChkpt);
/* /*
...@@ -1710,7 +1710,7 @@ ComputeXidHorizons(ComputeXidHorizonsResult *h) ...@@ -1710,7 +1710,7 @@ ComputeXidHorizons(ComputeXidHorizonsResult *h)
{ {
int pgprocno = arrayP->pgprocnos[index]; int pgprocno = arrayP->pgprocnos[index];
PGPROC *proc = &allProcs[pgprocno]; PGPROC *proc = &allProcs[pgprocno];
int8 vacuumFlags = ProcGlobal->vacuumFlags[index]; int8 statusFlags = ProcGlobal->statusFlags[index];
TransactionId xid; TransactionId xid;
TransactionId xmin; TransactionId xmin;
...@@ -1745,7 +1745,7 @@ ComputeXidHorizons(ComputeXidHorizonsResult *h) ...@@ -1745,7 +1745,7 @@ ComputeXidHorizons(ComputeXidHorizonsResult *h)
* removed, as long as pg_subtrans is not truncated) or doing logical * removed, as long as pg_subtrans is not truncated) or doing logical
* decoding (which manages xmin separately, check below). * decoding (which manages xmin separately, check below).
*/ */
if (vacuumFlags & (PROC_IN_VACUUM | PROC_IN_LOGICAL_DECODING)) if (statusFlags & (PROC_IN_VACUUM | PROC_IN_LOGICAL_DECODING))
continue; continue;
/* shared tables need to take backends in all database into account */ /* shared tables need to take backends in all database into account */
...@@ -2194,7 +2194,7 @@ GetSnapshotData(Snapshot snapshot) ...@@ -2194,7 +2194,7 @@ GetSnapshotData(Snapshot snapshot)
TransactionId *xip = snapshot->xip; TransactionId *xip = snapshot->xip;
int *pgprocnos = arrayP->pgprocnos; int *pgprocnos = arrayP->pgprocnos;
XidCacheStatus *subxidStates = ProcGlobal->subxidStates; XidCacheStatus *subxidStates = ProcGlobal->subxidStates;
uint8 *allVacuumFlags = ProcGlobal->vacuumFlags; uint8 *allStatusFlags = ProcGlobal->statusFlags;
/* /*
* First collect set of pgxactoff/xids that need to be included in the * First collect set of pgxactoff/xids that need to be included in the
...@@ -2204,7 +2204,7 @@ GetSnapshotData(Snapshot snapshot) ...@@ -2204,7 +2204,7 @@ GetSnapshotData(Snapshot snapshot)
{ {
/* Fetch xid just once - see GetNewTransactionId */ /* Fetch xid just once - see GetNewTransactionId */
TransactionId xid = UINT32_ACCESS_ONCE(other_xids[pgxactoff]); TransactionId xid = UINT32_ACCESS_ONCE(other_xids[pgxactoff]);
uint8 vacuumFlags; uint8 statusFlags;
Assert(allProcs[arrayP->pgprocnos[pgxactoff]].pgxactoff == pgxactoff); Assert(allProcs[arrayP->pgprocnos[pgxactoff]].pgxactoff == pgxactoff);
...@@ -2243,8 +2243,8 @@ GetSnapshotData(Snapshot snapshot) ...@@ -2243,8 +2243,8 @@ GetSnapshotData(Snapshot snapshot)
* Skip over backends doing logical decoding which manages xmin * Skip over backends doing logical decoding which manages xmin
* separately (check below) and ones running LAZY VACUUM. * separately (check below) and ones running LAZY VACUUM.
*/ */
vacuumFlags = allVacuumFlags[pgxactoff]; statusFlags = allStatusFlags[pgxactoff];
if (vacuumFlags & (PROC_IN_LOGICAL_DECODING | PROC_IN_VACUUM)) if (statusFlags & (PROC_IN_LOGICAL_DECODING | PROC_IN_VACUUM))
continue; continue;
if (NormalTransactionIdPrecedes(xid, xmin)) if (NormalTransactionIdPrecedes(xid, xmin))
...@@ -2483,11 +2483,11 @@ ProcArrayInstallImportedXmin(TransactionId xmin, ...@@ -2483,11 +2483,11 @@ ProcArrayInstallImportedXmin(TransactionId xmin,
{ {
int pgprocno = arrayP->pgprocnos[index]; int pgprocno = arrayP->pgprocnos[index];
PGPROC *proc = &allProcs[pgprocno]; PGPROC *proc = &allProcs[pgprocno];
int vacuumFlags = ProcGlobal->vacuumFlags[index]; int statusFlags = ProcGlobal->statusFlags[index];
TransactionId xid; TransactionId xid;
/* Ignore procs running LAZY VACUUM */ /* Ignore procs running LAZY VACUUM */
if (vacuumFlags & PROC_IN_VACUUM) if (statusFlags & PROC_IN_VACUUM)
continue; continue;
/* We are only interested in the specific virtual transaction. */ /* We are only interested in the specific virtual transaction. */
...@@ -3142,7 +3142,7 @@ IsBackendPid(int pid) ...@@ -3142,7 +3142,7 @@ IsBackendPid(int pid)
* If excludeXmin0 is true, skip processes with xmin = 0. * If excludeXmin0 is true, skip processes with xmin = 0.
* If allDbs is false, skip processes attached to other databases. * If allDbs is false, skip processes attached to other databases.
* If excludeVacuum isn't zero, skip processes for which * If excludeVacuum isn't zero, skip processes for which
* (vacuumFlags & excludeVacuum) is not zero. * (statusFlags & excludeVacuum) is not zero.
* *
* Note: the purpose of the limitXmin and excludeXmin0 parameters is to * Note: the purpose of the limitXmin and excludeXmin0 parameters is to
* allow skipping backends whose oldest live snapshot is no older than * allow skipping backends whose oldest live snapshot is no older than
...@@ -3176,12 +3176,12 @@ GetCurrentVirtualXIDs(TransactionId limitXmin, bool excludeXmin0, ...@@ -3176,12 +3176,12 @@ GetCurrentVirtualXIDs(TransactionId limitXmin, bool excludeXmin0,
{ {
int pgprocno = arrayP->pgprocnos[index]; int pgprocno = arrayP->pgprocnos[index];
PGPROC *proc = &allProcs[pgprocno]; PGPROC *proc = &allProcs[pgprocno];
uint8 vacuumFlags = ProcGlobal->vacuumFlags[index]; uint8 statusFlags = ProcGlobal->statusFlags[index];
if (proc == MyProc) if (proc == MyProc)
continue; continue;
if (excludeVacuum & vacuumFlags) if (excludeVacuum & statusFlags)
continue; continue;
if (allDbs || proc->databaseId == MyDatabaseId) if (allDbs || proc->databaseId == MyDatabaseId)
...@@ -3596,7 +3596,7 @@ CountOtherDBBackends(Oid databaseId, int *nbackends, int *nprepared) ...@@ -3596,7 +3596,7 @@ CountOtherDBBackends(Oid databaseId, int *nbackends, int *nprepared)
{ {
int pgprocno = arrayP->pgprocnos[index]; int pgprocno = arrayP->pgprocnos[index];
PGPROC *proc = &allProcs[pgprocno]; PGPROC *proc = &allProcs[pgprocno];
uint8 vacuumFlags = ProcGlobal->vacuumFlags[index]; uint8 statusFlags = ProcGlobal->statusFlags[index];
if (proc->databaseId != databaseId) if (proc->databaseId != databaseId)
continue; continue;
...@@ -3610,7 +3610,7 @@ CountOtherDBBackends(Oid databaseId, int *nbackends, int *nprepared) ...@@ -3610,7 +3610,7 @@ CountOtherDBBackends(Oid databaseId, int *nbackends, int *nprepared)
else else
{ {
(*nbackends)++; (*nbackends)++;
if ((vacuumFlags & PROC_IS_AUTOVACUUM) && if ((statusFlags & PROC_IS_AUTOVACUUM) &&
nautovacs < MAXAUTOVACPIDS) nautovacs < MAXAUTOVACPIDS)
autovac_pids[nautovacs++] = proc->pid; autovac_pids[nautovacs++] = proc->pid;
} }
......
...@@ -618,7 +618,7 @@ FindLockCycleRecurseMember(PGPROC *checkProc, ...@@ -618,7 +618,7 @@ FindLockCycleRecurseMember(PGPROC *checkProc,
* that an autovacuum won't be canceled with less than * that an autovacuum won't be canceled with less than
* deadlock_timeout grace period. * deadlock_timeout grace period.
* *
* Note we read vacuumFlags without any locking. This is * Note we read statusFlags without any locking. This is
* OK only for checking the PROC_IS_AUTOVACUUM flag, * OK only for checking the PROC_IS_AUTOVACUUM flag,
* because that flag is set at process start and never * because that flag is set at process start and never
* reset. There is logic elsewhere to avoid canceling an * reset. There is logic elsewhere to avoid canceling an
...@@ -628,7 +628,7 @@ FindLockCycleRecurseMember(PGPROC *checkProc, ...@@ -628,7 +628,7 @@ FindLockCycleRecurseMember(PGPROC *checkProc,
* ProcArrayLock. * ProcArrayLock.
*/ */
if (checkProc == MyProc && if (checkProc == MyProc &&
proc->vacuumFlags & PROC_IS_AUTOVACUUM) proc->statusFlags & PROC_IS_AUTOVACUUM)
blocking_autovacuum_proc = proc; blocking_autovacuum_proc = proc;
/* We're done looking at this proclock */ /* We're done looking at this proclock */
......
...@@ -111,7 +111,7 @@ ProcGlobalShmemSize(void) ...@@ -111,7 +111,7 @@ ProcGlobalShmemSize(void)
size = add_size(size, mul_size(TotalProcs, sizeof(*ProcGlobal->xids))); size = add_size(size, mul_size(TotalProcs, sizeof(*ProcGlobal->xids)));
size = add_size(size, mul_size(TotalProcs, sizeof(*ProcGlobal->subxidStates))); size = add_size(size, mul_size(TotalProcs, sizeof(*ProcGlobal->subxidStates)));
size = add_size(size, mul_size(TotalProcs, sizeof(*ProcGlobal->vacuumFlags))); size = add_size(size, mul_size(TotalProcs, sizeof(*ProcGlobal->statusFlags)));
return size; return size;
} }
...@@ -210,8 +210,8 @@ InitProcGlobal(void) ...@@ -210,8 +210,8 @@ InitProcGlobal(void)
MemSet(ProcGlobal->xids, 0, TotalProcs * sizeof(*ProcGlobal->xids)); MemSet(ProcGlobal->xids, 0, TotalProcs * sizeof(*ProcGlobal->xids));
ProcGlobal->subxidStates = (XidCacheStatus *) ShmemAlloc(TotalProcs * sizeof(*ProcGlobal->subxidStates)); ProcGlobal->subxidStates = (XidCacheStatus *) ShmemAlloc(TotalProcs * sizeof(*ProcGlobal->subxidStates));
MemSet(ProcGlobal->subxidStates, 0, TotalProcs * sizeof(*ProcGlobal->subxidStates)); MemSet(ProcGlobal->subxidStates, 0, TotalProcs * sizeof(*ProcGlobal->subxidStates));
ProcGlobal->vacuumFlags = (uint8 *) ShmemAlloc(TotalProcs * sizeof(*ProcGlobal->vacuumFlags)); ProcGlobal->statusFlags = (uint8 *) ShmemAlloc(TotalProcs * sizeof(*ProcGlobal->statusFlags));
MemSet(ProcGlobal->vacuumFlags, 0, TotalProcs * sizeof(*ProcGlobal->vacuumFlags)); MemSet(ProcGlobal->statusFlags, 0, TotalProcs * sizeof(*ProcGlobal->statusFlags));
for (i = 0; i < TotalProcs; i++) for (i = 0; i < TotalProcs; i++)
{ {
...@@ -393,10 +393,10 @@ InitProcess(void) ...@@ -393,10 +393,10 @@ InitProcess(void)
MyProc->tempNamespaceId = InvalidOid; MyProc->tempNamespaceId = InvalidOid;
MyProc->isBackgroundWorker = IsBackgroundWorker; MyProc->isBackgroundWorker = IsBackgroundWorker;
MyProc->delayChkpt = false; MyProc->delayChkpt = false;
MyProc->vacuumFlags = 0; MyProc->statusFlags = 0;
/* NB -- autovac launcher intentionally does not set IS_AUTOVACUUM */ /* NB -- autovac launcher intentionally does not set IS_AUTOVACUUM */
if (IsAutoVacuumWorkerProcess()) if (IsAutoVacuumWorkerProcess())
MyProc->vacuumFlags |= PROC_IS_AUTOVACUUM; MyProc->statusFlags |= PROC_IS_AUTOVACUUM;
MyProc->lwWaiting = false; MyProc->lwWaiting = false;
MyProc->lwWaitMode = 0; MyProc->lwWaitMode = 0;
MyProc->waitLock = NULL; MyProc->waitLock = NULL;
...@@ -574,7 +574,7 @@ InitAuxiliaryProcess(void) ...@@ -574,7 +574,7 @@ InitAuxiliaryProcess(void)
MyProc->tempNamespaceId = InvalidOid; MyProc->tempNamespaceId = InvalidOid;
MyProc->isBackgroundWorker = IsBackgroundWorker; MyProc->isBackgroundWorker = IsBackgroundWorker;
MyProc->delayChkpt = false; MyProc->delayChkpt = false;
MyProc->vacuumFlags = 0; MyProc->statusFlags = 0;
MyProc->lwWaiting = false; MyProc->lwWaiting = false;
MyProc->lwWaitMode = 0; MyProc->lwWaitMode = 0;
MyProc->waitLock = NULL; MyProc->waitLock = NULL;
...@@ -1310,7 +1310,7 @@ ProcSleep(LOCALLOCK *locallock, LockMethod lockMethodTable) ...@@ -1310,7 +1310,7 @@ ProcSleep(LOCALLOCK *locallock, LockMethod lockMethodTable)
if (deadlock_state == DS_BLOCKED_BY_AUTOVACUUM && allow_autovacuum_cancel) if (deadlock_state == DS_BLOCKED_BY_AUTOVACUUM && allow_autovacuum_cancel)
{ {
PGPROC *autovac = GetBlockingAutoVacuumPgproc(); PGPROC *autovac = GetBlockingAutoVacuumPgproc();
uint8 vacuumFlags; uint8 statusFlags;
LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE); LWLockAcquire(ProcArrayLock, LW_EXCLUSIVE);
...@@ -1318,9 +1318,9 @@ ProcSleep(LOCALLOCK *locallock, LockMethod lockMethodTable) ...@@ -1318,9 +1318,9 @@ ProcSleep(LOCALLOCK *locallock, LockMethod lockMethodTable)
* Only do it if the worker is not working to protect against Xid * Only do it if the worker is not working to protect against Xid
* wraparound. * wraparound.
*/ */
vacuumFlags = ProcGlobal->vacuumFlags[autovac->pgxactoff]; statusFlags = ProcGlobal->statusFlags[autovac->pgxactoff];
if ((vacuumFlags & PROC_IS_AUTOVACUUM) && if ((statusFlags & PROC_IS_AUTOVACUUM) &&
!(vacuumFlags & PROC_VACUUM_FOR_WRAPAROUND)) !(statusFlags & PROC_VACUUM_FOR_WRAPAROUND))
{ {
int pid = autovac->pid; int pid = autovac->pid;
StringInfoData locktagbuf; StringInfoData locktagbuf;
......
...@@ -49,7 +49,7 @@ struct XidCache ...@@ -49,7 +49,7 @@ struct XidCache
}; };
/* /*
* Flags for ProcGlobal->vacuumFlags[] * Flags for PGPROC->statusFlags and PROC_HDR->statusFlags[]
*/ */
#define PROC_IS_AUTOVACUUM 0x01 /* is it an autovac worker? */ #define PROC_IS_AUTOVACUUM 0x01 /* is it an autovac worker? */
#define PROC_IN_VACUUM 0x02 /* currently running lazy vacuum */ #define PROC_IN_VACUUM 0x02 /* currently running lazy vacuum */
...@@ -175,9 +175,10 @@ struct PGPROC ...@@ -175,9 +175,10 @@ struct PGPROC
bool delayChkpt; /* true if this proc delays checkpoint start */ bool delayChkpt; /* true if this proc delays checkpoint start */
uint8 vacuumFlags; /* this backend's vacuum flags, see PROC_* uint8 statusFlags; /* this backend's status flags, see PROC_*
* above. mirrored in * above. mirrored in
* ProcGlobal->vacuumFlags[pgxactoff] */ * ProcGlobal->statusFlags[pgxactoff] */
/* /*
* Info to allow us to wait for synchronous replication, if needed. * Info to allow us to wait for synchronous replication, if needed.
* waitLSN is InvalidXLogRecPtr if not waiting; set only by user backend. * waitLSN is InvalidXLogRecPtr if not waiting; set only by user backend.
...@@ -273,7 +274,7 @@ extern PGDLLIMPORT PGPROC *MyProc; ...@@ -273,7 +274,7 @@ extern PGDLLIMPORT PGPROC *MyProc;
* allow for as tight loops accessing the data as possible. Second, to prevent * allow for as tight loops accessing the data as possible. Second, to prevent
* updates of frequently changing data (e.g. xmin) from invalidating * updates of frequently changing data (e.g. xmin) from invalidating
* cachelines also containing less frequently changing data (e.g. xid, * cachelines also containing less frequently changing data (e.g. xid,
* vacuumFlags). Third to condense frequently accessed data into as few * statusFlags). Third to condense frequently accessed data into as few
* cachelines as possible. * cachelines as possible.
* *
* There are two main reasons to have the data mirrored between these dense * There are two main reasons to have the data mirrored between these dense
...@@ -315,10 +316,10 @@ typedef struct PROC_HDR ...@@ -315,10 +316,10 @@ typedef struct PROC_HDR
XidCacheStatus *subxidStates; XidCacheStatus *subxidStates;
/* /*
* Array mirroring PGPROC.vacuumFlags for each PGPROC currently in the * Array mirroring PGPROC.statusFlags for each PGPROC currently in the
* procarray. * procarray.
*/ */
uint8 *vacuumFlags; uint8 *statusFlags;
/* Length of allProcs array */ /* Length of allProcs array */
uint32 allProcCount; uint32 allProcCount;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment