From 953dd4098bafce6ddfaf80d4566fa5fecd11b74a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Wed, 3 Jul 2019 13:42:14 +0300 Subject: [PATCH] MXS-2587: Prevent queries after failed trx replay If a transaction replay fails, no queries must be routed before the connection is closed. This could happen if the client received the error from the replay failure and closes the connection before the fake hangup generated by the replay failure is processed. --- .../modules/routing/readwritesplit/rwsplitsession.cc | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/server/modules/routing/readwritesplit/rwsplitsession.cc b/server/modules/routing/readwritesplit/rwsplitsession.cc index bbdb45297..2c49c068e 100644 --- a/server/modules/routing/readwritesplit/rwsplitsession.cc +++ b/server/modules/routing/readwritesplit/rwsplitsession.cc @@ -472,14 +472,15 @@ void RWSplitSession::trx_replay_next_stmt() else { MXS_INFO("Checksum mismatch, transaction replay failed. Closing connection."); - modutil_send_mysql_err_packet(m_client, - 0, - 0, - 1927, - "08S01", + modutil_send_mysql_err_packet(m_client, 1, 0, 1927, "08S01", "Transaction checksum mismatch encountered " "when replaying transaction."); poll_fake_hangup_event(m_client); + + // Turn the replay flag back on to prevent queries from getting routed before the hangup we + // just added is processed. For example, this can happen if the error is sent and the client + // manages to send a COM_QUIT that gets processed before the fake hangup event. + m_is_replay_active = true; } } else