Commit 8fbad587 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-33342 Add a replication MTR test cloning the slave with mariadb-backup

parent 68c1fbfc
include/master-slave.inc
[connection master]
#
# MDEV-33342 Add a replication MTR test cloning the slave with mariadb-backup
#
connection master;
connection slave;
##############################################################
### Initial block with some transactions
### Slave: Make sure replication is not using GTID
connection slave;
# Using_Gtid=No
### Master: Create and populate t1
connection master;
CREATE TABLE t1(a TEXT) ENGINE=InnoDB;
START TRANSACTION;
INSERT INTO t1 VALUES ('tr#00:stmt#00 - slave run#0, before backup');
INSERT INTO t1 VALUES ('tr#00:stmt#01 - slave run#0, before backup');
INSERT INTO t1 VALUES ('tr#00:stmt#02 - slave run#0, before backup');
COMMIT;
connection slave;
##############################################################
### Run the last transaction before mariadb-backup --backup
### Remember SHOW MASTER STATUS and @@gtid_binlog_pos
### before and after the transaction.
### Master: Rember MASTER STATUS and @@gtid_binlog_pos before tr#01
connection master;
### Slave: Remember MASTER STATUS and @@gtid_binlog_pos before tr#01
connection slave;
### Master: Run the actual last transaction before the backup
connection master;
START TRANSACTION;
INSERT INTO t1 VALUES ('tr#01:stmt#00 - slave run#0, before backup');
INSERT INTO t1 VALUES ('tr#01:stmt#01 - slave run#0, before backup');
INSERT INTO t1 VALUES ('tr#01:stmt#02 - slave run#0, before backup');
COMMIT;
connection slave;
### Master: Remember MASTER STATUS and @@gtid_binlog_pos after tr#01
connection master;
### Slave: Remember MASTER STATUS and @@gtid_binlog_pos after tr#01
connection slave;
##############################################################
### Running `mariadb-backup --backup,--prepare` and checking
### that xtrabackup_slave_info and xtrabackup_binlog_info are OK
### Slave: Create a backup
### Slave: Prepare the backup
### Slave: xtrabackup files:
############################ xtrabackup_slave_info
CHANGE MASTER TO MASTER_LOG_FILE='master_after_tr01_show_master_status_file', MASTER_LOG_POS=master_after_tr01_show_master_status_position;
############################ xtrabackup_binlog_info
slave_after_tr01_show_master_status_file slave_after_tr01_show_master_status_position slave_after_tr01_gtid_binlog_pos
############################
##############################################################
### Run more transactions after the backup:
### - while the slave is still running, then
### - while the slave is shut down
### Master: Run another transaction while the slave is still running
connection master;
START TRANSACTION;
INSERT INTO t1 VALUES ('tr#02:stmt#00 - slave run#0, after backup');
INSERT INTO t1 VALUES ('tr#02:stmt#01 - slave run#0, after backup');
INSERT INTO t1 VALUES ('tr#02:stmt@02 - slave run#0, after backup');
COMMIT;
connection slave;
### Master: Remember MASTER STATUS and @@gtid_binlog_pos after tr#02
connection master;
### Slave: Remember MASTER STATUS and @@gtid_binlog_pos after tr#02
connection slave;
### Master: Checking SHOW BINLOG EVENTS
connection master;
SHOW BINLOG EVENTS FROM master_after_tr01_show_master_status_position LIMIT 0,1;
Log_name master_after_tr01_show_master_status_file
Pos master_after_tr01_show_master_status_position
Event_type Gtid
Server_id #
End_log_pos #
Info BEGIN GTID master_after_tr02_gtid_binlog_pos
SHOW BINLOG EVENTS FROM master_after_tr01_show_master_status_position LIMIT 1,1;
Log_name master_after_tr01_show_master_status_file
Pos #
Event_type Query_or_Annotate_rows
Server_id #
End_log_pos #
Info INSERT INTO t1 VALUES ('tr#02:stmt#00 - slave run#0, after backup')
### Slave: Checking SHOW BINLOG EVENTS
connection slave;
SHOW BINLOG EVENTS FROM slave_after_tr01_show_master_status_position LIMIT 0,1;
Log_name slave_after_tr01_show_master_status_file
Pos #
Event_type Gtid
Server_id 1
End_log_pos #
Info BEGIN GTID slave_after_tr02_gtid_binlog_pos
SHOW BINLOG EVENTS FROM slave_after_tr01_show_master_status_position LIMIT 1,1;
Log_name slave_after_tr01_show_master_status_file
Pos #
Event_type Query_or_Annotate_rows
Server_id #
End_log_pos #
Info INSERT INTO t1 VALUES ('tr#02:stmt#00 - slave run#0, after backup')
### Slave: Shutdown the server
include/rpl_stop_server.inc [server_number=2]
### Master: Run a transaction while the slave is shut down
connection master;
START TRANSACTION;
INSERT INTO t1 VALUES ('tr#03:stmt#00 - after slave run#0, slave is shut down, after backup');
INSERT INTO t1 VALUES ('tr#03:stmt#01 - after slave run#0, slave is shut down, after backup');
INSERT INTO t1 VALUES ('tr#03:stmt#02 - after slave run#0, slave is shut down, after backup');
COMMIT;
##############################################################
### Emulate starting a new virgin slave
### Slave: Remove the data directory
### Slave: Copy back the backup
### Slave: Restart the server
include/rpl_start_server.inc [server_number=2]
connection slave;
### Slave: Display the restored data before START SLAVE
connection slave;
SELECT * FROM t1 ORDER BY a;
a
tr#00:stmt#00 - slave run#0, before backup
tr#00:stmt#01 - slave run#0, before backup
tr#00:stmt#02 - slave run#0, before backup
tr#01:stmt#00 - slave run#0, before backup
tr#01:stmt#01 - slave run#0, before backup
tr#01:stmt#02 - slave run#0, before backup
### Slave: Execute the CHANGE MASTER statement to set up the host and port
CHANGE MASTER '' TO MASTER_USER='root', MASTER_HOST='127.0.0.1', MASTER_PORT=###, MASTER_CONNECT_RETRY=1;
### Slave: Execute the CHANGE MASTER statement from xtrabackup_slave_info
CHANGE MASTER TO MASTER_LOG_FILE='master_after_tr01_show_master_status_file', MASTER_LOG_POS=master_after_tr01_show_master_status_position;
### Slave: Execute START SLAVE
include/start_slave.inc
### Master: Wait for the slave to apply all master events
connection master;
connection slave;
### Slave: Make sure replication is not using GTID after the slave restart
connection slave;
# Using_Gtid=No
### Slave: Display the restored data after START SLAVE
connection slave;
SELECT * FROM t1 ORDER BY a;
a
tr#00:stmt#00 - slave run#0, before backup
tr#00:stmt#01 - slave run#0, before backup
tr#00:stmt#02 - slave run#0, before backup
tr#01:stmt#00 - slave run#0, before backup
tr#01:stmt#01 - slave run#0, before backup
tr#01:stmt#02 - slave run#0, before backup
tr#02:stmt#00 - slave run#0, after backup
tr#02:stmt#01 - slave run#0, after backup
tr#02:stmt@02 - slave run#0, after backup
tr#03:stmt#00 - after slave run#0, slave is shut down, after backup
tr#03:stmt#01 - after slave run#0, slave is shut down, after backup
tr#03:stmt#02 - after slave run#0, slave is shut down, after backup
##############################################################
### Continue master transactions, check the new slave replicates well.
### Master: Run a transaction after restarting replication
connection master;
START TRANSACTION;
INSERT INTO t1 VALUES ('tr#04:stmt#00 - slave run#1');
INSERT INTO t1 VALUES ('tr#04:stmt#01 - slave run#1');
INSERT INTO t1 VALUES ('tr#04:stmt#02 - slave run#1');
COMMIT;
connection slave;
### Slave: Display the restored data + new transactions
connection slave;
SELECT * FROM t1 ORDER BY a;
a
tr#00:stmt#00 - slave run#0, before backup
tr#00:stmt#01 - slave run#0, before backup
tr#00:stmt#02 - slave run#0, before backup
tr#01:stmt#00 - slave run#0, before backup
tr#01:stmt#01 - slave run#0, before backup
tr#01:stmt#02 - slave run#0, before backup
tr#02:stmt#00 - slave run#0, after backup
tr#02:stmt#01 - slave run#0, after backup
tr#02:stmt@02 - slave run#0, after backup
tr#03:stmt#00 - after slave run#0, slave is shut down, after backup
tr#03:stmt#01 - after slave run#0, slave is shut down, after backup
tr#03:stmt#02 - after slave run#0, slave is shut down, after backup
tr#04:stmt#00 - slave run#1
tr#04:stmt#01 - slave run#1
tr#04:stmt#02 - slave run#1
##############################################################
### Cleanup
### Removing the backup directory
connection master;
DROP TABLE t1;
connection slave;
include/rpl_end.inc
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment