From c878de1db438f9f4747374c286d4319cc527eec2 Mon Sep 17 00:00:00 2001 From: Tomas Vondra Date: Tue, 4 Mar 2025 18:33:09 +0100 Subject: Make FP_LOCK_SLOTS_PER_BACKEND look like a function The FP_LOCK_SLOTS_PER_BACKEND macro looks like a constant, but it depends on the max_locks_per_transaction GUC, and thus can change. This is non-obvious and confusing, so make it look more like a function by renaming it to FastPathLockSlotsPerBackend(). While at it, use the macro when initializing fast-path shared memory, instead of using the formula. Reported-by: Andres Freund Discussion: https://postgr.es/m/ffiwtzc6vedo6wb4gbwelon5nefqg675t5c7an2ta7pcz646cg%40qwmkdb3l4ett --- src/backend/utils/init/postinit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/backend/utils/init/postinit.c') diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c index b428a59bdd2..ee1a9d5d98b 100644 --- a/src/backend/utils/init/postinit.c +++ b/src/backend/utils/init/postinit.c @@ -587,7 +587,7 @@ InitializeFastPathLocks(void) while (FastPathLockGroupsPerBackend < FP_LOCK_GROUPS_PER_BACKEND_MAX) { /* stop once we exceed max_locks_per_xact */ - if (FastPathLockGroupsPerBackend * FP_LOCK_SLOTS_PER_GROUP >= max_locks_per_xact) + if (FastPathLockSlotsPerBackend() >= max_locks_per_xact) break; FastPathLockGroupsPerBackend *= 2; -- cgit v1.2.3