diff --git a/test/tap/tests/reg_test_1574-stmt_metadata-t.cpp b/test/tap/tests/reg_test_1574-stmt_metadata-t.cpp index 8cfdd87613..dae9044981 100644 --- a/test/tap/tests/reg_test_1574-stmt_metadata-t.cpp +++ b/test/tap/tests/reg_test_1574-stmt_metadata-t.cpp @@ -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))"); @@ -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(num_columns_query_t.size() + query.size()), '\0'); @@ -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