pgpool2.git / summary / log / commit / refs
commit 6ed89298fb9a71e5554ee44d4abe0cfd0f2da0f0
Author: Tatsuo Ishii <ishii@sraoss.co.jp>
Date: Sun Oct 24 02:30:25 2021 +0000
Fix connection counter issue when reserved_connections is 0.
If reserved_connections is 0, we don't need to manage the connection
counter to check if the count is larger than
(pool_config->num_init_children - pool_config->reserved_connections).
So remove the check. This will prevent unwanted "Sorry, too many
clients already" error" by accidental counter leak.
For reserved_connections > 0 case, we need to fix the counter leak but
it's another story.
Discussion: https://www.pgpool.net/pipermail/pgpool-general/2021-October/007808.html
src/protocol/child.c | 40 ++++++++++++++++++++++------------------
1 file changed, 22 insertions(+), 18 deletions(-)
diff --git a/src/protocol/child.c b/src/protocol/child.c
index 779763efa..94e63efd3 100644
--- a/src/protocol/child.c
+++ b/src/protocol/child.c
@@ -345,30 +345,34 @@ do_child(int *fds)
if (front_end_fd == RETRY)
continue;
- /*
- * Check if max connections from clients exceeded.
- */
con_count = connection_count_up();
- if (con_count > (pool_config->num_init_children - pool_config->reserved_connections))
+
+ if (pool_config->reserved_connections > 0)
{
- POOL_CONNECTION * cp;
- cp = pool_open(front_end_fd, false);
- if (cp == NULL)
+ /*
+ * Check if max connections from clients exceeded.
+ */
+ if (con_count > (pool_config->num_init_children - pool_config->reserved_connections))
{
+ POOL_CONNECTION * cp;
+ cp = pool_open(front_end_fd, false);
+ if (cp == NULL)
+ {
+ connection_count_down();
+ continue;
+ }
connection_count_down();
+ pool_send_fatal_message(cp, 3, "53300",
+ "Sorry, too many clients already",
+ "",
+ "",
+ __FILE__, __LINE__);
+ ereport(ERROR,
+ (errcode(ERRCODE_TOO_MANY_CONNECTIONS),
+ errmsg("Sorry, too many clients already")));
+ pool_close(cp);
continue;
}
- connection_count_down();
- pool_send_fatal_message(cp, 3, "53300",
- "Sorry, too many clients already",
- "",
- "",
- __FILE__, __LINE__);
- ereport(ERROR,
- (errcode(ERRCODE_TOO_MANY_CONNECTIONS),
- errmsg("Sorry, too many clients already")));
- pool_close(cp);
- continue;
}
accepted = 1;
[parent: 3525981a1890]