mirror of
				https://github.com/MariaDB/server.git
				synced 2025-11-03 14:33:32 +03:00 
			
		
		
		
	MDEV-6344: mysqldump issues FLUSH TABLES, which gets written into binlog and replicated Add a --gtid option (for compatibility, the original behaviour is preserved when --gtid is not used). With --gtid, --master-data and --dump-slave output the GTID position (the old-style file/offset position is still output, but commented out). Also, a CHANGE MASTER TO master_use_gtid=slave_pos is output to ensure a provisioned slave is configured in GTID, as requested. Without --gtid, the GTID position is still output, if available, but commented out. Also fix MDEV-6344, to avoid FLUSH TABLES getting into the binlog. Otherwise a mysqldump on a slave server will silently inject a GTID which does not exist on the master, which is highly undesirable. Also fix an incorrect error handling around obtaining binlog position with --master-data (was probably unlikely to trigger in most cases).
		
			
				
	
	
		
			89 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			89 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
--source include/master-slave.inc
 | 
						|
 | 
						|
--echo #
 | 
						|
--echo # New --dump-slave, --apply-slave-statements functionality
 | 
						|
--echo #
 | 
						|
 | 
						|
# There is a gap between when START SLAVE returns and when MASTER_LOG_FILE and
 | 
						|
# MASTER_LOG_POS are set.  Ensure that we don't call SHOW SLAVE STATUS during
 | 
						|
# that gap.
 | 
						|
--sync_slave_with_master
 | 
						|
 | 
						|
connection master;
 | 
						|
use test;
 | 
						|
 | 
						|
connection slave;
 | 
						|
 | 
						|
# Execute mysqldump with --dump-slave
 | 
						|
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
 | 
						|
--exec $MYSQL_DUMP_SLAVE --compact --dump-slave test
 | 
						|
 | 
						|
# Execute mysqldump with --dump-slave and --apply-slave-statements 
 | 
						|
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
 | 
						|
--exec $MYSQL_DUMP_SLAVE --compact --dump-slave --apply-slave-statements test
 | 
						|
 | 
						|
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
 | 
						|
--replace_result $MASTER_MYPORT MASTER_MYPORT
 | 
						|
# Execute mysqldump with --dump-slave ,--apply-slave-statements and --include-master-host-port
 | 
						|
--exec $MYSQL_DUMP_SLAVE --compact --dump-slave --apply-slave-statements --include-master-host-port test
 | 
						|
 | 
						|
#
 | 
						|
# MDEV-5624 mysqldump --dump-slave option does not restart the replication if the dump has failed
 | 
						|
#
 | 
						|
start slave;
 | 
						|
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
 | 
						|
--error 2
 | 
						|
--exec $MYSQL_DUMP_SLAVE --compact --dump-slave no_such_db
 | 
						|
start slave;
 | 
						|
 | 
						|
 | 
						|
--echo *** Test mysqldump --dump-slave GTID functionality.
 | 
						|
 | 
						|
--connection master
 | 
						|
SET gtid_seq_no = 1000;
 | 
						|
CREATE TABLE t1 (a INT PRIMARY KEY);
 | 
						|
DROP TABLE t1;
 | 
						|
--sync_slave_with_master
 | 
						|
 | 
						|
--connection slave
 | 
						|
# Inject a local transaction on the slave to check that this is not considered
 | 
						|
# for --dump-slave.
 | 
						|
CREATE TABLE t2 (a INT PRIMARY KEY);
 | 
						|
DROP TABLE t2;
 | 
						|
 | 
						|
--echo
 | 
						|
--echo 1. --dump-slave=1
 | 
						|
--echo
 | 
						|
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
 | 
						|
--exec $MYSQL_DUMP_SLAVE --compact --dump-slave=1 --gtid test
 | 
						|
 | 
						|
--echo
 | 
						|
--echo 2. --dump-slave=2
 | 
						|
--echo
 | 
						|
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
 | 
						|
--exec $MYSQL_DUMP_SLAVE --compact --dump-slave=2 --gtid test
 | 
						|
 | 
						|
 | 
						|
--echo *** Test mysqldump --master-data GTID functionality.
 | 
						|
--echo
 | 
						|
--echo 1. --master-data=1
 | 
						|
--echo
 | 
						|
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
 | 
						|
--exec $MYSQL_DUMP_SLAVE --compact --master-data=1 --gtid test
 | 
						|
 | 
						|
--echo
 | 
						|
--echo 2. --master-data=2
 | 
						|
--echo
 | 
						|
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
 | 
						|
--exec $MYSQL_DUMP_SLAVE --compact --master-data=2 --gtid test
 | 
						|
 | 
						|
--echo
 | 
						|
--echo 3. --master-data --single-transaction
 | 
						|
--echo
 | 
						|
--replace_regex /MASTER_LOG_POS=[0-9]+/MASTER_LOG_POS=BINLOG_START/
 | 
						|
--exec $MYSQL_DUMP_SLAVE --compact --master-data --single-transaction --gtid test
 | 
						|
 | 
						|
 | 
						|
 | 
						|
--source include/rpl_end.inc
 |