From 74c189c3124a0ada02b51227a57e0ec851d057a0 Mon Sep 17 00:00:00 2001 From: Brandon Nesterenko Date: Tue, 29 Apr 2025 09:57:52 -0600 Subject: [PATCH] MDEV-35304: Fix multi_source.connects_tried Test multi_source.connects tried would sporadically fail with a result mismatch resembling the following diff: @@ -29,6 +29,7 @@ SELECT @time_begin, CURRENT_TIMESTAMP(1) WHERE TIMESTAMPDIFF(SECOND, @time_begin, CURRENT_TIMESTAMP(1)) < 1; @time_begin CURRENT_TIMESTAMP(1) +2025-04-28 17:10:08.3 2025-04-28 17:10:09.2 CREATE TEMPORARY TABLE status_sleep AS SELECT 'named' Connection_name, Connects_Tried Connects_Tried; SET @@SESSION.default_master_connection= ''; include/wait_for_slave_param.inc [Connects_Tried] This happened due to the reference variable @time_begin being set _after_ the slave was started. That is, @time_begin was used as the anchor point at which the time should start ticking for when Connects_Tried should be incremented; however, MTR may not actually be able to set it for some time after the slave had started due to OS scheduling or heavy server load. The failure can be reproduced by adding a 0.1s sleep statement in-between the aformentioned statements. The fix is to set @time_begin before starting the slave so it is at least always valid to reference as the start of the test case. --- mysql-test/suite/multi_source/connects_tried.result | 2 +- mysql-test/suite/multi_source/connects_tried.test | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/mysql-test/suite/multi_source/connects_tried.result b/mysql-test/suite/multi_source/connects_tried.result index fa92b572b4c..5fb686794c8 100644 --- a/mysql-test/suite/multi_source/connects_tried.result +++ b/mysql-test/suite/multi_source/connects_tried.result @@ -10,8 +10,8 @@ SELECT Connection_name, Connects_Tried FROM information_schema.SLAVE_STATUS; Connection_name Connects_Tried 0 named 0 -START ALL SLAVES; SET @time_begin= CURRENT_TIMESTAMP(1); +START ALL SLAVES; SET @@SESSION.default_master_connection= 'named'; include/wait_for_slave_io_error.inc [errno=2003] SET @@SESSION.default_master_connection= ''; diff --git a/mysql-test/suite/multi_source/connects_tried.test b/mysql-test/suite/multi_source/connects_tried.test index f8a014a5180..95dbb44274f 100644 --- a/mysql-test/suite/multi_source/connects_tried.test +++ b/mysql-test/suite/multi_source/connects_tried.test @@ -24,8 +24,8 @@ CHANGE MASTER TO master_connect_retry=2; SELECT Connection_name, Connects_Tried FROM information_schema.SLAVE_STATUS; --disable_warnings -START ALL SLAVES; # will fail because the masters are down SET @time_begin= CURRENT_TIMESTAMP(1); +START ALL SLAVES; # will fail because the masters are down --enable_warnings # CR_CONN_HOST_ERROR --let $slave_io_errno= 2003