From a217dde1f0bb3ff57b9ee423dd16881eb4ccf856 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Tue, 2 Apr 2019 17:45:22 +0300 Subject: [PATCH] MXS-2419: Queue queries executed during trx replay By storing the queries in the query queue and routing it once the transaction replay is done, we prevent two problems: * Multiple transaction replays would overwrite the m_interrupted_query buffer that was used to store any queries executed during the transaction replay. * Incorrect ordering of queries when the query queue is not empty and a new query is executed during transaction replay. --- server/modules/routing/readwritesplit/rwsplitsession.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/server/modules/routing/readwritesplit/rwsplitsession.cc b/server/modules/routing/readwritesplit/rwsplitsession.cc index 3142f5061..02a9ff990 100644 --- a/server/modules/routing/readwritesplit/rwsplitsession.cc +++ b/server/modules/routing/readwritesplit/rwsplitsession.cc @@ -138,12 +138,11 @@ int32_t RWSplitSession::routeQuery(GWBUF* querybuf) { MXS_INFO("New query received while transaction replay is active: %s", mxs::extract_sql(querybuf).c_str()); - mxb_assert(!m_interrupted_query.get()); - m_interrupted_query.reset(querybuf); + m_query_queue = gwbuf_append(m_query_queue, querybuf); return 1; } - if (m_query_queue == NULL + if ((m_query_queue == NULL || GWBUF_IS_REPLAYED(querybuf)) && (m_expected_responses == 0 || m_qc.load_data_state() == QueryClassifier::LOAD_DATA_ACTIVE || m_qc.large_query())) @@ -469,6 +468,10 @@ void RWSplitSession::trx_replay_next_stmt() MXS_INFO("Resuming execution: %s", mxs::extract_sql(m_interrupted_query.get()).c_str()); retry_query(m_interrupted_query.release(), 0); } + else if (m_query_queue) + { + route_stored_query(); + } } else {