From 106b1d46d576a03dd32f88a066d610d94b896ef4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Sun, 22 Jul 2018 23:22:21 +0300 Subject: [PATCH] Only perform causal reads on slaves The causal read queries were performed also when the target server was the master. The extra functionality of the causal reads is only needed on slaves. Adjusted the test case to require GTID replication. --- maxscale-system-test/mxs1778_causal_reads.cpp | 1 + server/modules/routing/readwritesplit/rwsplit_route_stmt.cc | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/maxscale-system-test/mxs1778_causal_reads.cpp b/maxscale-system-test/mxs1778_causal_reads.cpp index 8a8de1c09..93424897b 100644 --- a/maxscale-system-test/mxs1778_causal_reads.cpp +++ b/maxscale-system-test/mxs1778_causal_reads.cpp @@ -8,6 +8,7 @@ int main(int argc, char** argv) { + Mariadb_nodes::require_gtid(true); TestConnections::require_repl_version("10.3.8"); TestConnections test(argc, argv); const int N_QUERIES = 100; diff --git a/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc b/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc index 89af89033..fc9442e7c 100644 --- a/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc +++ b/server/modules/routing/readwritesplit/rwsplit_route_stmt.cc @@ -1083,8 +1083,10 @@ bool RWSplitSession::handle_got_target(GWBUF* querybuf, SRWBackend& target, bool uint8_t cmd = mxs_mysql_get_command(querybuf); GWBUF *send_buf = gwbuf_clone(querybuf); - if (m_config->causal_reads && cmd == COM_QUERY && !m_gtid_pos.empty()) + if (m_config->causal_reads && cmd == COM_QUERY && !m_gtid_pos.empty() && + target->is_slave()) { + // Perform the causal read only when the query is routed to a slave send_buf = add_prefix_wait_gtid(target->server(), send_buf); m_wait_gtid = WAITING_FOR_HEADER; }