Commit 907e4c62 authored by Alexander Barkov's avatar Alexander Barkov

MDEV-21037 mariabackup does not detect multi-source replication slave

parent 3fec38d9
This diff is collapsed.
--disable_query_log
--file_exists $targetdir/xtrabackup_slave_info
CREATE TEMPORARY TABLE tmp_slave_info(lineno SERIAL, line TEXT);
--replace_result $targetdir TARGETDIR
--eval LOAD DATA LOCAL INFILE '$targetdir/xtrabackup_slave_info' INTO TABLE tmp_slave_info (line);
SELECT
lineno,
regexp_replace(
regexp_replace(line, '(?<=MASTER_LOG_POS=)[0-9]+', '<NUM>'),
'[0-9]+-[0-9]+-[0-9]+', '<NUM-NUM-NUM>')
AS line
FROM tmp_slave_info ORDER BY lineno;
DROP TEMPORARY TABLE tmp_slave_info;
--enable_query_log
--disable_query_log
--file_exists $XTRABACKUP_OUT
CREATE TEMPORARY TABLE tmp_slave_info_out(lineno SERIAL, line TEXT);
--replace_result $targetdir TARGETDIR
--eval LOAD DATA LOCAL INFILE '$XTRABACKUP_OUT' INTO TABLE tmp_slave_info_out (line);
SELECT
replace(
regexp_replace(
regexp_replace(line,
'[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9] [0-9][0-9]:[0-9][0-9]:[0-9][0-9]',
'YYYY-MM-DD hh:mm:ss'),
'[0-9]+-[0-9]+-[0-9]+', '<NUM-NUM-NUM>'),
'\r','' /* Remove CR on Windows */)
AS line
FROM tmp_slave_info_out
WHERE line LIKE '%MySQL slave binlog position%'
OR line LIKE '%Failed to get master binlog coordinates%'
ORDER BY lineno;
DROP TEMPORARY TABLE tmp_slave_info_out;
--enable_query_log
...@@ -13,6 +13,9 @@ connection slave; ...@@ -13,6 +13,9 @@ connection slave;
"using_gtid: Slave_Pos" "using_gtid: Slave_Pos"
FOUND 1 /gtid_slave_pos/ in xtrabackup_slave_info FOUND 1 /gtid_slave_pos/ in xtrabackup_slave_info
NOT FOUND /MASTER_LOG_FILE/ in xtrabackup_slave_info NOT FOUND /MASTER_LOG_FILE/ in xtrabackup_slave_info
lineno line
1 SET GLOBAL gtid_slave_pos = '<NUM-NUM-NUM>';
2 CHANGE MASTER TO master_use_gtid = slave_pos;
############### ###############
# If Using_Gtid != 'No' and !gtid_slave_pos, backup master position # If Using_Gtid != 'No' and !gtid_slave_pos, backup master position
######################## ########################
...@@ -20,6 +23,8 @@ include/stop_slave.inc ...@@ -20,6 +23,8 @@ include/stop_slave.inc
SET GLOBAL gtid_slave_pos=""; SET GLOBAL gtid_slave_pos="";
NOT FOUND /gtid_slave_pos/ in xtrabackup_slave_info NOT FOUND /gtid_slave_pos/ in xtrabackup_slave_info
FOUND 1 /MASTER_LOG_FILE/ in xtrabackup_slave_info FOUND 1 /MASTER_LOG_FILE/ in xtrabackup_slave_info
lineno line
1 CHANGE MASTER TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=<NUM>;
############### ###############
# If Using_Gtid == 'No', backup Exec_Master_Log_Pos # If Using_Gtid == 'No', backup Exec_Master_Log_Pos
######################## ########################
...@@ -31,6 +36,8 @@ connection slave; ...@@ -31,6 +36,8 @@ connection slave;
"using_gtid: No" "using_gtid: No"
NOT FOUND /gtid_slave_pos/ in xtrabackup_slave_info NOT FOUND /gtid_slave_pos/ in xtrabackup_slave_info
FOUND 1 /MASTER_LOG_FILE/ in xtrabackup_slave_info FOUND 1 /MASTER_LOG_FILE/ in xtrabackup_slave_info
lineno line
1 CHANGE MASTER TO MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=<NUM>;
connection master; connection master;
DROP TABLE t; DROP TABLE t;
connection slave; connection slave;
......
...@@ -27,6 +27,7 @@ exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group-suffi ...@@ -27,6 +27,7 @@ exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group-suffi
--source include/search_pattern_in_file.inc --source include/search_pattern_in_file.inc
--let SEARCH_PATTERN=MASTER_LOG_FILE --let SEARCH_PATTERN=MASTER_LOG_FILE
--source include/search_pattern_in_file.inc --source include/search_pattern_in_file.inc
--source include/show_xtrabackup_slave_info.inc
rmdir $targetdir; rmdir $targetdir;
...@@ -35,7 +36,9 @@ rmdir $targetdir; ...@@ -35,7 +36,9 @@ rmdir $targetdir;
--echo ######################## --echo ########################
--source include/stop_slave.inc --source include/stop_slave.inc
--disable_warnings
SET GLOBAL gtid_slave_pos=""; SET GLOBAL gtid_slave_pos="";
--enable_warnings
--let $targetdir=$MYSQLTEST_VARDIR/tmp/backup --let $targetdir=$MYSQLTEST_VARDIR/tmp/backup
--disable_result_log --disable_result_log
...@@ -47,6 +50,7 @@ exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group-suffi ...@@ -47,6 +50,7 @@ exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group-suffi
--source include/search_pattern_in_file.inc --source include/search_pattern_in_file.inc
--let SEARCH_PATTERN=MASTER_LOG_FILE --let SEARCH_PATTERN=MASTER_LOG_FILE
--source include/search_pattern_in_file.inc --source include/search_pattern_in_file.inc
--source include/show_xtrabackup_slave_info.inc
rmdir $targetdir; rmdir $targetdir;
...@@ -74,6 +78,7 @@ exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group-suffi ...@@ -74,6 +78,7 @@ exec $XTRABACKUP --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group-suffi
--source include/search_pattern_in_file.inc --source include/search_pattern_in_file.inc
--let SEARCH_PATTERN=MASTER_LOG_FILE --let SEARCH_PATTERN=MASTER_LOG_FILE
--source include/search_pattern_in_file.inc --source include/search_pattern_in_file.inc
--source include/show_xtrabackup_slave_info.inc
rmdir $targetdir; rmdir $targetdir;
......
#
# Start of 10.2 tests
#
#
# MDEV-21037 mariabackup does not detect multi-source replication slave
#
SELECT @@global.gtid_slave_pos;
@@global.gtid_slave_pos
# Without any masters the file xtrabackup_slave_info is not created
line
[00] YYYY-MM-DD hh:mm:ss Failed to get master binlog coordinates from SHOW SLAVE STATUS.This means that the server is not a replication slave. Ignoring the --slave-info option
CHANGE MASTER TO MASTER_HOST='localhost', MASTER_PORT=10000;
lineno line
1 CHANGE MASTER TO MASTER_LOG_FILE='', MASTER_LOG_POS=<NUM>;
line
[00] YYYY-MM-DD hh:mm:ss MySQL slave binlog position: master '' filename '' position '0'
CHANGE MASTER 'master2' TO MASTER_HOST='localhost', MASTER_PORT=10002;
lineno line
1 CHANGE MASTER TO MASTER_LOG_FILE='', MASTER_LOG_POS=<NUM>;
2 CHANGE MASTER 'master2' TO MASTER_LOG_FILE='', MASTER_LOG_POS=<NUM>;
line
[00] YYYY-MM-DD hh:mm:ss MySQL slave binlog position: master '' filename '' position '0'; master 'master2' filename '' position '0'
SET GLOBAL gtid_slave_pos='1-1-1,2-2-2';
CHANGE MASTER 'master3' TO MASTER_HOST='localhost', MASTER_PORT=10003, MASTER_USE_GTID=slave_pos;
CHANGE MASTER 'master4' TO MASTER_HOST='localhost', MASTER_PORT=10004, MASTER_USE_GTID=no;
CHANGE MASTER 'master5' TO MASTER_HOST='localhost', MASTER_PORT=10005, MASTER_USE_GTID=slave_pos;
lineno line
1 SET GLOBAL gtid_slave_pos = '<NUM-NUM-NUM>,<NUM-NUM-NUM>';
2 CHANGE MASTER TO MASTER_LOG_FILE='', MASTER_LOG_POS=<NUM>;
3 CHANGE MASTER 'master2' TO MASTER_LOG_FILE='', MASTER_LOG_POS=<NUM>;
4 CHANGE MASTER 'master3' TO master_use_gtid = slave_pos;
5 CHANGE MASTER 'master4' TO MASTER_LOG_FILE='', MASTER_LOG_POS=<NUM>;
6 CHANGE MASTER 'master5' TO master_use_gtid = slave_pos;
line
[00] YYYY-MM-DD hh:mm:ss MySQL slave binlog position: gtid_slave_pos '<NUM-NUM-NUM>,<NUM-NUM-NUM>'; master '' filename '' position '0'; master 'master2' filename '' position '0'; master 'master3' master_use_gtid = slave_pos; master 'master4' filename '' position '0'; master 'master5' master_use_gtid = slave_pos
CHANGE MASTER TO MASTER_HOST='localhost', MASTER_PORT=10000, MASTER_USE_GTID=slave_pos;
lineno line
1 SET GLOBAL gtid_slave_pos = '<NUM-NUM-NUM>,<NUM-NUM-NUM>';
2 CHANGE MASTER TO master_use_gtid = slave_pos;
3 CHANGE MASTER 'master2' TO MASTER_LOG_FILE='', MASTER_LOG_POS=<NUM>;
4 CHANGE MASTER 'master3' TO master_use_gtid = slave_pos;
5 CHANGE MASTER 'master4' TO MASTER_LOG_FILE='', MASTER_LOG_POS=<NUM>;
6 CHANGE MASTER 'master5' TO master_use_gtid = slave_pos;
line
[00] YYYY-MM-DD hh:mm:ss MySQL slave binlog position: gtid_slave_pos '<NUM-NUM-NUM>,<NUM-NUM-NUM>'; master '' master_use_gtid = slave_pos; master 'master2' filename '' position '0'; master 'master3' master_use_gtid = slave_pos; master 'master4' filename '' position '0'; master 'master5' master_use_gtid = slave_pos
RESET SLAVE ALL;
RESET SLAVE 'master2' ALL;
RESET SLAVE 'master3' ALL;
RESET SLAVE 'master4' ALL;
RESET SLAVE 'master5' ALL;
#
# End of 10.2 tests
#
#
# "mariabackup --slave-info" tests that can be run without
# actually starting the replication.
#
--echo #
--echo # Start of 10.2 tests
--echo #
--echo #
--echo # MDEV-21037 mariabackup does not detect multi-source replication slave
--echo #
--let $targetdir=$MYSQLTEST_VARDIR/tmp/backup
--let $XTRABACKUP_ARGS=--defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group-suffix=.2 --slave-info --backup --databases=test --target-dir=$targetdir
--let $XTRABACKUP_OUT=$MYSQLTEST_VARDIR/tmp/xtrabackup_out
# Should be empty by default
SELECT @@global.gtid_slave_pos;
--echo
--echo # Without any masters the file xtrabackup_slave_info is not created
--disable_result_log
exec $XTRABACKUP $XTRABACKUP_ARGS >$XTRABACKUP_OUT;
--enable_result_log
--error 1
--file_exists $targetdir/xtrabackup_slave_info
--source include/show_xtrabackup_slave_info_out.inc
--remove_file $XTRABACKUP_OUT
rmdir $targetdir;
--echo
CHANGE MASTER TO MASTER_HOST='localhost', MASTER_PORT=10000;
--disable_result_log
exec $XTRABACKUP $XTRABACKUP_ARGS >$XTRABACKUP_OUT;
--enable_result_log
--source include/show_xtrabackup_slave_info.inc
--source include/show_xtrabackup_slave_info_out.inc
--remove_file $XTRABACKUP_OUT
rmdir $targetdir;
--echo
CHANGE MASTER 'master2' TO MASTER_HOST='localhost', MASTER_PORT=10002;
--disable_result_log
exec $XTRABACKUP $XTRABACKUP_ARGS >$XTRABACKUP_OUT;
--enable_result_log
--source include/show_xtrabackup_slave_info.inc
--source include/show_xtrabackup_slave_info_out.inc
--remove_file $XTRABACKUP_OUT
rmdir $targetdir;
--echo
SET GLOBAL gtid_slave_pos='1-1-1,2-2-2';
CHANGE MASTER 'master3' TO MASTER_HOST='localhost', MASTER_PORT=10003, MASTER_USE_GTID=slave_pos;
CHANGE MASTER 'master4' TO MASTER_HOST='localhost', MASTER_PORT=10004, MASTER_USE_GTID=no;
CHANGE MASTER 'master5' TO MASTER_HOST='localhost', MASTER_PORT=10005, MASTER_USE_GTID=slave_pos;
--disable_result_log
exec $XTRABACKUP $XTRABACKUP_ARGS >$XTRABACKUP_OUT;
--enable_result_log
--source include/show_xtrabackup_slave_info.inc
--source include/show_xtrabackup_slave_info_out.inc
--remove_file $XTRABACKUP_OUT
rmdir $targetdir;
--echo
CHANGE MASTER TO MASTER_HOST='localhost', MASTER_PORT=10000, MASTER_USE_GTID=slave_pos;
--disable_result_log
exec $XTRABACKUP $XTRABACKUP_ARGS >$XTRABACKUP_OUT;
--enable_result_log
--source include/show_xtrabackup_slave_info.inc
--source include/show_xtrabackup_slave_info_out.inc
--remove_file $XTRABACKUP_OUT
rmdir $targetdir;
RESET SLAVE ALL;
RESET SLAVE 'master2' ALL;
RESET SLAVE 'master3' ALL;
RESET SLAVE 'master4' ALL;
RESET SLAVE 'master5' ALL;
--echo #
--echo # End of 10.2 tests
--echo #
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