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.
This commit is contained in:
Markus Mäkelä 2018-07-22 23:22:21 +03:00
parent d7a3980308
commit 106b1d46d5
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19
2 changed files with 4 additions and 1 deletions

View File

@ -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;

View File

@ -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;
}