pgpool2.git / summary / log / commit / refs
commit 37dc683f7f15cbf4502b338937e54b9da0a92efd
Author: Muhammad Usama <m.usama@gmail.com>
Date: Sat Jul 22 13:54:31 2023 +0000
Disallowing setting the max_spare_children greater than num_init_children.
Config post-processing stage now throws an error if num_init_children is
smaller than max_spare_children.
Commit also adjusts the number of child processes spawned at startup based on
the configured process management strategy.
For the Aggressive strategy, max_spare_children number of processes is spawned;
for the other two strategies, min_spare_children number of children gets
created at startup.
src/config/pool_config_variables.c | 7 +++++++
src/main/pgpool_main.c | 11 ++++++++---
2 files changed, 15 insertions(+), 3 deletions(-)
diff --git a/src/config/pool_config_variables.c b/src/config/pool_config_variables.c
index 3373f04f9..faa677698 100644
--- a/src/config/pool_config_variables.c
+++ b/src/config/pool_config_variables.c
@@ -4966,6 +4966,13 @@ config_post_processor(ConfigContext context, int elevel)
pool_config->max_spare_children,pool_config->min_spare_children)));
return false;
}
+ if (pool_config->num_init_children < pool_config->max_spare_children)
+ {
+ ereport(elevel,
+ (errmsg("invalid configuration, max_spare_children:%d can't be greater than num_init_children:%d",
+ pool_config->max_spare_children,pool_config->num_init_children)));
+ return false;
+ }
return true;
}
diff --git a/src/main/pgpool_main.c b/src/main/pgpool_main.c
index dc2ff1fab..252ea6da2 100644
--- a/src/main/pgpool_main.c
+++ b/src/main/pgpool_main.c
@@ -538,11 +538,16 @@ PgpoolMain(bool discard_status, bool clear_memcache_oidmaps)
POOL_SETMASK(&BlockSig);
if (pool_config->process_management == PM_DYNAMIC)
- current_child_process_count = pool_config->max_spare_children;
+ {
+ if (pool_config->process_management_strategy == PM_STRATEGY_AGGRESSIVE)
+ current_child_process_count = pool_config->max_spare_children;
+ else
+ current_child_process_count = pool_config->min_spare_children;
+ }
else
current_child_process_count = pool_config->num_init_children;
-
- /* fork the children */
+ ereport(DEBUG1,
+ (errmsg("Spawning %d child processes",current_child_process_count)));
for (i = 0; i < current_child_process_count; i++)
{
process_info[i].start_time = time(NULL);
[parent: 4aa657e05525]