Read correct parameter for causal_reads
The configuration used the wrong parameter name. The test also did not explicitly enable tracking of the last_gtid variable which caused it to fail if it wasn't already on.
This commit is contained in:
parent
823efffb00
commit
d7a3980308
@ -12,6 +12,11 @@ int main(int argc, char** argv)
|
||||
TestConnections test(argc, argv);
|
||||
const int N_QUERIES = 100;
|
||||
|
||||
test.repl->execute_query_all_nodes("SET GLOBAL session_track_system_variables='last_gtid'");
|
||||
test.repl->connect();
|
||||
std::string master = get_row(test.repl->nodes[0], "SELECT @@server_id")[0];
|
||||
test.repl->disconnect();
|
||||
|
||||
test.maxscales->connect();
|
||||
|
||||
test.try_query(test.maxscales->conn_rwsplit[0], "CREATE OR REPLACE TABLE test.t1(id INT)");
|
||||
@ -20,11 +25,12 @@ int main(int argc, char** argv)
|
||||
{
|
||||
std::string value = std::to_string(i);
|
||||
std::string insert = "INSERT INTO test.t1 VALUES (" + value + ")";
|
||||
std::string select = "SELECT COUNT(*) FROM test.t1 WHERE id = " + value;
|
||||
std::string select = "SELECT @@server_id, COUNT(*) FROM test.t1 WHERE id = " + value;
|
||||
|
||||
test.try_query(test.maxscales->conn_rwsplit[0], "%s", insert.c_str());
|
||||
Row row = get_row(test.maxscales->conn_rwsplit[0], select);
|
||||
test.assert(!row.empty() && row[0] == "1", "At %d: Row is %s", i, row.empty() ? "empty" : row[0].c_str());
|
||||
test.assert(!row.empty() && row [0] != master && row[1] == "1",
|
||||
"At %d: Row is %s", i, row.empty() ? "empty" : (row[0] + " " + row[1]).c_str());
|
||||
}
|
||||
|
||||
test.try_query(test.maxscales->conn_rwsplit[0], "DROP TABLE test.t1");
|
||||
|
@ -158,8 +158,8 @@ struct Config
|
||||
max_slave_replication_lag(config_get_integer(params, "max_slave_replication_lag")),
|
||||
rw_max_slave_conn_percent(0),
|
||||
max_slave_connections(0),
|
||||
causal_reads(config_get_bool(params, "enable_causal_read")),
|
||||
causal_reads_timeout(config_get_string(params, "causal_read_timeout")),
|
||||
causal_reads(config_get_bool(params, "causal_reads")),
|
||||
causal_reads_timeout(config_get_string(params, "causal_reads_timeout")),
|
||||
master_reconnection(config_get_bool(params, "master_reconnection")),
|
||||
delayed_retry(config_get_bool(params, "delayed_retry")),
|
||||
delayed_retry_timeout(config_get_integer(params, "delayed_retry_timeout")),
|
||||
|
@ -1083,7 +1083,7 @@ 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 (cmd == COM_QUERY && m_config->causal_reads && !m_gtid_pos .empty())
|
||||
if (m_config->causal_reads && cmd == COM_QUERY && !m_gtid_pos.empty())
|
||||
{
|
||||
send_buf = add_prefix_wait_gtid(target->server(), send_buf);
|
||||
m_wait_gtid = WAITING_FOR_HEADER;
|
||||
|
@ -363,9 +363,7 @@ GWBUF* RWSplitSession::handle_causal_read_reply(GWBUF *writebuf, SRWBackend& bac
|
||||
{
|
||||
if (GWBUF_IS_REPLY_OK(writebuf) && backend == m_current_master)
|
||||
{
|
||||
/** Save gtid position */
|
||||
char *tmp = gwbuf_get_property(writebuf, MXS_LAST_GTID);
|
||||
if (tmp)
|
||||
if (char *tmp = gwbuf_get_property(writebuf, MXS_LAST_GTID))
|
||||
{
|
||||
m_gtid_pos = std::string(tmp);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user