diff options
Diffstat (limited to 'src/backend/storage')
-rw-r--r-- | src/backend/storage/ipc/dsm.c | 2 | ||||
-rw-r--r-- | src/backend/storage/ipc/procarray.c | 25 | ||||
-rw-r--r-- | src/backend/storage/ipc/procsignal.c | 37 | ||||
-rw-r--r-- | src/backend/storage/ipc/sinvaladt.c | 4 | ||||
-rw-r--r-- | src/backend/storage/lmgr/deadlock.c | 31 | ||||
-rw-r--r-- | src/backend/storage/lmgr/lock.c | 22 | ||||
-rw-r--r-- | src/backend/storage/lmgr/predicate.c | 10 | ||||
-rw-r--r-- | src/backend/storage/lmgr/proc.c | 17 |
8 files changed, 85 insertions, 63 deletions
diff --git a/src/backend/storage/ipc/dsm.c b/src/backend/storage/ipc/dsm.c index ae751415925..e9e9fae3eb9 100644 --- a/src/backend/storage/ipc/dsm.c +++ b/src/backend/storage/ipc/dsm.c @@ -166,7 +166,7 @@ dsm_postmaster_startup(PGShmemHeader *shim) /* Determine size for new control segment. */ maxitems = PG_DYNSHMEM_FIXED_SLOTS - + PG_DYNSHMEM_SLOTS_PER_BACKEND * MaxBackends; + + PG_DYNSHMEM_SLOTS_PER_BACKEND * GetMaxBackends(); elog(DEBUG2, "dynamic shared memory system will support %u segments", maxitems); segsize = dsm_control_bytes_needed(maxitems); diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c index 9d3efb7d80e..13d192ec2b4 100644 --- a/src/backend/storage/ipc/procarray.c +++ b/src/backend/storage/ipc/procarray.c @@ -97,7 +97,7 @@ typedef struct ProcArrayStruct /* oldest catalog xmin of any replication slot */ TransactionId replication_slot_catalog_xmin; - /* indexes into allProcs[], has PROCARRAY_MAXPROCS entries */ + /* indexes into allProcs[], has ProcArrayMaxProcs entries */ int pgprocnos[FLEXIBLE_ARRAY_MEMBER]; } ProcArrayStruct; @@ -355,6 +355,17 @@ static void MaintainLatestCompletedXidRecovery(TransactionId latestXid); static inline FullTransactionId FullXidRelativeTo(FullTransactionId rel, TransactionId xid); static void GlobalVisUpdateApply(ComputeXidHorizonsResult *horizons); +static inline int GetProcArrayMaxProcs(void); + + +/* + * Retrieve the number of slots in the ProcArray structure. + */ +static inline int +GetProcArrayMaxProcs(void) +{ + return GetMaxBackends() + max_prepared_xacts; +} /* * Report shared-memory space needed by CreateSharedProcArray. @@ -365,10 +376,8 @@ ProcArrayShmemSize(void) Size size; /* Size of the ProcArray structure itself */ -#define PROCARRAY_MAXPROCS (MaxBackends + max_prepared_xacts) - size = offsetof(ProcArrayStruct, pgprocnos); - size = add_size(size, mul_size(sizeof(int), PROCARRAY_MAXPROCS)); + size = add_size(size, mul_size(sizeof(int), GetProcArrayMaxProcs())); /* * During Hot Standby processing we have a data structure called @@ -384,7 +393,7 @@ ProcArrayShmemSize(void) * shared memory is being set up. */ #define TOTAL_MAX_CACHED_SUBXIDS \ - ((PGPROC_MAX_CACHED_SUBXIDS + 1) * PROCARRAY_MAXPROCS) + ((PGPROC_MAX_CACHED_SUBXIDS + 1) * GetProcArrayMaxProcs()) if (EnableHotStandby) { @@ -411,7 +420,7 @@ CreateSharedProcArray(void) ShmemInitStruct("Proc Array", add_size(offsetof(ProcArrayStruct, pgprocnos), mul_size(sizeof(int), - PROCARRAY_MAXPROCS)), + GetProcArrayMaxProcs())), &found); if (!found) @@ -420,7 +429,7 @@ CreateSharedProcArray(void) * We're the first - initialize. */ procArray->numProcs = 0; - procArray->maxProcs = PROCARRAY_MAXPROCS; + procArray->maxProcs = GetProcArrayMaxProcs(); procArray->maxKnownAssignedXids = TOTAL_MAX_CACHED_SUBXIDS; procArray->numKnownAssignedXids = 0; procArray->tailKnownAssignedXids = 0; @@ -4623,7 +4632,7 @@ KnownAssignedXidsCompress(bool force) */ int nelements = head - tail; - if (nelements < 4 * PROCARRAY_MAXPROCS || + if (nelements < 4 * GetProcArrayMaxProcs() || nelements < 2 * pArray->numKnownAssignedXids) return; } diff --git a/src/backend/storage/ipc/procsignal.c b/src/backend/storage/ipc/procsignal.c index f1c8ff8f9e4..d158bb7a19f 100644 --- a/src/backend/storage/ipc/procsignal.c +++ b/src/backend/storage/ipc/procsignal.c @@ -80,13 +80,6 @@ typedef struct ProcSignalSlot psh_slot[FLEXIBLE_ARRAY_MEMBER]; } ProcSignalHeader; -/* - * We reserve a slot for each possible BackendId, plus one for each - * possible auxiliary process type. (This scheme assumes there is not - * more than one of any auxiliary process type at a time.) - */ -#define NumProcSignalSlots (MaxBackends + NUM_AUXPROCTYPES) - /* Check whether the relevant type bit is set in the flags. */ #define BARRIER_SHOULD_CHECK(flags, type) \ (((flags) & (((uint32) 1) << (uint32) (type))) != 0) @@ -102,6 +95,20 @@ static bool CheckProcSignal(ProcSignalReason reason); static void CleanupProcSignalState(int status, Datum arg); static void ResetProcSignalBarrierBits(uint32 flags); static bool ProcessBarrierPlaceholder(void); +static inline int GetNumProcSignalSlots(void); + +/* + * GetNumProcSignalSlots + * + * We reserve a slot for each possible BackendId, plus one for each possible + * auxiliary process type. (This scheme assume there is not more than one of + * any auxiliary process type at a time.) + */ +static inline int +GetNumProcSignalSlots(void) +{ + return GetMaxBackends() + NUM_AUXPROCTYPES; +} /* * ProcSignalShmemSize @@ -112,7 +119,7 @@ ProcSignalShmemSize(void) { Size size; - size = mul_size(NumProcSignalSlots, sizeof(ProcSignalSlot)); + size = mul_size(GetNumProcSignalSlots(), sizeof(ProcSignalSlot)); size = add_size(size, offsetof(ProcSignalHeader, psh_slot)); return size; } @@ -126,6 +133,7 @@ ProcSignalShmemInit(void) { Size size = ProcSignalShmemSize(); bool found; + int numProcSignalSlots = GetNumProcSignalSlots(); ProcSignal = (ProcSignalHeader *) ShmemInitStruct("ProcSignal", size, &found); @@ -137,7 +145,7 @@ ProcSignalShmemInit(void) pg_atomic_init_u64(&ProcSignal->psh_barrierGeneration, 0); - for (i = 0; i < NumProcSignalSlots; ++i) + for (i = 0; i < numProcSignalSlots; ++i) { ProcSignalSlot *slot = &ProcSignal->psh_slot[i]; @@ -163,7 +171,7 @@ ProcSignalInit(int pss_idx) ProcSignalSlot *slot; uint64 barrier_generation; - Assert(pss_idx >= 1 && pss_idx <= NumProcSignalSlots); + Assert(pss_idx >= 1 && pss_idx <= GetNumProcSignalSlots()); slot = &ProcSignal->psh_slot[pss_idx - 1]; @@ -292,7 +300,7 @@ SendProcSignal(pid_t pid, ProcSignalReason reason, BackendId backendId) */ int i; - for (i = NumProcSignalSlots - 1; i >= 0; i--) + for (i = GetNumProcSignalSlots() - 1; i >= 0; i--) { slot = &ProcSignal->psh_slot[i]; @@ -333,6 +341,7 @@ EmitProcSignalBarrier(ProcSignalBarrierType type) { uint32 flagbit = 1 << (uint32) type; uint64 generation; + int numProcSignalSlots = GetNumProcSignalSlots(); /* * Set all the flags. @@ -342,7 +351,7 @@ EmitProcSignalBarrier(ProcSignalBarrierType type) * anything that we do afterwards. (This is also true of the later call to * pg_atomic_add_fetch_u64.) */ - for (int i = 0; i < NumProcSignalSlots; i++) + for (int i = 0; i < numProcSignalSlots; i++) { volatile ProcSignalSlot *slot = &ProcSignal->psh_slot[i]; @@ -368,7 +377,7 @@ EmitProcSignalBarrier(ProcSignalBarrierType type) * backends that need to update state - but they won't actually need to * change any state. */ - for (int i = NumProcSignalSlots - 1; i >= 0; i--) + for (int i = numProcSignalSlots - 1; i >= 0; i--) { volatile ProcSignalSlot *slot = &ProcSignal->psh_slot[i]; pid_t pid = slot->pss_pid; @@ -393,7 +402,7 @@ WaitForProcSignalBarrier(uint64 generation) { Assert(generation <= pg_atomic_read_u64(&ProcSignal->psh_barrierGeneration)); - for (int i = NumProcSignalSlots - 1; i >= 0; i--) + for (int i = GetNumProcSignalSlots() - 1; i >= 0; i--) { ProcSignalSlot *slot = &ProcSignal->psh_slot[i]; uint64 oldval; diff --git a/src/backend/storage/ipc/sinvaladt.c b/src/backend/storage/ipc/sinvaladt.c index cb3ee820460..68e7160b30e 100644 --- a/src/backend/storage/ipc/sinvaladt.c +++ b/src/backend/storage/ipc/sinvaladt.c @@ -205,7 +205,7 @@ SInvalShmemSize(void) Size size; size = offsetof(SISeg, procState); - size = add_size(size, mul_size(sizeof(ProcState), MaxBackends)); + size = add_size(size, mul_size(sizeof(ProcState), GetMaxBackends())); return size; } @@ -231,7 +231,7 @@ CreateSharedInvalidationState(void) shmInvalBuffer->maxMsgNum = 0; shmInvalBuffer->nextThreshold = CLEANUP_MIN; shmInvalBuffer->lastBackend = 0; - shmInvalBuffer->maxBackends = MaxBackends; + shmInvalBuffer->maxBackends = GetMaxBackends(); SpinLockInit(&shmInvalBuffer->msgnumLock); /* The buffer[] array is initially all unused, so we need not fill it */ diff --git a/src/backend/storage/lmgr/deadlock.c b/src/backend/storage/lmgr/deadlock.c index cd9c0418eca..b5d539ba5d9 100644 --- a/src/backend/storage/lmgr/deadlock.c +++ b/src/backend/storage/lmgr/deadlock.c @@ -143,6 +143,7 @@ void InitDeadLockChecking(void) { MemoryContext oldcxt; + int max_backends = GetMaxBackends(); /* Make sure allocations are permanent */ oldcxt = MemoryContextSwitchTo(TopMemoryContext); @@ -151,16 +152,16 @@ InitDeadLockChecking(void) * FindLockCycle needs at most MaxBackends entries in visitedProcs[] and * deadlockDetails[]. */ - visitedProcs = (PGPROC **) palloc(MaxBackends * sizeof(PGPROC *)); - deadlockDetails = (DEADLOCK_INFO *) palloc(MaxBackends * sizeof(DEADLOCK_INFO)); + visitedProcs = (PGPROC **) palloc(max_backends * sizeof(PGPROC *)); + deadlockDetails = (DEADLOCK_INFO *) palloc(max_backends * sizeof(DEADLOCK_INFO)); /* * TopoSort needs to consider at most MaxBackends wait-queue entries, and * it needn't run concurrently with FindLockCycle. */ topoProcs = visitedProcs; /* re-use this space */ - beforeConstraints = (int *) palloc(MaxBackends * sizeof(int)); - afterConstraints = (int *) palloc(MaxBackends * sizeof(int)); + beforeConstraints = (int *) palloc(max_backends * sizeof(int)); + afterConstraints = (int *) palloc(max_backends * sizeof(int)); /* * We need to consider rearranging at most MaxBackends/2 wait queues @@ -169,8 +170,8 @@ InitDeadLockChecking(void) * MaxBackends total waiters. */ waitOrders = (WAIT_ORDER *) - palloc((MaxBackends / 2) * sizeof(WAIT_ORDER)); - waitOrderProcs = (PGPROC **) palloc(MaxBackends * sizeof(PGPROC *)); + palloc((max_backends / 2) * sizeof(WAIT_ORDER)); + waitOrderProcs = (PGPROC **) palloc(max_backends * sizeof(PGPROC *)); /* * Allow at most MaxBackends distinct constraints in a configuration. (Is @@ -180,7 +181,7 @@ InitDeadLockChecking(void) * limits the maximum recursion depth of DeadLockCheckRecurse. Making it * really big might potentially allow a stack-overflow problem. */ - maxCurConstraints = MaxBackends; + maxCurConstraints = max_backends; curConstraints = (EDGE *) palloc(maxCurConstraints * sizeof(EDGE)); /* @@ -191,7 +192,7 @@ InitDeadLockChecking(void) * last MaxBackends entries in possibleConstraints[] are reserved as * output workspace for FindLockCycle. */ - maxPossibleConstraints = MaxBackends * 4; + maxPossibleConstraints = max_backends * 4; possibleConstraints = (EDGE *) palloc(maxPossibleConstraints * sizeof(EDGE)); @@ -327,7 +328,7 @@ DeadLockCheckRecurse(PGPROC *proc) if (nCurConstraints >= maxCurConstraints) return true; /* out of room for active constraints? */ oldPossibleConstraints = nPossibleConstraints; - if (nPossibleConstraints + nEdges + MaxBackends <= maxPossibleConstraints) + if (nPossibleConstraints + nEdges + GetMaxBackends() <= maxPossibleConstraints) { /* We can save the edge list in possibleConstraints[] */ nPossibleConstraints += nEdges; @@ -388,7 +389,7 @@ TestConfiguration(PGPROC *startProc) /* * Make sure we have room for FindLockCycle's output. */ - if (nPossibleConstraints + MaxBackends > maxPossibleConstraints) + if (nPossibleConstraints + GetMaxBackends() > maxPossibleConstraints) return -1; /* @@ -486,7 +487,7 @@ FindLockCycleRecurse(PGPROC *checkProc, * record total length of cycle --- outer levels will now fill * deadlockDetails[] */ - Assert(depth <= MaxBackends); + Assert(depth <= GetMaxBackends()); nDeadlockDetails = depth; return true; @@ -500,7 +501,7 @@ FindLockCycleRecurse(PGPROC *checkProc, } } /* Mark proc as seen */ - Assert(nVisitedProcs < MaxBackends); + Assert(nVisitedProcs < GetMaxBackends()); visitedProcs[nVisitedProcs++] = checkProc; /* @@ -698,7 +699,7 @@ FindLockCycleRecurseMember(PGPROC *checkProc, /* * Add this edge to the list of soft edges in the cycle */ - Assert(*nSoftEdges < MaxBackends); + Assert(*nSoftEdges < GetMaxBackends()); softEdges[*nSoftEdges].waiter = checkProcLeader; softEdges[*nSoftEdges].blocker = leader; softEdges[*nSoftEdges].lock = lock; @@ -771,7 +772,7 @@ FindLockCycleRecurseMember(PGPROC *checkProc, /* * Add this edge to the list of soft edges in the cycle */ - Assert(*nSoftEdges < MaxBackends); + Assert(*nSoftEdges < GetMaxBackends()); softEdges[*nSoftEdges].waiter = checkProcLeader; softEdges[*nSoftEdges].blocker = leader; softEdges[*nSoftEdges].lock = lock; @@ -834,7 +835,7 @@ ExpandConstraints(EDGE *constraints, waitOrders[nWaitOrders].procs = waitOrderProcs + nWaitOrderProcs; waitOrders[nWaitOrders].nProcs = lock->waitProcs.size; nWaitOrderProcs += lock->waitProcs.size; - Assert(nWaitOrderProcs <= MaxBackends); + Assert(nWaitOrderProcs <= GetMaxBackends()); /* * Do the topo sort. TopoSort need not examine constraints after this diff --git a/src/backend/storage/lmgr/lock.c b/src/backend/storage/lmgr/lock.c index 5f5803f6814..1528d788d0a 100644 --- a/src/backend/storage/lmgr/lock.c +++ b/src/backend/storage/lmgr/lock.c @@ -55,7 +55,7 @@ int max_locks_per_xact; /* set by guc.c */ #define NLOCKENTS() \ - mul_size(max_locks_per_xact, add_size(MaxBackends, max_prepared_xacts)) + mul_size(max_locks_per_xact, add_size(GetMaxBackends(), max_prepared_xacts)) /* @@ -2942,12 +2942,12 @@ GetLockConflicts(const LOCKTAG *locktag, LOCKMODE lockmode, int *countp) vxids = (VirtualTransactionId *) MemoryContextAlloc(TopMemoryContext, sizeof(VirtualTransactionId) * - (MaxBackends + max_prepared_xacts + 1)); + (GetMaxBackends() + max_prepared_xacts + 1)); } else vxids = (VirtualTransactionId *) palloc0(sizeof(VirtualTransactionId) * - (MaxBackends + max_prepared_xacts + 1)); + (GetMaxBackends() + max_prepared_xacts + 1)); /* Compute hash code and partition lock, and look up conflicting modes. */ hashcode = LockTagHashCode(locktag); @@ -3104,7 +3104,7 @@ GetLockConflicts(const LOCKTAG *locktag, LOCKMODE lockmode, int *countp) LWLockRelease(partitionLock); - if (count > MaxBackends + max_prepared_xacts) /* should never happen */ + if (count > GetMaxBackends() + max_prepared_xacts) /* should never happen */ elog(PANIC, "too many conflicting locks found"); vxids[count].backendId = InvalidBackendId; @@ -3651,11 +3651,12 @@ GetLockStatusData(void) int els; int el; int i; + int max_backends = GetMaxBackends(); data = (LockData *) palloc(sizeof(LockData)); /* Guess how much space we'll need. */ - els = MaxBackends; + els = max_backends; el = 0; data->locks = (LockInstanceData *) palloc(sizeof(LockInstanceData) * els); @@ -3689,7 +3690,7 @@ GetLockStatusData(void) if (el >= els) { - els += MaxBackends; + els += max_backends; data->locks = (LockInstanceData *) repalloc(data->locks, sizeof(LockInstanceData) * els); } @@ -3721,7 +3722,7 @@ GetLockStatusData(void) if (el >= els) { - els += MaxBackends; + els += max_backends; data->locks = (LockInstanceData *) repalloc(data->locks, sizeof(LockInstanceData) * els); } @@ -3850,7 +3851,7 @@ GetBlockerStatusData(int blocked_pid) * for the procs[] array; the other two could need enlargement, though.) */ data->nprocs = data->nlocks = data->npids = 0; - data->maxprocs = data->maxlocks = data->maxpids = MaxBackends; + data->maxprocs = data->maxlocks = data->maxpids = GetMaxBackends(); data->procs = (BlockedProcData *) palloc(sizeof(BlockedProcData) * data->maxprocs); data->locks = (LockInstanceData *) palloc(sizeof(LockInstanceData) * data->maxlocks); data->waiter_pids = (int *) palloc(sizeof(int) * data->maxpids); @@ -3925,6 +3926,7 @@ GetSingleProcBlockerStatusData(PGPROC *blocked_proc, BlockedProcsData *data) PGPROC *proc; int queue_size; int i; + int max_backends = GetMaxBackends(); /* Nothing to do if this proc is not blocked */ if (theLock == NULL) @@ -3953,7 +3955,7 @@ GetSingleProcBlockerStatusData(PGPROC *blocked_proc, BlockedProcsData *data) if (data->nlocks >= data->maxlocks) { - data->maxlocks += MaxBackends; + data->maxlocks += max_backends; data->locks = (LockInstanceData *) repalloc(data->locks, sizeof(LockInstanceData) * data->maxlocks); } @@ -3982,7 +3984,7 @@ GetSingleProcBlockerStatusData(PGPROC *blocked_proc, BlockedProcsData *data) if (queue_size > data->maxpids - data->npids) { - data->maxpids = Max(data->maxpids + MaxBackends, + data->maxpids = Max(data->maxpids + max_backends, data->npids + queue_size); data->waiter_pids = (int *) repalloc(data->waiter_pids, sizeof(int) * data->maxpids); diff --git a/src/backend/storage/lmgr/predicate.c b/src/backend/storage/lmgr/predicate.c index 25e7e4e37bf..e337aad5b24 100644 --- a/src/backend/storage/lmgr/predicate.c +++ b/src/backend/storage/lmgr/predicate.c @@ -257,7 +257,7 @@ (&MainLWLockArray[PREDICATELOCK_MANAGER_LWLOCK_OFFSET + (i)].lock) #define NPREDICATELOCKTARGETENTS() \ - mul_size(max_predicate_locks_per_xact, add_size(MaxBackends, max_prepared_xacts)) + mul_size(max_predicate_locks_per_xact, add_size(GetMaxBackends(), max_prepared_xacts)) #define SxactIsOnFinishedList(sxact) (!SHMQueueIsDetached(&((sxact)->finishedLink))) @@ -1222,7 +1222,7 @@ InitPredicateLocks(void) * Compute size for serializable transaction hashtable. Note these * calculations must agree with PredicateLockShmemSize! */ - max_table_size = (MaxBackends + max_prepared_xacts); + max_table_size = (GetMaxBackends() + max_prepared_xacts); /* * Allocate a list to hold information on transactions participating in @@ -1375,7 +1375,7 @@ PredicateLockShmemSize(void) size = add_size(size, size / 10); /* transaction list */ - max_table_size = MaxBackends + max_prepared_xacts; + max_table_size = GetMaxBackends() + max_prepared_xacts; max_table_size *= 10; size = add_size(size, PredXactListDataSize); size = add_size(size, mul_size((Size) max_table_size, @@ -1907,7 +1907,7 @@ GetSerializableTransactionSnapshotInt(Snapshot snapshot, { ++(PredXact->WritableSxactCount); Assert(PredXact->WritableSxactCount <= - (MaxBackends + max_prepared_xacts)); + (GetMaxBackends() + max_prepared_xacts)); } MySerializableXact = sxact; @@ -5111,7 +5111,7 @@ predicatelock_twophase_recover(TransactionId xid, uint16 info, { ++(PredXact->WritableSxactCount); Assert(PredXact->WritableSxactCount <= - (MaxBackends + max_prepared_xacts)); + (GetMaxBackends() + max_prepared_xacts)); } /* diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index e306b04738d..37f032e7b95 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -103,7 +103,7 @@ ProcGlobalShmemSize(void) { Size size = 0; Size TotalProcs = - add_size(MaxBackends, add_size(NUM_AUXILIARY_PROCS, max_prepared_xacts)); + add_size(GetMaxBackends(), add_size(NUM_AUXILIARY_PROCS, max_prepared_xacts)); /* ProcGlobal */ size = add_size(size, sizeof(PROC_HDR)); @@ -127,7 +127,7 @@ ProcGlobalSemas(void) * We need a sema per backend (including autovacuum), plus one for each * auxiliary process. */ - return MaxBackends + NUM_AUXILIARY_PROCS; + return GetMaxBackends() + NUM_AUXILIARY_PROCS; } /* @@ -162,7 +162,8 @@ InitProcGlobal(void) int i, j; bool found; - uint32 TotalProcs = MaxBackends + NUM_AUXILIARY_PROCS + max_prepared_xacts; + int max_backends = GetMaxBackends(); + uint32 TotalProcs = max_backends + NUM_AUXILIARY_PROCS + max_prepared_xacts; /* Create the ProcGlobal shared structure */ ProcGlobal = (PROC_HDR *) @@ -195,7 +196,7 @@ InitProcGlobal(void) MemSet(procs, 0, TotalProcs * sizeof(PGPROC)); ProcGlobal->allProcs = procs; /* XXX allProcCount isn't really all of them; it excludes prepared xacts */ - ProcGlobal->allProcCount = MaxBackends + NUM_AUXILIARY_PROCS; + ProcGlobal->allProcCount = max_backends + NUM_AUXILIARY_PROCS; /* * Allocate arrays mirroring PGPROC fields in a dense manner. See @@ -221,7 +222,7 @@ InitProcGlobal(void) * dummy PGPROCs don't need these though - they're never associated * with a real process */ - if (i < MaxBackends + NUM_AUXILIARY_PROCS) + if (i < max_backends + NUM_AUXILIARY_PROCS) { procs[i].sem = PGSemaphoreCreate(); InitSharedLatch(&(procs[i].procLatch)); @@ -258,7 +259,7 @@ InitProcGlobal(void) ProcGlobal->bgworkerFreeProcs = &procs[i]; procs[i].procgloballist = &ProcGlobal->bgworkerFreeProcs; } - else if (i < MaxBackends) + else if (i < max_backends) { /* PGPROC for walsender, add to walsenderFreeProcs list */ procs[i].links.next = (SHM_QUEUE *) ProcGlobal->walsenderFreeProcs; @@ -286,8 +287,8 @@ InitProcGlobal(void) * Save pointers to the blocks of PGPROC structures reserved for auxiliary * processes and prepared transactions. */ - AuxiliaryProcs = &procs[MaxBackends]; - PreparedXactProcs = &procs[MaxBackends + NUM_AUXILIARY_PROCS]; + AuxiliaryProcs = &procs[max_backends]; + PreparedXactProcs = &procs[max_backends + NUM_AUXILIARY_PROCS]; /* Create ProcStructLock spinlock, too */ ProcStructLock = (slock_t *) ShmemAlloc(sizeof(slock_t)); |