From a5898f83f9052bb7d06fa02a07df3ecc6fef3526 Mon Sep 17 00:00:00 2001 From: Esa Korhonen Date: Tue, 11 Jun 2019 12:22:00 +0000 Subject: [PATCH 1/2] Fix mysqlmon_rejoin_manual Added some extra connection refreshing and monitor waiting. Unclear why this is needed now but it seems to work. --- .../mysqlmon_rejoin_manual.cpp | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/maxscale-system-test/mysqlmon_rejoin_manual.cpp b/maxscale-system-test/mysqlmon_rejoin_manual.cpp index 15b8ece6b..662b04297 100644 --- a/maxscale-system-test/mysqlmon_rejoin_manual.cpp +++ b/maxscale-system-test/mysqlmon_rejoin_manual.cpp @@ -60,14 +60,14 @@ int main(int argc, char** argv) print_gtids(test); cout << "Bringing old master back online..." << endl; test.repl->start_node(master_index, (char*) ""); - test.maxscales->wait_for_monitor(); - test.repl->connect(); + test.maxscales->wait_for_monitor(2); get_output(test); test.tprintf("and manually rejoining it to cluster."); const char REJOIN_CMD[] = "maxadmin call command mariadbmon rejoin MySQL-Monitor server1"; test.maxscales->ssh_node_output(0, REJOIN_CMD, true, &ec); - test.maxscales->wait_for_monitor(); + test.maxscales->wait_for_monitor(2); get_output(test); + test.repl->connect(); string gtid_old_master; test.repl->connect(); @@ -88,10 +88,9 @@ int main(int argc, char** argv) "Old master did not successfully rejoin the cluster (%s != %s).", gtid_final.c_str(), gtid_old_master.c_str()); // Switch master back to server1 so last check is faster - int ec; - test.maxscales->ssh_node_output(0, "maxadmin call command mysqlmon switchover " - "MySQL-Monitor server1 server2", true, &ec); - test.maxscales->wait_for_monitor(); + test.maxscales->ssh_node_output(0, + "maxadmin call command mysqlmon switchover MySQL-Monitor server1 server2", true, &ec); + test.maxscales->wait_for_monitor(2); get_output(test); master_id = get_master_server_id(test); test.expect(master_id == old_master_id, "Switchover back to server1 failed."); @@ -115,16 +114,17 @@ int main(int argc, char** argv) test.expect(row.empty() || row[0].empty(), "server3 gtid is not empty as it should (%s).", row[0].c_str()); cout << "Rejoining server3.\n"; - test.maxscales->ssh_node_output(0, "maxadmin call command mysqlmon rejoin " - "MySQL-Monitor server3", true, &ec); - test.maxscales->wait_for_monitor(); + test.maxscales->ssh_node_output(0, + "maxadmin call command mysqlmon rejoin MySQL-Monitor server3", true, &ec); + test.maxscales->wait_for_monitor(2); get_output(test); + test.repl->connect(); char result[100]; test.repl->connect(); if (find_field(conn, sstatus_query.c_str(), "Master_Host", result) == 0) { test.expect(strcmp(result, test.repl->IP[0]) == 0, - "server3 did not rejoin the cluster (%s != %s).", result, test.repl->IP[0]); + "server3 did not rejoin the cluster (%s != %s).", result, test.repl->IP[0]); } else { From 2accfad329dc51cc115069b17949762f25ada1df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 13 Jun 2019 15:34:07 +0300 Subject: [PATCH 2/2] Handle trailing unexpected ERR packets RWBackend did not expect that a resultset and an unexpected ERR packet could be stored in the same buffer. This can happen for example if a server shuts down immediately after the resultset is sent. --- server/modules/protocol/MySQL/rwbackend.cc | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/server/modules/protocol/MySQL/rwbackend.cc b/server/modules/protocol/MySQL/rwbackend.cc index 2dd8a9d22..9bc311c4b 100644 --- a/server/modules/protocol/MySQL/rwbackend.cc +++ b/server/modules/protocol/MySQL/rwbackend.cc @@ -315,9 +315,16 @@ void RWBackend::process_packets(GWBUF* result) break; case REPLY_STATE_DONE: - // This should never happen - MXS_ERROR("Unexpected result state. cmd: 0x%02hhx, len: %u", cmd, len); - mxb_assert(!true); + if (cmd == MYSQL_REPLY_ERR) + { + // Unexpected error at the end of a resultset, possibly a killed connection + } + else + { + // This should never happen + MXS_ERROR("Unexpected result state. cmd: 0x%02hhx, len: %u", cmd, len); + mxb_assert(!true); + } break; case REPLY_STATE_RSET_COLDEF: