From e69d1807a2405ba5fab74afac2846de76cc1817b Mon Sep 17 00:00:00 2001 From: Roman Zharkov Date: Tue, 11 Oct 2022 10:24:53 +0700 Subject: [PATCH] PGPRO-7151: Fix the get_max_procs_count() function. Little refactor of the #ifdef block. Fix accounting for the MaxATX variable in the PostgresPro Enterprise versions. --- pg_wait_sampling.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/pg_wait_sampling.c b/pg_wait_sampling.c index c77f980..259b9e8 100644 --- a/pg_wait_sampling.c +++ b/pg_wait_sampling.c @@ -89,7 +89,7 @@ get_max_procs_count(void) */ Assert(MaxBackends > 0); count += MaxBackends; -#else +#elif PG_VERSION_NUM >= 120000 /* * On older versions, we need to compute MaxBackends: bgworkers, autovacuum * workers and launcher. @@ -110,23 +110,22 @@ get_max_procs_count(void) * fail (and prevent postgres startup) due to an out of shared memory * error. */ - count += MaxConnections + autovacuum_max_workers + 1 - + max_worker_processes; - -#if PG_VERSION_NUM >= 140000 && defined(PGPRO_EE) - count += MaxATX; -#endif - + count += MaxConnections + autovacuum_max_workers + 1 + + max_worker_processes + max_wal_senders; +#else /* pg 12- */ /* - * Starting with pg12, wal senders aren't part of MaxConnections anymore - * and have to be accounted for. + * On versions before pg12, wal senders are the part of MaxConnections + * and doesn't have to be accounted for. */ -#if PG_VERSION_NUM >= 120000 - count += max_wal_senders; -#endif /* pg 12+ */ + count += MaxConnections + autovacuum_max_workers + 1 + + max_worker_processes; #endif /* pg 15- */ /* End of MaxBackends calculation. */ +#if PG_VERSION_NUM >= 140000 && defined(PGPRO_EE) + count += MaxATX; +#endif + /* Add AuxiliaryProcs */ count += NUM_AUXILIARY_PROCS;