From dd95c58b5864c8b6f57630df67afd19a9552350e Mon Sep 17 00:00:00 2001 From: Brandon Nesterenko Date: Tue, 30 Jan 2024 21:50:13 +0100 Subject: [PATCH] MDEV-33331: IO Thread Relay Log Inconsistent Statistics After MDEV-32551 After MDEV-32551, in a master/slave setup, if the replica's IO thread quickly and successively reconnects (i.e quickly running STOP SLAVE IO_THREAD followed by START SLAVE IO_THREAD), the relay log rotation behavior changes. That is, MDEV-32551 changed the logic of the binlog_dump_thread on the primary, such that it can stop itself before sending any events if it sees a new connection has been created to a replica with the same server_id. Pre MDEV-32551, the connection would establish and it would send a "fake" rotate event to populate the log name. Post MDEV-32551, the connection stops itself, and a rotate event is not sent. This made the test rpl.rpl_mariadb_slave_capability unstable because it is reliant on the name of the relay logs (which is dependent on the number of rotates); and the pre-amble of the test would quickly start/stop the IO thread. There a binlog dump thread could end itself before sending a rotate event to the replica, thereby changing the name of the relay log. This patch fixes this by adding in a synchronization in-between IO thread restarts, such that it waits for the primary's binlog dump threads to sync up with the state of the replica. --- .../suite/rpl/r/rpl_mariadb_slave_capability.result | 5 +++++ .../suite/rpl/t/rpl_mariadb_slave_capability.test | 12 ++++++++++++ 2 files changed, 17 insertions(+) diff --git a/mysql-test/suite/rpl/r/rpl_mariadb_slave_capability.result b/mysql-test/suite/rpl/r/rpl_mariadb_slave_capability.result index 68e8b22dd02..fddb07c9cbf 100644 --- a/mysql-test/suite/rpl/r/rpl_mariadb_slave_capability.result +++ b/mysql-test/suite/rpl/r/rpl_mariadb_slave_capability.result @@ -6,6 +6,11 @@ connection slave; include/stop_slave.inc CHANGE MASTER TO MASTER_USE_GTID=NO; include/start_slave.inc +connection master; +# Ensure only the new binlog dump thread is alive (wait for the old one +# to complete its kill) +# And that it has already sent its fake rotate +connection slave; include/stop_slave.inc # Test slave with no capability gets dummy event, which is ignored. set @old_dbug= @@global.debug_dbug; diff --git a/mysql-test/suite/rpl/t/rpl_mariadb_slave_capability.test b/mysql-test/suite/rpl/t/rpl_mariadb_slave_capability.test index 2ad9124d886..ee890a8fd03 100644 --- a/mysql-test/suite/rpl/t/rpl_mariadb_slave_capability.test +++ b/mysql-test/suite/rpl/t/rpl_mariadb_slave_capability.test @@ -18,6 +18,18 @@ connection slave; CHANGE MASTER TO MASTER_USE_GTID=NO; --source include/start_slave.inc +--connection master +--echo # Ensure only the new binlog dump thread is alive (wait for the old one +--echo # to complete its kill) +--let $wait_condition= select count(*)=1 from information_schema.processlist where command='Binlog Dump' +--source include/wait_condition.inc + +--echo # And that it has already sent its fake rotate +--let $wait_condition= select count(*)=1 from information_schema.processlist where state LIKE '%Master has sent all binlog to slave%' and command='Binlog Dump' +--source include/wait_condition.inc + + +--connection slave --source include/stop_slave.inc --echo # Test slave with no capability gets dummy event, which is ignored. set @old_dbug= @@global.debug_dbug;