Calculation of pooled_connection, which is used by the process
eviction algorithm, was not correct. The number always resulted in
max_pool. Also more comments are added.
Discussion: [pgpool-hackers: 4490] Issue with dynamic process management
https://www.pgpool.net/pipermail/pgpool-hackers/2024-July/004491.html
Backpatch-through: master, 4.5, 4.4
/* Mark this connection pool is not connected from frontend */
pool_coninfo_unset_frontend_connected(pool_get_process_context()->proc_id, pool_pool_index());
+
+ /*
+ * Update number of established connections in the connection pool.
+ */
update_pooled_connection_count();
+
accepted = 0;
connection_count_down();
if (pool_config->log_disconnections)
POOL_SETMASK(&oldmask);
}
-void update_pooled_connection_count(void)
+/*
+ * Return number of established connections in the connection pool.
+ * This is called when a client disconnects to pgpool.
+ */
+void
+update_pooled_connection_count(void)
{
int i;
int count = 0;
POOL_CONNECTION_POOL *p = pool_connection_pool;
- for (i = 0; i < pool_config->max_pool; i++)
+ for (i = 0; i < pool_config->max_pool; i++, p++)
{
if (MAIN_CONNECTION(p))
count++;