From ec890b33cd689f231899b6a63a71e31bd79ac07c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 4 Apr 2019 17:20:04 +0300 Subject: [PATCH] Prevent checksum mismatch on second trx replay If a transaction replay has to be executed twice due to a failure of the original candidate master, the query queue could contain replayed queries. The replayed queries would be placed into the queue if a new connection needs to be created before the transaction replay can start. --- server/modules/routing/readwritesplit/rwsplitsession.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/server/modules/routing/readwritesplit/rwsplitsession.cc b/server/modules/routing/readwritesplit/rwsplitsession.cc index 0fa0b9536..138144aaf 100644 --- a/server/modules/routing/readwritesplit/rwsplitsession.cc +++ b/server/modules/routing/readwritesplit/rwsplitsession.cc @@ -813,6 +813,11 @@ bool RWSplitSession::start_trx_replay() m_trx.close(); m_trx = m_orig_trx; m_current_query.copy_from(m_orig_stmt); + + // Erase all replayed queries from the query queue to prevent checksum mismatches + m_query_queue.erase(std::remove_if(m_query_queue.begin(), m_query_queue.end(), [](mxs::Buffer b) { + return GWBUF_IS_REPLAYED(b.get()); + }), m_query_queue.end()); } if (m_trx.have_stmts() || m_current_query.get())