Commit e6bd4762 authored by Kristian Nielsen's avatar Kristian Nielsen

Test case for provisioning a slave with mariabackup --no-lock

Signed-off-by: default avatarKristian Nielsen <knielsen@knielsen-hq.org>
parent 167fe664
[mysqld.1]
log-slave-updates
loose-innodb
[mysqld.2]
log-slave-updates
loose-innodb
[ENV]
SERVER_MYPORT_1= @mysqld.1.port
SERVER_MYSOCK_1= @mysqld.1.socket
SERVER_MYPORT_2= @mysqld.2.port
SERVER_MYSOCK_2= @mysqld.2.socket
RESET MASTER;
CREATE TABLE t1(a varchar(60) PRIMARY KEY, b VARCHAR(60)) ENGINE INNODB;
INSERT INTO t1 VALUES(1, NULL);
CREATE TABLE t2 (val INT) ENGINE=InnoDB;
INSERT INTO t2 VALUES (0);
connect con1,localhost,root,,;
*** Start a background load...
CALL gen_load();
connection default;
*** Doing backup...
*** Doing prepare...
*** Stop the background load...
UPDATE t2 SET val=1;
connection con1;
connection default;
disconnect con1;
*** Provision a new slave from the backup
connect server2,127.0.0.1,root,,,$SERVER_MYPORT_2;
*** Stopping provisioned server
*** Removing old datadir for provisioned server
*** Provision new server from backup
# restart
*** Configure slave position from xtrabackup_binlog_pos_innodb
CREATE TABLE t3 (file VARCHAR(255), pos INT) ENGINE=InnoDB;
LOAD DATA LOCAL INFILE "BASEDIR/xtrabackup_binlog_pos_innodb"
INTO TABLE t3 FIELDS ESCAPED BY '' (file, pos);
CHANGE MASTER TO
master_port=PORT, master_host='127.0.0.1', master_user='root',
master_log_file= "MASTER_FILE",
master_log_pos= MASTER_POS;
START SLAVE;
connection default;
connection server2;
connection server2;
STOP SLAVE;
RESET SLAVE ALL;
DROP PROCEDURE gen_load;
DROP TABLE t1, t2, t3;
connection default;
DROP PROCEDURE gen_load;
DROP TABLE t1, t2;
--source include/have_innodb.inc
--source include/have_log_bin.inc
# Test provisioning a slave from an existing server, using mariabackup --no-lock
# and the binlog position recovered from InnoDB redo log.
let $basedir=$MYSQLTEST_VARDIR/tmp/backup;
RESET MASTER;
CREATE TABLE t1(a varchar(60) PRIMARY KEY, b VARCHAR(60)) ENGINE INNODB;
INSERT INTO t1 VALUES(1, NULL);
CREATE TABLE t2 (val INT) ENGINE=InnoDB;
INSERT INTO t2 VALUES (0);
--disable_query_log
--delimiter //
CREATE PROCEDURE gen_load()
MODIFIES SQL DATA
BEGIN
DECLARE i INT;
DECLARE flag TYPE OF t2.val;
SET i = 0;
load_loop: LOOP
SELECT val INTO flag FROM t2;
IF NOT (flag=0) THEN
LEAVE load_loop;
END IF;
START TRANSACTION;
INSERT INTO t1 VALUES (CONCAT("AbAdCaFe", LPAD(i, 6, "0")), @@SESSION.last_gtid);
COMMIT;
SET i = i + 1;
END LOOP;
END
//
--delimiter ;
--enable_query_log
connect (con1,localhost,root,,);
--echo *** Start a background load...
send CALL gen_load();
--connection default
--echo *** Doing backup...
--exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --backup --target-dir=$basedir --no-lock
--echo *** Doing prepare...
--exec $XTRABACKUP --prepare --rollback-xa --binlog-info=1 --target-dir=$basedir
--echo *** Stop the background load...
UPDATE t2 SET val=1;
--connection con1
reap;
--connection default
disconnect con1;
--let $count_master= `SELECT COUNT(*) FROM t1`
--echo *** Provision a new slave from the backup
--connect (server2,127.0.0.1,root,,,$SERVER_MYPORT_2)
--let $datadir_2= `SELECT @@datadir`
--echo *** Stopping provisioned server
--source include/shutdown_mysqld.inc
--echo *** Removing old datadir for provisioned server
--rmdir $datadir_2
--echo *** Provision new server from backup
--exec $XTRABACKUP --copy-back --datadir=$datadir_2 --target-dir=$basedir
--source include/start_mysqld.inc
--echo *** Configure slave position from xtrabackup_binlog_pos_innodb
CREATE TABLE t3 (file VARCHAR(255), pos INT) ENGINE=InnoDB;
--replace_result $basedir BASEDIR
--disable_warnings
eval LOAD DATA LOCAL INFILE "$basedir/xtrabackup_binlog_pos_innodb"
INTO TABLE t3 FIELDS ESCAPED BY '' (file, pos);
--enable_warnings
# Remove leading ./ from filename (leading .\ on windows).
--let provision_master_file= `SELECT REGEXP_REPLACE(file, "^[.].", "") FROM t3`
--let provision_master_pos= `SELECT pos FROM t3`
--replace_result $SERVER_MYPORT_1 PORT $provision_master_file MASTER_FILE $provision_master_pos MASTER_POS
eval CHANGE MASTER TO
master_port=$SERVER_MYPORT_1, master_host='127.0.0.1', master_user='root',
master_log_file= "$provision_master_file",
master_log_pos= $provision_master_pos;
START SLAVE;
--connection default
--save_master_pos
--connection server2
--sync_with_master
--let $count_slave= `SELECT COUNT(*) FROM t1`
if ($count_master != $count_slave) {
--echo *** ERROR: Table on master has $count_master rows, but table on provisioned slave has $count_slave rows
--die Row difference on provisioned slave.
}
# Cleanup
--connection server2
STOP SLAVE;
RESET SLAVE ALL;
DROP PROCEDURE gen_load;
DROP TABLE t1, t2, t3;
--connection default
DROP PROCEDURE gen_load;
DROP TABLE t1, t2;
rmdir $basedir;
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