From 7fc0e7de9fb8306e84d1c15211aba4308f694455 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Tue, 12 Apr 2022 14:45:23 -0400 Subject: 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 --- src/backend/commands/async.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'src/backend/commands/async.c') diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c index 455d895a44a..3e1b92df030 100644 --- a/src/backend/commands/async.c +++ b/src/backend/commands/async.c @@ -518,7 +518,7 @@ AsyncShmemSize(void) Size size; /* This had better match AsyncShmemInit */ - size = mul_size(GetMaxBackends() + 1, sizeof(QueueBackendStatus)); + size = mul_size(MaxBackends + 1, sizeof(QueueBackendStatus)); size = add_size(size, offsetof(AsyncQueueControl, backend)); size = add_size(size, SimpleLruShmemSize(NUM_NOTIFY_BUFFERS, 0)); @@ -534,7 +534,6 @@ AsyncShmemInit(void) { bool found; Size size; - int max_backends = GetMaxBackends(); /* * Create or attach to the AsyncQueueControl structure. @@ -542,7 +541,7 @@ AsyncShmemInit(void) * The used entries in the backend[] array run from 1 to MaxBackends; the * zero'th entry is unused but must be allocated. */ - size = mul_size(max_backends + 1, sizeof(QueueBackendStatus)); + size = mul_size(MaxBackends + 1, sizeof(QueueBackendStatus)); size = add_size(size, offsetof(AsyncQueueControl, backend)); asyncQueueControl = (AsyncQueueControl *) @@ -557,7 +556,7 @@ AsyncShmemInit(void) QUEUE_FIRST_LISTENER = InvalidBackendId; asyncQueueControl->lastQueueFillWarn = 0; /* zero'th entry won't be used, but let's initialize it anyway */ - for (int i = 0; i <= max_backends; i++) + for (int i = 0; i <= MaxBackends; i++) { QUEUE_BACKEND_PID(i) = InvalidPid; QUEUE_BACKEND_DBOID(i) = InvalidOid; @@ -1633,7 +1632,6 @@ SignalBackends(void) int32 *pids; BackendId *ids; int count; - int max_backends = GetMaxBackends(); /* * Identify backends that we need to signal. We don't want to send @@ -1643,8 +1641,8 @@ SignalBackends(void) * XXX in principle these pallocs could fail, which would be bad. Maybe * preallocate the arrays? They're not that large, though. */ - pids = (int32 *) palloc(max_backends * sizeof(int32)); - ids = (BackendId *) palloc(max_backends * sizeof(BackendId)); + pids = (int32 *) palloc(MaxBackends * sizeof(int32)); + ids = (BackendId *) palloc(MaxBackends * sizeof(BackendId)); count = 0; LWLockAcquire(NotifyQueueLock, LW_EXCLUSIVE); -- cgit v1.2.3