From 452e00d2df5fd858b297504bbcc028763094e43d Mon Sep 17 00:00:00 2001 From: wangbin Date: Tue, 25 Apr 2023 20:26:18 +0800 Subject: [PATCH] Add max connection info while waiting one backend connection failed --- plugins/admin/admin-plugin.c | 15 ++++++++------- src/network-mysqld.c | 12 +++++++----- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/plugins/admin/admin-plugin.c b/plugins/admin/admin-plugin.c index 0501574..1466e3c 100644 --- a/plugins/admin/admin-plugin.c +++ b/plugins/admin/admin-plugin.c @@ -355,20 +355,21 @@ network_read_sql_resp(int G_GNUC_UNUSED fd, short events, void *user_data) packet.data = chunk->data; packet.offset = 0; - int is_finished = network_mysqld_proto_get_query_result(&packet, con); + int is_finished = + network_mysqld_proto_get_query_result(&packet, con); if (is_finished == 1) { - g_debug("%s: read finished", G_STRLOC); - break; + g_debug("%s: read finished", G_STRLOC); + break; } ret = network_mysqld_con_get_packet(con->srv, sock); - } + } - if (con->servers == NULL) { + if (con->servers == NULL) { con->servers = g_ptr_array_new(); - } + } - g_ptr_array_add(con->servers, sock); + g_ptr_array_add(con->servers, sock); } } else { diff --git a/src/network-mysqld.c b/src/network-mysqld.c index 77fd449..697d6b1 100644 --- a/src/network-mysqld.c +++ b/src/network-mysqld.c @@ -2585,12 +2585,14 @@ handle_read_query(network_mysqld_con *con, network_mysqld_con_state_t ostate) } /* fall through */ default: - g_critical("%s: wait failed and no server backend for user:%s, ret:%d", - G_STRLOC, con->client->response->username->str, ret); + g_critical("%s: wait failed and no server backend for user:%s, ret:%d, " + "max conn:%d", + G_STRLOC, con->client->response->username->str, ret, + con->srv->max_idle_connections); - handle_query_wait_stats(con); - process_service_unavailable(con); - break; + handle_query_wait_stats(con); + process_service_unavailable(con); + break; } /**