diff options
author | Robert Haas <rhaas@postgresql.org> | 2022-04-12 14:45:23 -0400 |
---|---|---|
committer | Robert Haas <rhaas@postgresql.org> | 2022-04-12 14:45:23 -0400 |
commit | 7fc0e7de9fb8306e84d1c15211aba4308f694455 (patch) | |
tree | ce8d0213123959bce52699e8e8d837d46758a2f6 /src/backend/storage/ipc/procarray.c | |
parent | 2c9381840fe2d6d1c3179350493fe5fd3dcf90b5 (diff) | |
download | postgresql-7fc0e7de9fb8306e84d1c15211aba4308f694455.tar.gz postgresql-7fc0e7de9fb8306e84d1c15211aba4308f694455.zip |
Revert the addition of GetMaxBackends() and related stuff.
This reverts commits 0147fc7, 4567596, aa64f23, and 5ecd018.
There is no longer agreement that introducing this function
was the right way to address the problem. The consensus now
seems to favor trying to make a correct value for MaxBackends
available to mdules executing their _PG_init() functions.
Nathan Bossart
Discussion: http://postgr.es/m/20220323045229.i23skfscdbvrsuxa@jrouhaud
Diffstat (limited to 'src/backend/storage/ipc/procarray.c')
-rw-r--r-- | src/backend/storage/ipc/procarray.c | 25 |
1 files changed, 8 insertions, 17 deletions
diff --git a/src/backend/storage/ipc/procarray.c b/src/backend/storage/ipc/procarray.c index e184a3552c8..cb39fdde339 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 ProcArrayMaxProcs entries */ + /* indexes into allProcs[], has PROCARRAY_MAXPROCS entries */ int pgprocnos[FLEXIBLE_ARRAY_MEMBER]; } ProcArrayStruct; @@ -355,17 +355,6 @@ 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. @@ -376,8 +365,10 @@ 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), GetProcArrayMaxProcs())); + size = add_size(size, mul_size(sizeof(int), PROCARRAY_MAXPROCS)); /* * During Hot Standby processing we have a data structure called @@ -393,7 +384,7 @@ ProcArrayShmemSize(void) * shared memory is being set up. */ #define TOTAL_MAX_CACHED_SUBXIDS \ - ((PGPROC_MAX_CACHED_SUBXIDS + 1) * GetProcArrayMaxProcs()) + ((PGPROC_MAX_CACHED_SUBXIDS + 1) * PROCARRAY_MAXPROCS) if (EnableHotStandby) { @@ -420,7 +411,7 @@ CreateSharedProcArray(void) ShmemInitStruct("Proc Array", add_size(offsetof(ProcArrayStruct, pgprocnos), mul_size(sizeof(int), - GetProcArrayMaxProcs())), + PROCARRAY_MAXPROCS)), &found); if (!found) @@ -429,7 +420,7 @@ CreateSharedProcArray(void) * We're the first - initialize. */ procArray->numProcs = 0; - procArray->maxProcs = GetProcArrayMaxProcs(); + procArray->maxProcs = PROCARRAY_MAXPROCS; procArray->maxKnownAssignedXids = TOTAL_MAX_CACHED_SUBXIDS; procArray->numKnownAssignedXids = 0; procArray->tailKnownAssignedXids = 0; @@ -4645,7 +4636,7 @@ KnownAssignedXidsCompress(bool force) */ int nelements = head - tail; - if (nelements < 4 * GetProcArrayMaxProcs() || + if (nelements < 4 * PROCARRAY_MAXPROCS || nelements < 2 * pArray->numKnownAssignedXids) return; } |