5 changed files with 398 additions and 41 deletions
-
85client/mysqldump.c
-
2mysql-test/main/log_slow.test
-
69mysql-test/main/rpl_mysqldump_slave.result
-
148mysql-test/suite/rpl/r/rpl_mysqldump_gtid_slave_pos.result
-
135mysql-test/suite/rpl/t/rpl_mysqldump_gtid_slave_pos.test
@ -0,0 +1,148 @@ |
|||
include/master-slave.inc |
|||
[connection master] |
|||
# Initialize |
|||
connection slave; |
|||
ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB; |
|||
# Setup data |
|||
connection master; |
|||
CREATE TABLE t1 (a int PRIMARY KEY, b INT) ENGINE=InnoDB; |
|||
include/save_master_gtid.inc |
|||
connection slave; |
|||
include/sync_with_master_gtid.inc |
|||
# 1. run some replication load that adds records to gtid_slave_pos table |
|||
# 2. stop slave, remove loaded data (it will be replicated), delete from |
|||
# gtid_slave_pos as the table is going to be restored |
|||
# 3. take dump from slave (master has an empty gtid_slave_pos) |
|||
# with --gtid and for the default value of both |
|||
# --dump-slave and --master-data |
|||
# and in loop for the two options do: |
|||
# 4. reset the slave state to install some initial state |
|||
# 5. restart slave server, restore the dump |
|||
# 6. check the final state which must be equal to the dump's one |
|||
# 7. start replication to see no error => Q.E.D. |
|||
# unless the test runs on a buggy version in which case set to zero. |
|||
# 1. |
|||
include/stop_slave.inc |
|||
delete from mysql.gtid_slave_pos; |
|||
connection master; |
|||
insert into t1 set a = 5; |
|||
insert into t1 set a = 4; |
|||
insert into t1 set a = 3; |
|||
insert into t1 set a = 2; |
|||
insert into t1 set a = 1; |
|||
connection slave; |
|||
include/start_slave.inc |
|||
include/sync_with_master_gtid.inc |
|||
select * from mysql.gtid_slave_pos; |
|||
domain_id sub_id server_id seq_no |
|||
0 2 1 1 |
|||
0 3 1 2 |
|||
0 4 1 3 |
|||
0 5 1 4 |
|||
0 6 1 5 |
|||
0 7 1 6 |
|||
select @@global.gtid_slave_pos as "after initial slave got in sync"; |
|||
after initial slave got in sync |
|||
0-1-6 |
|||
# 2. |
|||
include/stop_slave.inc |
|||
# 3. A |
|||
include/stop_slave.inc |
|||
include/stop_slave.inc |
|||
# 4. |
|||
set statement sql_log_bin=0 for delete from mysql.gtid_slave_pos; |
|||
insert into mysql.gtid_slave_pos values (99 + 2, 1, 1, 1); |
|||
# 5. |
|||
include/rpl_restart_server.inc [server_number=2] |
|||
select * from mysql.gtid_slave_pos; |
|||
domain_id sub_id server_id seq_no |
|||
101 1 1 1 |
|||
select @@global.gtid_slave_pos as "before dump restore"; |
|||
before dump restore |
|||
101-1-1 |
|||
# 6. |
|||
select * from mysql.gtid_slave_pos; |
|||
domain_id sub_id server_id seq_no |
|||
0 2 1 6 |
|||
select @@global.gtid_slave_pos as "after dump restore"; |
|||
after dump restore |
|||
0-1-6 |
|||
# 7. |
|||
reset slave; |
|||
select @@global.gtid_slave_pos; |
|||
@@global.gtid_slave_pos |
|||
0-1-6 |
|||
change master to master_use_gtid=no; |
|||
connection master; |
|||
insert into t1 select 1+max(a),2 from t1; |
|||
include/save_master_gtid.inc |
|||
connection slave; |
|||
include/start_slave.inc |
|||
include/sync_with_master_gtid.inc |
|||
select * from mysql.gtid_slave_pos; |
|||
domain_id sub_id server_id seq_no |
|||
0 2 1 6 |
|||
0 3 1 1 |
|||
0 4 1 2 |
|||
0 5 1 3 |
|||
0 6 1 4 |
|||
0 7 1 5 |
|||
0 8 1 6 |
|||
0 9 1 7 |
|||
select @@global.gtid_slave_pos as "after slave got in sync"; |
|||
after slave got in sync |
|||
0-1-7 |
|||
include/stop_slave.inc |
|||
# 4. |
|||
set statement sql_log_bin=0 for delete from mysql.gtid_slave_pos; |
|||
insert into mysql.gtid_slave_pos values (99 + 1, 1, 1, 1); |
|||
# 5. |
|||
include/rpl_restart_server.inc [server_number=2] |
|||
select * from mysql.gtid_slave_pos; |
|||
domain_id sub_id server_id seq_no |
|||
100 1 1 1 |
|||
select @@global.gtid_slave_pos as "before dump restore"; |
|||
before dump restore |
|||
100-1-1 |
|||
# 6. |
|||
select * from mysql.gtid_slave_pos; |
|||
domain_id sub_id server_id seq_no |
|||
0 2 1 6 |
|||
select @@global.gtid_slave_pos as "after dump restore"; |
|||
after dump restore |
|||
0-1-6 |
|||
# 7. |
|||
reset slave; |
|||
select @@global.gtid_slave_pos; |
|||
@@global.gtid_slave_pos |
|||
0-1-6 |
|||
change master to master_use_gtid=no; |
|||
connection master; |
|||
insert into t1 select 1+max(a),1 from t1; |
|||
include/save_master_gtid.inc |
|||
connection slave; |
|||
include/start_slave.inc |
|||
include/sync_with_master_gtid.inc |
|||
select * from mysql.gtid_slave_pos; |
|||
domain_id sub_id server_id seq_no |
|||
0 2 1 6 |
|||
0 3 1 1 |
|||
0 4 1 2 |
|||
0 5 1 3 |
|||
0 6 1 4 |
|||
0 7 1 5 |
|||
0 8 1 6 |
|||
0 9 1 7 |
|||
0 10 1 8 |
|||
select @@global.gtid_slave_pos as "after slave got in sync"; |
|||
after slave got in sync |
|||
0-1-8 |
|||
# |
|||
# Cleanup |
|||
# |
|||
connection master; |
|||
DROP TABLE t1; |
|||
include/save_master_gtid.inc |
|||
connection slave; |
|||
include/sync_with_master_gtid.inc |
|||
include/rpl_end.inc |
|||
@ -0,0 +1,135 @@ |
|||
--source include/have_innodb.inc |
|||
--source include/master-slave.inc |
|||
|
|||
--echo # Initialize |
|||
--connection slave |
|||
ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB; |
|||
|
|||
--echo # Setup data |
|||
--connection master |
|||
CREATE TABLE t1 (a int PRIMARY KEY, b INT) ENGINE=InnoDB; |
|||
--source include/save_master_gtid.inc |
|||
|
|||
--connection slave |
|||
--source include/sync_with_master_gtid.inc |
|||
|
|||
# The following test proves fixes to |
|||
# MDEV-15393 gtid_slave_pos duplicate key errors after mysqldump restore |
|||
# |
|||
--echo # 1. run some replication load that adds records to gtid_slave_pos table |
|||
--echo # 2. stop slave, remove loaded data (it will be replicated), delete from |
|||
--echo # gtid_slave_pos as the table is going to be restored |
|||
--echo # 3. take dump from slave (master has an empty gtid_slave_pos) |
|||
--echo # with --gtid and for the default value of both |
|||
--echo # --dump-slave and --master-data |
|||
--echo # and in loop for the two options do: |
|||
--echo # 4. reset the slave state to install some initial state |
|||
--echo # 5. restart slave server, restore the dump |
|||
--echo # 6. check the final state which must be equal to the dump's one |
|||
--echo # 7. start replication to see no error => Q.E.D. |
|||
--echo # unless the test runs on a buggy version in which case set $FIXED to zero. |
|||
|
|||
# set to ZERO when run with mysqldump of buggy version |
|||
--let $FIXED= 1 |
|||
|
|||
--echo # 1. |
|||
--source include/stop_slave.inc |
|||
delete from mysql.gtid_slave_pos; |
|||
|
|||
--connection master |
|||
--let $trx_number = 5 |
|||
--let $i = $trx_number |
|||
while ($i) |
|||
{ |
|||
eval insert into t1 set a = $i; |
|||
--dec $i |
|||
} |
|||
|
|||
--connection slave |
|||
--source include/start_slave.inc |
|||
--source include/sync_with_master_gtid.inc |
|||
# Prior tests in a mtr batch could leave the min value of sub_id column with |
|||
# arbtirary value. Therefore before dumping let's |
|||
# adjust mysql.gtid_slave_pos to have sub_id growing deterministically. |
|||
# The value of 2 is choosen. |
|||
--disable_query_log |
|||
set statement sql_log_bin = 0 for update mysql.gtid_slave_pos set sub_id = sub_id - (select min(sub_id) from mysql.gtid_slave_pos) + 2; |
|||
--enable_query_log |
|||
select * from mysql.gtid_slave_pos; |
|||
select @@global.gtid_slave_pos as "after initial slave got in sync"; |
|||
|
|||
--echo # 2. |
|||
--source include/stop_slave.inc |
|||
|
|||
--echo # 3. A |
|||
# Two dumps prepared to be restored in the following loop |
|||
--exec $MYSQL_DUMP_SLAVE --dump-slave --gtid mysql gtid_slave_pos > $MYSQLTEST_VARDIR/tmp/dump_2.sql |
|||
--source include/stop_slave.inc |
|||
|
|||
--exec $MYSQL_DUMP_SLAVE --master-data --gtid mysql gtid_slave_pos > $MYSQLTEST_VARDIR/tmp/dump_1.sql |
|||
|
|||
--let $i=2 |
|||
while ($i) |
|||
{ |
|||
--disable_warnings |
|||
--source include/stop_slave.inc |
|||
--enable_warnings |
|||
--echo # 4. |
|||
set statement sql_log_bin=0 for delete from mysql.gtid_slave_pos; |
|||
# setup a new gtid/sub_id state as complication for future backup restore. |
|||
# After the restore the new state must be a union of the backup state |
|||
# and this one. |
|||
--eval insert into mysql.gtid_slave_pos values (99 + $i, 1, 1, 1) |
|||
|
|||
--echo # 5. |
|||
--let $rpl_server_number= 2 |
|||
--source include/rpl_restart_server.inc |
|||
select * from mysql.gtid_slave_pos; |
|||
select @@global.gtid_slave_pos as "before dump restore"; |
|||
--let $dump=dump_$i.sql |
|||
--exec $MYSQL_SLAVE mysql -e "source $MYSQLTEST_VARDIR/tmp/$dump" |
|||
|
|||
--echo # 6. |
|||
select * from mysql.gtid_slave_pos; |
|||
select @@global.gtid_slave_pos as "after dump restore"; |
|||
|
|||
--echo # 7. |
|||
reset slave; |
|||
select @@global.gtid_slave_pos; |
|||
change master to master_use_gtid=no; |
|||
|
|||
--connection master |
|||
eval insert into t1 select 1+max(a),$i from t1; |
|||
--source include/save_master_gtid.inc |
|||
|
|||
--connection slave |
|||
if ($FIXED) |
|||
{ |
|||
--source include/start_slave.inc |
|||
--source include/sync_with_master_gtid.inc |
|||
} |
|||
if (!$FIXED) |
|||
{ |
|||
start slave; |
|||
--let $slave_sql_errno= 1942 |
|||
--source include/wait_for_slave_sql_error.inc |
|||
|
|||
--die |
|||
} |
|||
select * from mysql.gtid_slave_pos; |
|||
select @@global.gtid_slave_pos as "after slave got in sync"; |
|||
|
|||
--dec $i |
|||
} |
|||
--echo # |
|||
--echo # Cleanup |
|||
--echo # |
|||
--connection master |
|||
DROP TABLE t1; |
|||
--source include/save_master_gtid.inc |
|||
|
|||
--connection slave |
|||
--remove_files_wildcard $MYSQLTEST_VARDIR/tmp dump_*.sql |
|||
--source include/sync_with_master_gtid.inc |
|||
|
|||
--source include/rpl_end.inc |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue