Skip to content

Commit

Permalink
Set 'max_replication_lag' and an extra wait for test 'reg_test_1574-s…
Browse files Browse the repository at this point in the history
…tmt_metadata-t' to avoid replication lag issues in CI
  • Loading branch information
JavierJF committed Feb 18, 2021
1 parent 88512b6 commit 96a56a9
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion test/tap/tests/reg_test_1574-stmt_metadata-t.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ int main(int argc, char** argv) {
return exit_status();
}

// Set a replication lag inferior to default one (60). This is to prevent reads
// from a replica in which replication is currently disabled.
MYSQL_QUERY(proxysql_admin, "UPDATE mysql_servers SET max_replication_lag=20");
MYSQL_QUERY(proxysql_admin, "LOAD MYSQL SERVERS TO RUNTIME");

MYSQL_QUERY(proxysql_mysql, "CREATE DATABASE IF NOT EXISTS test");
MYSQL_QUERY(proxysql_mysql, "DROP TABLE IF EXISTS test.reg_test_1574");
MYSQL_QUERY(proxysql_mysql, "CREATE TABLE IF NOT EXISTS test.reg_test_1574 (id INT NOT NULL AUTO_INCREMENT PRIMARY KEY, `c2` varchar(32))");
Expand Down Expand Up @@ -111,6 +116,9 @@ int main(int argc, char** argv) {
MYSQL_QUERY(proxysql_mysql, "ALTER TABLE test.reg_test_1574 ADD c1 BIGINT AFTER id");
MYSQL_QUERY(proxysql_mysql, "INSERT INTO test.reg_test_1574 (c1,c2) VALUES (100, 'abcde')");

// Wait for ProxySQL to detect replication issues and in case of slow replication itself
sleep(10);

// Check that ProxySQL cached metadata for the query has the old information
std::string num_columns_query_t = "SELECT num_columns FROM stats.stats_mysql_prepared_statements_info WHERE query='%s'";
std::string num_columns_query (static_cast<std::size_t>(num_columns_query_t.size() + query.size()), '\0');
Expand Down Expand Up @@ -183,7 +191,7 @@ int main(int argc, char** argv) {

ok(
data_match_expected,
"Prepared statement result matches expected - Exp=(id:1, c1:100, c2:'abcde'), Act=(id:%d, c1:%d, c2:'%s')",
"Prepared statement result matches expected - Exp=(id:1, c1:100, c2:'abcde'), Act=(id:%d, c1:%ld, c2:'%s')",
data_id,
data_c1,
data_c2
Expand Down

0 comments on commit 96a56a9

Please sign in to comment.