mirror of
https://github.com/MariaDB/server.git
synced 2025-08-07 00:04:31 +03:00
MDEV-19801: Change defaults for CHANGE MASTER TO so that GTID-based replication is used by default if master supports it
This commit makes replicas crash-safe by default by changing the Using_Gtid value to be Slave_Pos on a fresh slave start and after RESET SLAVE is issued. If the primary server does not support GTIDs (i.e., version < 10), the replica will fall back to Using_Gtid=No on slave start and after RESET SLAVE. The following additional informational messages/warnings are added: 1. When Using_Gtid is automatically changed. That is, if RESET SLAVE reverts Using_Gtid back to Slave_Pos, or Using_Gtid is inferred to No from a CHANGE MASTER TO given with log coordinates without MASTER_USE_GTID. 2. If options are ignored in CHANGE MASTER TO. If CHANGE MASTER TO is given with log coordinates, yet also specifies MASTER_USE_GTID=Slave_Pos, a warning message is given that the log coordinate options are ignored. Additionally, an MTR macro has been added for RESET SLAVE, reset_slave.inc, which provides modes/options for resetting a slave in log coordinate or gtid modes. When in log coordinates mode, the macro will execute CHANGE MASTER TO MASTER_USE_GTID=No after the RESET SLAVE command. When in GTID mode, an extra parameter, reset_slave_keep_gtid_state, can be set to reset or preserve the value of gtid_slave_pos. Reviewed By: =========== Andrei Elkin <andrei.elkin@mariadb.com>
This commit is contained in:
58
mysql-test/include/reset_slave.inc
Normal file
58
mysql-test/include/reset_slave.inc
Normal file
@@ -0,0 +1,58 @@
|
||||
# ==== Purpose ====
|
||||
#
|
||||
# Reset the slave on the active connection
|
||||
#
|
||||
#
|
||||
# ==== Usage ====
|
||||
#
|
||||
# [--let $master_use_gtid_option= NO]
|
||||
# --source include/rpl_reset_slave.inc
|
||||
#
|
||||
# Parameters:
|
||||
# $master_use_gtid_option
|
||||
# Sets the context for the reset slave. When No, execute
|
||||
# CHANGE MASTER TO MASTER_USE_GTID=No after the RESET SLAVE. When
|
||||
# Slave_Pos, execute set gtid_slave_pos= "" after RESET SLAVE.
|
||||
#
|
||||
# $reset_slave_keep_gtid_state
|
||||
# When master_use_gtid_option is Slave_Pos, this defines whether or not
|
||||
# gtid_slave_pos will be reset as well. Accepted values are of boolean
|
||||
# type. Default value is false.
|
||||
#
|
||||
|
||||
--let $include_filename= reset_slave.inc
|
||||
--source include/begin_include_file.inc
|
||||
|
||||
|
||||
if (!$rpl_debug)
|
||||
{
|
||||
--disable_query_log
|
||||
}
|
||||
|
||||
if (!$master_use_gtid_option)
|
||||
{
|
||||
--let $master_use_gtid_option= Slave_Pos
|
||||
}
|
||||
|
||||
if (!$reset_slave_keep_gtid_state)
|
||||
{
|
||||
--let $reset_slave_keep_gtid_state=0
|
||||
}
|
||||
|
||||
if (`SELECT strcmp("$master_use_gtid_option","Slave_Pos") != 0 AND strcmp("$master_use_gtid_option","No") != 0`)
|
||||
{
|
||||
die Invalid option provided as master_use_gtid_option, Slave_Pos or No are the only allowed options;
|
||||
}
|
||||
|
||||
RESET SLAVE;
|
||||
if (`SELECT strcmp("$master_use_gtid_option","Slave_Pos") = 0 AND NOT $reset_slave_keep_gtid_state`)
|
||||
{
|
||||
SET @@GLOBAL.gtid_slave_pos= "";
|
||||
}
|
||||
if (`SELECT strcmp("$master_use_gtid_option","No") = 0`)
|
||||
{
|
||||
CHANGE MASTER TO MASTER_USE_GTID=No;
|
||||
}
|
||||
|
||||
--let $include_filename= reset_slave.inc
|
||||
--source include/end_include_file.inc
|
Reference in New Issue
Block a user