mirror of https://github.com/sysown/proxysql
fix(tests): resolve flaky failures in pgsql-copy_from_stdin_session_parameter-t and test_dns_cache-t
1. pgsql-copy_from_stdin_session_parameter-t: race condition in log file reading The test's check_logs_for_command() performed a single stream-based read via get_matching_lines() to find the "Switching back to Normal mode" log line. When ProxySQL hadn't flushed the log entry yet (observed window as tight as ~23 microseconds between PQgetResult returning and the check), the read would miss the line, causing a false test failure. The log line was always present in the final file, confirming this is a timing issue. Fix: Replace the single-shot read with a retry loop (up to 10 attempts, 10ms each = 100ms total). If all stream-based retries fail, fall back to get_matching_lines_from_filename() which opens a fresh file handle, avoiding any stream position issues entirely. Add a global g_proxysql_log_path to support the filename-based fallback. 2. test_dns_cache-t: spurious dns_cache_queried counter increment in Step 9 Step 9 disables the DNS cache refresh interval (set to 0) and expects dns_cache_queried to remain unchanged (equal_to). However, INVALID_DOMAIN was still in mysql_servers from Step 8, so when "DO 1" queries were routed through hostgroup 999, the connection routing layer called MySQL_Monitor::dns_lookup() -> DNS_Cache::lookup(), incrementing the counter by exactly 1 regardless of the refresh interval setting. Fix: Before the measurement window in Step 9, replace INVALID_DOMAIN with 0.0.0.0 in mysql_servers. Since 0.0.0.0 is a valid IP address, dns_lookup() returns immediately without consulting the DNS cache (early return at MySQL_Monitor.cpp:6675), so the counter stays unchanged as expected. Both fixes verified: each test passes in isolation against legacy infra.mariadb-rpl-helper
parent
98083cdf0f
commit
d7c4a1a94c
Loading…
Reference in new issue