1
0
mirror of https://github.com/MariaDB/server.git synced 2025-08-08 11:22:35 +03:00

MDEV-18450 Slaves wait shutdown

The patches features an optional shutdown behavior to hold on until
after all connected slaves have been sent the last binlogged event.
The connected slave is one whose START SLAVE has been acknowledged and
that was not stopped since that though it could be technically
reconnecting in background.

The solution therefore disallows killing the dump thread until is has
found EOF of the latest binlog file.  It is up to the shutdown
requester (DBA) to set up a sufficiently large shutdown timeout value
for shudown to wait patiently until lagging behind slaves have been
synchronized. On the other hand if a specific slave needs exclusion
from synchronization the DBA would have to stop it manually which
would terminate its dump thread.

`mysqladmin shutdown' is extended with a `--wait_for_all_slaves' option
which translates to `SHUTDOW WAIT FOR ALL SLAVES' sql query
to enable the feature on the client side.

The patch also performs a small refactoring of the server shutdown
around close_connections() to introduce kill thread phases which
are two as of current.
This commit is contained in:
Sergey Vojtovich
2019-03-07 08:12:26 +04:00
committed by Andrei Elkin
parent e450527938
commit 3568427d11
19 changed files with 459 additions and 54 deletions

View File

@@ -0,0 +1,83 @@
--connection server_1
CREATE TABLE t1 (a INT) ENGINE=innodb;
--save_master_pos
--connection server_2
--sync_with_master
--connection server_3
--sync_with_master
--connection server_4
--source include/stop_slave.inc
--connection server_1
--disable_query_log
--let $count=1000
while ($count)
{
INSERT INTO t1 SET a=1;
--dec $count
}
--enable_query_log
--save_master_pos
# Shutdown master and restart server_4 who will be waiting for the master
# to start replication at its shutdown beginning phase.
# The being forked out server_4 dump thread must relate to a record
# in slave_list, and it won't start sending out binlog events
# until has received a signal from the shutdown thread.
# This also proves delivery to a started-in-middle-of-shutdown slave.
--connection server_1
SET @@GLOBAL.debug_dbug="+d,simulate_delay_at_shutdown";
--connection server_4
--source include/start_slave.inc
--connection server_1
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
wait
EOF
# --shutdown_server 60
--send SHUTDOWN WAIT FOR ALL SLAVES
--reap
--source include/wait_until_disconnected.inc
#
# MDEV-18450 liveness condition:
# Despite shutdown even "late" slave #4 is in sync
#
--connection server_4
--sync_with_master
--connection server_3
--sync_with_master
--connection server_2
--sync_with_master
--connection server_1
--append_file $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
restart
EOF
--connection default
--enable_reconnect
--source include/wait_until_connected_again.inc
--connection server_1
--enable_reconnect
--source include/wait_until_connected_again.inc
#
# Cleanup
#
--connection server_1
DROP TABLE t1;
--connection server_2
--source include/start_slave.inc
--connection server_3
--source include/start_slave.inc
--connection server_4
--source include/start_slave.inc