From 944a5bd9c130e7641d73d56f9281163628133d6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Sun, 24 Sep 2017 11:31:56 +0300 Subject: [PATCH] Only extract successful PS responses If a prepared statement fails to execute on a backend server, no prepared statement ID is returned. As the connection to the slave backend will be closed when the result of a session command differs from the master's response, there's no need to even attempt extracting the response. This change avoids the triggering of a false positive in mxs_mysql_extract_ps_response when an attempt to extract a COM_STMT_PREPARE response is made on a response that isn't a COM_STMT_PREPARE response. --- server/modules/routing/readwritesplit/rwsplit_session_cmd.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/modules/routing/readwritesplit/rwsplit_session_cmd.cc b/server/modules/routing/readwritesplit/rwsplit_session_cmd.cc index 63d910c04..76119b975 100644 --- a/server/modules/routing/readwritesplit/rwsplit_session_cmd.cc +++ b/server/modules/routing/readwritesplit/rwsplit_session_cmd.cc @@ -40,7 +40,7 @@ void process_sescmd_response(RWSplitSession* rses, SRWBackend& backend, uint64_t id = backend->complete_session_command(); MXS_PS_RESPONSE resp = {}; - if (command == MXS_COM_STMT_PREPARE) + if (command == MXS_COM_STMT_PREPARE && cmd != MYSQL_REPLY_ERR) { // This should never fail or the backend protocol is broken ss_debug(bool b = )mxs_mysql_extract_ps_response(*ppPacket, &resp);