diff --git a/src/backend/distributed/connection/shared_connection_stats.c b/src/backend/distributed/connection/shared_connection_stats.c index 26598b465f2..60ac9293745 100644 --- a/src/backend/distributed/connection/shared_connection_stats.c +++ b/src/backend/distributed/connection/shared_connection_stats.c @@ -238,7 +238,7 @@ GetLocalSharedPoolSize(void) { if (LocalSharedPoolSize == ADJUST_POOLSIZE_AUTOMATICALLY) { - return GetMaxClientConnections() * 0.5; + return GetMaxClientConnections(); } return LocalSharedPoolSize; diff --git a/src/test/regress/expected/single_node.out b/src/test/regress/expected/single_node.out index 522ffb8e804..935d6a2a694 100644 --- a/src/test/regress/expected/single_node.out +++ b/src/test/regress/expected/single_node.out @@ -2561,6 +2561,45 @@ SELECT pg_reload_conf(); t (1 row) +/* + * test for the citus.local_shared_pool_size value when a regular user & superuser are querying it. + */ +ALTER SYSTEM SET citus.max_client_connections TO 80; +ALTER SYSTEM SET citus.local_shared_pool_size TO 0; +SELECT pg_reload_conf(); + pg_reload_conf +--------------------------------------------------------------------- + t +(1 row) + +CREATE ROLE user_1 WITH LOGIN; +GRANT pg_read_all_settings TO user_1; +SET ROLE user_1; +/* should output 80, as this is the citus.max_client_connections value and a regular user is querying it. */ +SHOW citus.local_shared_pool_size; + citus.local_shared_pool_size +--------------------------------------------------------------------- + 80 +(1 row) + +SET ROLE postgres; +/* should output 100, as this is the postgresql default for max_connections and the superuser is querying it. */ +SHOW citus.local_shared_pool_size; + citus.local_shared_pool_size +--------------------------------------------------------------------- + 100 +(1 row) + +DROP ROLE user_1; +ALTER SYSTEM RESET citus.max_client_connections; +ALTER SYSTEM RESET max_connections; +ALTER SYSTEM RESET citus.local_shared_pool_size; +SELECT pg_reload_conf(); + pg_reload_conf +--------------------------------------------------------------------- + t +(1 row) + -- suppress notices SET client_min_messages TO error; -- cannot remove coordinator since a reference table exists on coordinator and no other worker nodes are added diff --git a/src/test/regress/sql/single_node.sql b/src/test/regress/sql/single_node.sql index 2bb7c58a36d..857ee1d5936 100644 --- a/src/test/regress/sql/single_node.sql +++ b/src/test/regress/sql/single_node.sql @@ -1293,7 +1293,31 @@ ALTER SYSTEM RESET citus.distributed_deadlock_detection_factor; ALTER SYSTEM RESET citus.local_shared_pool_size; SELECT pg_reload_conf(); +/* + * test for the citus.local_shared_pool_size value when a regular user & superuser are querying it. + */ +ALTER SYSTEM SET citus.max_client_connections TO 80; +ALTER SYSTEM SET citus.local_shared_pool_size TO 0; +SELECT pg_reload_conf(); + +CREATE ROLE user_1 WITH LOGIN; +GRANT pg_read_all_settings TO user_1; +SET ROLE user_1; + +/* should output 80, as this is the citus.max_client_connections value and a regular user is querying it. */ +SHOW citus.local_shared_pool_size; + +SET ROLE postgres; +/* should output 100, as this is the postgresql default for max_connections and the superuser is querying it. */ +SHOW citus.local_shared_pool_size; + +DROP ROLE user_1; + +ALTER SYSTEM RESET citus.max_client_connections; +ALTER SYSTEM RESET max_connections; +ALTER SYSTEM RESET citus.local_shared_pool_size; +SELECT pg_reload_conf(); -- suppress notices SET client_min_messages TO error;