From be8f4fe055d4d82b222ad71cfe55623720a906b9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Tue, 2 Jul 2019 09:23:19 +0300 Subject: [PATCH] MXS-1901: Route related PS commands to same server All COM_STMT_SEND_LONG_DATA commands and the COM_STMT_EXECUTE that follows it must be sent to the same server. This implicitly works for masters but with multiple slave servers the data could be sent to the wrong server. By using the code added for MXS-2521, this problem can now be easily solved by checking what the previous command was. --- server/core/queryclassifier.cc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/server/core/queryclassifier.cc b/server/core/queryclassifier.cc index 87b78704d..918db76fa 100644 --- a/server/core/queryclassifier.cc +++ b/server/core/queryclassifier.cc @@ -956,8 +956,15 @@ QueryClassifier::current_target_t QueryClassifier::handle_multi_temp_and_load( bool QueryClassifier::query_continues_ps(uint8_t cmd, uint32_t stmt_id, GWBUF* buffer) { bool rval = false; + uint8_t prev_cmd = m_route_info.command(); - if (cmd == COM_STMT_FETCH) + if (prev_cmd == MXS_COM_STMT_SEND_LONG_DATA + && (cmd == MXS_COM_STMT_EXECUTE || cmd == MXS_COM_STMT_SEND_LONG_DATA)) + { + // PS execution must be sent to the same server where the data was sent + rval = true; + } + else if (cmd == COM_STMT_FETCH) { // COM_STMT_FETCH should always go to the same target as the COM_STMT_EXECUTE rval = true;