From 26c5a2572451672232869e62eba2cf147c75f328 Mon Sep 17 00:00:00 2001 From: Rene Cannao Date: Sun, 5 Apr 2026 05:59:42 +0000 Subject: [PATCH] Fix read_only test assuming default_hostgroup=0 The test configures mysql_servers with writer_hostgroup=0 and reader_hostgroup=1, but the CI infrastructure sets users' default_hostgroup to 1300. When the test opens a proxy connection and runs BEGIN, ProxySQL routes to hostgroup 1300 which has no servers, causing a 10s timeout. Fix by setting default_hostgroup=0 for the test user at the start of each scenario. --- ...ad_only_actions_offline_hard_servers-t.cpp | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/test/tap/tests/test_read_only_actions_offline_hard_servers-t.cpp b/test/tap/tests/test_read_only_actions_offline_hard_servers-t.cpp index 5f0762d6e..60d315fba 100644 --- a/test/tap/tests/test_read_only_actions_offline_hard_servers-t.cpp +++ b/test/tap/tests/test_read_only_actions_offline_hard_servers-t.cpp @@ -210,6 +210,14 @@ int test_scenario_1(MYSQL* proxy_admin, const CommandLine& cl) { MYSQL_QUERY__(proxy_admin, "DELETE FROM mysql_replication_hostgroups"); MYSQL_QUERY__(proxy_admin, "LOAD MYSQL SERVERS TO RUNTIME"); + // Set default_hostgroup=0 to match writer_hostgroup used in this test + { + std::string update_user; + string_format("UPDATE mysql_users SET default_hostgroup=0 WHERE username='%s'", update_user, cl.root_username); + MYSQL_QUERY__(proxy_admin, update_user.c_str()); + MYSQL_QUERY__(proxy_admin, "LOAD MYSQL USERS TO RUNTIME"); + } + MYSQL_QUERY__(proxy_admin, "SET mysql-monitor_read_only_interval=200"); // setting read_only variables MYSQL_QUERY__(proxy_admin, "SET mysql-monitor_read_only_timeout=100"); MYSQL_QUERY__(proxy_admin, "SET mysql-monitor_enabled='true'"); // enabling monitor @@ -225,14 +233,14 @@ int test_scenario_1(MYSQL* proxy_admin, const CommandLine& cl) { ok(read_only_val == 0, "MySQL Server '%s:%d' should function as a writer", cl.mysql_host, cl.mysql_port); - // Inserting new records into 'mysql_servers' and 'mysql_replication_hostgroups'. + // Inserting new records into 'mysql_servers' and 'mysql_replication_hostgroups'. result = insert_mysql_servers_records(proxy_admin, insert_mysql_servers_values, insert_replication_hostgroups_values); if (result != EXIT_SUCCESS) { fprintf(stderr, "File %s, line %d, Error: `%s`\n", __FILE__, __LINE__, "Failed to insert records in mysql_servers table."); goto cleanup; } - + std::string variable_val; // get read_only interval variable value @@ -363,6 +371,14 @@ int test_scenario_2(MYSQL* proxy_admin, const CommandLine& cl) { MYSQL_QUERY__(proxy_admin, "DELETE FROM mysql_replication_hostgroups"); MYSQL_QUERY__(proxy_admin, "LOAD MYSQL SERVERS TO RUNTIME"); + // Set default_hostgroup=0 to match writer_hostgroup used in this test + { + std::string update_user; + string_format("UPDATE mysql_users SET default_hostgroup=0 WHERE username='%s'", update_user, cl.root_username); + MYSQL_QUERY__(proxy_admin, update_user.c_str()); + MYSQL_QUERY__(proxy_admin, "LOAD MYSQL USERS TO RUNTIME"); + } + MYSQL_QUERY__(proxy_admin, "SET mysql-monitor_read_only_interval=200"); // setting read_only variables MYSQL_QUERY__(proxy_admin, "SET mysql-monitor_read_only_timeout=100"); MYSQL_QUERY__(proxy_admin, "SET mysql-monitor_writer_is_also_reader='false'");