From: Cody Cutrer Date: Mon, 26 Aug 2013 20:30:27 +0000 (-0600) Subject: fix launching new connections during maintenance X-Git-Tag: pgbouncer_1_6_rc1~30^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=3bb254281be40dcd3e6befab4d24c5a3a7590063;p=pgbouncer fix launching new connections during maintenance match up waiting connections with tested/used until we run out. launches new connection if there are more waiting than could be fulfilled by refreshing current connections. this situation can happen if you have high churn on client connections (i.e. with transaction pooling), such that there is *always* at least one connection in sv_tested or sv_used. --- diff --git a/src/janitor.c b/src/janitor.c index 083da52..26c7c57 100644 --- a/src/janitor.c +++ b/src/janitor.c @@ -171,8 +171,11 @@ static void per_loop_activate(PgPool *pool) { struct List *item, *tmp; PgSocket *client; + int sv_tested, sv_used; /* see if any server have been freed */ + sv_tested = statlist_count(&pool->tested_server_list); + sv_used = statlist_count(&pool->used_server_list); statlist_for_each_safe(item, &pool->waiting_client_list, tmp) { client = container_of(item, PgSocket, head); if (!statlist_empty(&pool->idle_server_list)) { @@ -185,13 +188,13 @@ static void per_loop_activate(PgPool *pool) /* there is a ready server already */ activate_client(client); - } else if (!statlist_empty(&pool->tested_server_list)) { + } else if (sv_tested > 0) { /* some connections are in testing process */ - break; - } else if (!statlist_empty(&pool->used_server_list)) { + --sv_tested; + } else if (sv_used > 0) { /* ask for more connections to be tested */ launch_recheck(pool); - break; + --sv_used; } else { /* not enough connections */ launch_new_connection(pool);