From e725ebb7d065273d996ef08f357ca66731137068 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 19 Dec 2019 11:31:51 +0200 Subject: [PATCH 1/3] Add missing set of fake event flag The FakeEventTask called the actual DCB handler with a fake task but it didn't set the fake event flag. This caused KILL queries to be treated as if they were network errors. --- server/core/dcb.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/server/core/dcb.cc b/server/core/dcb.cc index d6828cd3f..f466d2135 100644 --- a/server/core/dcb.cc +++ b/server/core/dcb.cc @@ -3327,7 +3327,9 @@ public: { mxb_assert(m_dcb->poll.owner == RoutingWorker::get_current()); m_dcb->fakeq = m_buffer; + m_dcb->is_fake_event = true; dcb_handler(m_dcb, m_ev); + m_dcb->is_fake_event = true; } else { From 484ff06795adafa05f40cb1a686f3e2c9d2086d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 19 Dec 2019 13:22:10 +0200 Subject: [PATCH 2/3] MXS-619: Send fake response for unconnected DCBs This causes the connection failure to be counted as an authentication failure instead of a connection error. The former never causes the host to be blocked which effectively solves the problem for most cases. The only case where this would not work is where the network buffer for a backend DCB is full right after the connection is created. --- .../protocol/MySQL/mariadbbackend/mysql_backend.cc | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/server/modules/protocol/MySQL/mariadbbackend/mysql_backend.cc b/server/modules/protocol/MySQL/mariadbbackend/mysql_backend.cc index ef904c4f4..b40f54bb1 100644 --- a/server/modules/protocol/MySQL/mariadbbackend/mysql_backend.cc +++ b/server/modules/protocol/MySQL/mariadbbackend/mysql_backend.cc @@ -1415,10 +1415,20 @@ static int gw_backend_hangup(DCB* dcb) static int gw_backend_close(DCB* dcb) { mxb_assert(dcb->session); + MySQLProtocol* proto = (MySQLProtocol*)dcb->protocol; + + if (proto->protocol_auth_state == MXS_AUTH_STATE_INIT + || proto->protocol_auth_state == MXS_AUTH_STATE_PENDING_CONNECT + || proto->protocol_auth_state == MXS_AUTH_STATE_CONNECTED) + { + MYSQL_session client; + gw_get_shared_session_auth_info(dcb->session->client_dcb, &client); + memset(proto->scramble, 0, sizeof(proto->scramble)); + dcb_write(dcb, gw_generate_auth_response(&client, proto, false, false, 0)); + } /** Send COM_QUIT to the backend being closed */ - GWBUF* quitbuf = mysql_create_com_quit(NULL, 0); - mysql_send_com_quit(dcb, 0, quitbuf); + dcb_write(dcb, mysql_create_com_quit(NULL, 0)); /** Free protocol data */ mysql_protocol_done(dcb); From 8de3339bc043f2298cae56cba3fb9e9695bcad54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 19 Dec 2019 14:43:27 +0200 Subject: [PATCH 3/3] MXS-619: Restore old test The test now performs the original test of not doing any queries between the opening and closing of sessions. --- maxscale-system-test/open_close_connections.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/maxscale-system-test/open_close_connections.cpp b/maxscale-system-test/open_close_connections.cpp index d565bb740..64bb5e176 100644 --- a/maxscale-system-test/open_close_connections.cpp +++ b/maxscale-system-test/open_close_connections.cpp @@ -25,11 +25,7 @@ void query_thread(TestConnections& test, int thread_id) "Error opening conn to %s:%u, thread num is %d, iteration %ld, error is: %s\n", host, port, thread_id, i, mysql_error(conn)); - if (conn && mysql_errno(conn) == 0) - { - test.try_query(conn, "USE test"); - mysql_close(conn); - } + mysql_close(conn); }; // Keep running the test until we exhaust all available ports