1
0
mirror of https://github.com/MariaDB/server.git synced 2025-07-30 16:24:05 +03:00

Merge branch '11.1' into 11.2

This commit is contained in:
Oleksandr Byelkin
2024-08-03 09:50:16 +02:00
463 changed files with 12095 additions and 5097 deletions

View File

@ -191,10 +191,10 @@ ROLLBACK/*!*/;
#010909 4:46:40 server id # end_log_pos # CRC32 XXX Binlog checkpoint slave-bin.000001
# at #
#010909 4:46:40 server id # end_log_pos # CRC32 XXX GTID 0-1-1 ddl
/*!100101 SET @@session.skip_parallel_replication=0*//*!*/;
/*!100001 SET @@session.gtid_domain_id=0*//*!*/;
/*!100001 SET @@session.server_id=1*//*!*/;
/*!100001 SET @@session.gtid_seq_no=1*//*!*/;
/*M!100101 SET @@session.skip_parallel_replication=0*//*!*/;
/*M!100001 SET @@session.gtid_domain_id=0*//*!*/;
/*M!100001 SET @@session.server_id=1*//*!*/;
/*M!100001 SET @@session.gtid_seq_no=1*//*!*/;
# at #
#010909 4:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid=<xid>
use `test`/*!*/;
@ -211,7 +211,7 @@ CREATE TABLE t1 (a INT, b INT, c INT)
/*!*/;
# at #
#010909 4:46:40 server id # end_log_pos # CRC32 XXX GTID 0-1-2 ddl
/*!100001 SET @@session.gtid_seq_no=2*//*!*/;
/*M!100001 SET @@session.gtid_seq_no=2*//*!*/;
# at #
#010909 4:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid=<xid>
SET TIMESTAMP=1000000000/*!*/;
@ -219,8 +219,8 @@ CREATE TABLE t2 (a INT, b INT, c INT)
/*!*/;
# at #
#010909 4:46:40 server id # end_log_pos # CRC32 XXX GTID 0-2-3 ddl
/*!100001 SET @@session.server_id=2*//*!*/;
/*!100001 SET @@session.gtid_seq_no=3*//*!*/;
/*M!100001 SET @@session.server_id=2*//*!*/;
/*M!100001 SET @@session.gtid_seq_no=3*//*!*/;
# at #
#010909 4:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid=<xid>
SET TIMESTAMP=1000000000/*!*/;
@ -228,8 +228,8 @@ ALTER TABLE t1 ENGINE=BLACKHOLE
/*!*/;
# at #
#010909 4:46:40 server id # end_log_pos # CRC32 XXX GTID 0-1-3 trans
/*!100001 SET @@session.server_id=1*//*!*/;
/*!100001 SET @@session.gtid_seq_no=3*//*!*/;
/*M!100001 SET @@session.server_id=1*//*!*/;
/*M!100001 SET @@session.gtid_seq_no=3*//*!*/;
START TRANSACTION
/*!*/;
# at #
@ -247,7 +247,7 @@ COMMIT
/*!*/;
# at #
#010909 4:46:40 server id # end_log_pos # CRC32 XXX GTID 0-1-4 trans
/*!100001 SET @@session.gtid_seq_no=4*//*!*/;
/*M!100001 SET @@session.gtid_seq_no=4*//*!*/;
START TRANSACTION
/*!*/;
# at #
@ -265,7 +265,7 @@ COMMIT
/*!*/;
# at #
#010909 4:46:40 server id # end_log_pos # CRC32 XXX GTID 0-1-5 trans
/*!100001 SET @@session.gtid_seq_no=5*//*!*/;
/*M!100001 SET @@session.gtid_seq_no=5*//*!*/;
START TRANSACTION
/*!*/;
# at #
@ -283,7 +283,7 @@ COMMIT
/*!*/;
# at #
#010909 4:46:40 server id # end_log_pos # CRC32 XXX GTID 0-1-6 trans
/*!100001 SET @@session.gtid_seq_no=6*//*!*/;
/*M!100001 SET @@session.gtid_seq_no=6*//*!*/;
START TRANSACTION
/*!*/;
# at #
@ -301,7 +301,7 @@ COMMIT
/*!*/;
# at #
#010909 4:46:40 server id # end_log_pos # CRC32 XXX GTID 0-1-7 trans
/*!100001 SET @@session.gtid_seq_no=7*//*!*/;
/*M!100001 SET @@session.gtid_seq_no=7*//*!*/;
START TRANSACTION
/*!*/;
# at #
@ -319,7 +319,7 @@ COMMIT
/*!*/;
# at #
#010909 4:46:40 server id # end_log_pos # CRC32 XXX GTID 0-1-8 ddl
/*!100001 SET @@session.gtid_seq_no=8*//*!*/;
/*M!100001 SET @@session.gtid_seq_no=8*//*!*/;
# at #
#010909 4:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid=<xid>
SET TIMESTAMP=1000000000/*!*/;
@ -327,7 +327,7 @@ ALTER TABLE t1 ADD PRIMARY KEY pk_t1 (a,b)
/*!*/;
# at #
#010909 4:46:40 server id # end_log_pos # CRC32 XXX GTID 0-1-9 trans
/*!100001 SET @@session.gtid_seq_no=9*//*!*/;
/*M!100001 SET @@session.gtid_seq_no=9*//*!*/;
START TRANSACTION
/*!*/;
# at #
@ -345,7 +345,7 @@ COMMIT
/*!*/;
# at #
#010909 4:46:40 server id # end_log_pos # CRC32 XXX GTID 0-1-10 trans
/*!100001 SET @@session.gtid_seq_no=10*//*!*/;
/*M!100001 SET @@session.gtid_seq_no=10*//*!*/;
START TRANSACTION
/*!*/;
# at #
@ -363,7 +363,7 @@ COMMIT
/*!*/;
# at #
#010909 4:46:40 server id # end_log_pos # CRC32 XXX GTID 0-1-11 trans
/*!100001 SET @@session.gtid_seq_no=11*//*!*/;
/*M!100001 SET @@session.gtid_seq_no=11*//*!*/;
START TRANSACTION
/*!*/;
# at #
@ -381,7 +381,7 @@ COMMIT
/*!*/;
# at #
#010909 4:46:40 server id # end_log_pos # CRC32 XXX GTID 0-1-12 ddl
/*!100001 SET @@session.gtid_seq_no=12*//*!*/;
/*M!100001 SET @@session.gtid_seq_no=12*//*!*/;
# at #
#010909 4:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid=<xid>
SET TIMESTAMP=1000000000/*!*/;
@ -389,7 +389,7 @@ ALTER TABLE t1 DROP PRIMARY KEY, ADD KEY key_t1 (a)
/*!*/;
# at #
#010909 4:46:40 server id # end_log_pos # CRC32 XXX GTID 0-1-13 trans
/*!100001 SET @@session.gtid_seq_no=13*//*!*/;
/*M!100001 SET @@session.gtid_seq_no=13*//*!*/;
START TRANSACTION
/*!*/;
# at #
@ -407,7 +407,7 @@ COMMIT
/*!*/;
# at #
#010909 4:46:40 server id # end_log_pos # CRC32 XXX GTID 0-1-14 trans
/*!100001 SET @@session.gtid_seq_no=14*//*!*/;
/*M!100001 SET @@session.gtid_seq_no=14*//*!*/;
START TRANSACTION
/*!*/;
# at #
@ -425,7 +425,7 @@ COMMIT
/*!*/;
# at #
#010909 4:46:40 server id # end_log_pos # CRC32 XXX GTID 0-1-15 trans
/*!100001 SET @@session.gtid_seq_no=15*//*!*/;
/*M!100001 SET @@session.gtid_seq_no=15*//*!*/;
START TRANSACTION
/*!*/;
# at #
@ -443,7 +443,7 @@ COMMIT
/*!*/;
# at #
#010909 4:46:40 server id # end_log_pos # CRC32 XXX GTID 0-1-16 ddl
/*!100001 SET @@session.gtid_seq_no=16*//*!*/;
/*M!100001 SET @@session.gtid_seq_no=16*//*!*/;
# at #
#010909 4:46:40 server id # end_log_pos # CRC32 XXX Query thread_id=# exec_time=# error_code=0 xid=<xid>
SET TIMESTAMP=1000000000/*!*/;

View File

@ -501,8 +501,7 @@ Warnings:
Note 1278 It is recommended to use --skip-slave-start when doing step-by-step replication with START SLAVE UNTIL; otherwise, you will get problems if you get an unexpected slave's mariadbd restart
# Slave needs time to start and stop automatically
# Waiting for both SQL and IO threads to have started..
# Waiting for SQL thread to be killed..
# Waiting for IO thread to be killed..
# Waiting for Slave SQL and IO threads to be killed..
# Validating neither SQL nor IO threads are running..
# ..success
# Clean slave state of master

View File

@ -0,0 +1,150 @@
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;
include/save_master_gtid.inc
connection slave;
CHANGE MASTER TO master_use_gtid= no;
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

View File

@ -2,7 +2,9 @@ include/master-slave.inc
[connection master]
connection master;
connection slave;
# MDEV-32892: Repeatedly starting/stopping io_thread..
include/stop_slave.inc
NOT FOUND /Error reading packet from server: Lost connection/ in slave_log.err
NOT FOUND /error code: 2013/ in slave_log.err
include/start_slave.inc
include/rpl_end.inc

View File

@ -1164,6 +1164,88 @@ include/sync_with_master_gtid.inc
connection server_1;
set @@binlog_format = @sav_binlog_format;
set @@global.binlog_format = @sav_binlog_format;
#
# MDEV-33921.1: If a slave's replication of an XA transaction results in
# an empty transaction, e.g. due to replication filters, the slave
# should not binlog any part of the XA transaction.
connection server_1;
create database db1;
create database db2;
create table db1.t1 (a int) engine=innodb;
include/save_master_gtid.inc
connection server_3;
include/sync_with_master_gtid.inc
include/stop_slave.inc
change master to master_use_gtid=slave_pos;
connection server_2;
include/stop_slave.inc
SET @@GLOBAL.replicate_ignore_db= "";
SET @@GLOBAL.replicate_do_db= "db2";
change master to master_use_gtid=slave_pos;
include/start_slave.inc
connection server_1;
use db1;
XA START "x1";
insert into db1.t1 values (1);
XA END "x1";
XA PREPARE "x1";
XA COMMIT "x1";
include/save_master_gtid.inc
connection server_2;
include/sync_with_master_gtid.inc
connection server_2;
include/save_master_gtid.inc
connection server_3;
include/start_slave.inc
include/sync_with_master_gtid.inc
#
# 33921.2: If the slave shuts down after "preparing" a filtered-to-empty
# XA transaction (and not completing it), then when the respective
# XA completion (COMMIT in this test) command is replicated, the slave
# should not throw ER_XAER_NOTA. Note that internally, the error is
# thrown, but it is ignored because the target db is filtered.
connection server_3;
include/stop_slave.inc
connection server_1;
use db1;
XA START "x2";
insert into db1.t1 values (2);
XA END "x2";
XA PREPARE "x2";
include/save_master_gtid.inc
connection server_2;
include/sync_with_master_gtid.inc
# Connection named slave is needed for reconnection
connect slave,localhost,root,,;
connect slave1,localhost,root,,;
include/rpl_restart_server.inc [server_number=2]
connection server_2;
include/stop_slave.inc
SET @@GLOBAL.replicate_do_db= "db2";
change master to master_use_gtid=slave_pos;
include/start_slave.inc
connection server_1;
XA COMMIT "x2";
include/save_master_gtid.inc
connection server_2;
include/sync_with_master_gtid.inc
include/save_master_gtid.inc
connection server_3;
include/start_slave.inc
include/sync_with_master_gtid.inc
#
# 33921.3: Ensure XA commands are not considered by mysqlbinlog's
# --database filter
connection server_1;
# MYSQL_BINLOG datadir/binlog_file --start-position=pre_xa_pos --database=db2 --result-file=assert_file
include/assert_grep.inc [Mysqlbinlog should output all XA commands from the filtered transaction]
connection server_2;
include/stop_slave.inc
SET @@GLOBAL.replicate_do_db="";
include/start_slave.inc
connection server_1;
drop database db1;
drop database db2;
connection server_1;
include/rpl_end.inc
# End of rpl_xa_empty_transaction.test

View File

@ -277,36 +277,43 @@ SELECT VARIABLE_NAME, GLOBAL_VALUE FROM INFORMATION_SCHEMA.SYSTEM_VARIABLES WHER
--echo # position pointing to a previous event (because
--echo # master_demote_to_slave=1 merges gtid_binlog_pos into gtid_slave_pos).
--let $pre_start_slave_thread_count= query_get_value(SHOW STATUS LIKE 'Connections', Value, 1)
# Note that we can't use sync_with_master_gtid.inc,
# wait_for_slave_to_start.inc, or wait_for_slave_to_stop.inc because our MTR
# connection thread races with the start/stop of the SQL/IO threads. So
# instead, for slave start, we prove the threads started by waiting for the
# connection count to increase by 2; and for slave stop, we wait for the
# processlist count to return to its pre start slave number.
--let $pre_start_slave_conn_count= query_get_value(SHOW STATUS LIKE 'Connections', Value, 1)
--let $pre_start_slave_process_count= `SELECT count(*) from information_schema.PROCESSLIST`
--replace_result $ssu_middle_binlog_pos ssu_middle_binlog_pos
eval START SLAVE UNTIL master_gtid_pos="$ssu_middle_binlog_pos";
--echo # Slave needs time to start and stop automatically
--echo # Waiting for both SQL and IO threads to have started..
--let $expected_cons_after_start_slave= `SELECT ($pre_start_slave_thread_count + 2)`
--let $expected_cons_after_start_slave= `SELECT ($pre_start_slave_conn_count + 2)`
--let $status_var= Connections
--let $status_var_value= $expected_cons_after_start_slave
--let $status_var_comparsion= >=
--source include/wait_for_status_var.inc
--let $status_var_comparsion=
--echo # Waiting for SQL thread to be killed..
--let $wait_condition= SELECT count(*)=0 from information_schema.PROCESSLIST where COMMAND="Slave_SQL"
--source include/wait_condition.inc
--echo # Waiting for IO thread to be killed..
--let $wait_condition= SELECT count(*)=0 from information_schema.PROCESSLIST where COMMAND="Slave_IO"
--echo # Waiting for Slave SQL and IO threads to be killed..
--let $wait_condition= SELECT count(*)=$pre_start_slave_process_count from information_schema.PROCESSLIST
--source include/wait_condition.inc
--echo # Validating neither SQL nor IO threads are running..
--let $io_state= query_get_value("SHOW SLAVE STATUS", Slave_IO_State, 1)
if (`SELECT strcmp("$io_state","") != 0`)
{
--echo # Slave_IO_State is "$io_state" but should be empty
die "IO thread should not be running after START SLAVE UNTIL master_gtid_pos using a pre-existing GTID";
}
--let $sql_state= query_get_value("SHOW SLAVE STATUS", Slave_SQL_Running_State, 1)
if (`SELECT strcmp("$sql_state","") != 0`)
{
--echo # Slave_SQL_Running_State is "$sql_state" but should be empty
die "SQL thread should not be running after START SLAVE UNTIL master_gtid_pos using a pre-existing GTID";
}
--echo # ..success

View File

@ -55,9 +55,7 @@ SET sql_log_bin=1;
# Restart the slave mysqld server, and verify that the GTID position is
# read correctly from the new mysql.gtid_slave_pos_innodb table.
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
wait
EOF
--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
--shutdown_server
--source include/wait_until_disconnected.inc
@ -94,9 +92,7 @@ DROP TABLE mysql.gtid_slave_pos;
RENAME TABLE mysql.gtid_slave_pos_innodb TO mysql.gtid_slave_pos;
SET sql_log_bin=1;
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
wait
EOF
--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
--shutdown_server
--source include/wait_until_disconnected.inc
@ -132,9 +128,7 @@ SET sql_log_bin=0;
ALTER TABLE mysql.gtid_slave_pos ENGINE=Aria;
SET sql_log_bin=1;
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
wait
EOF
--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
--shutdown_server
--source include/wait_until_disconnected.inc
@ -176,9 +170,7 @@ INSERT INTO mysql.gtid_slave_pos SELECT * FROM mysql.gtid_slave_pos_InnoDB;
DROP TABLE mysql.gtid_slave_pos_InnoDB;
SET sql_log_bin=1;
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
wait
EOF
--write_line "wait" $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
--shutdown_server
--source include/wait_until_disconnected.inc
@ -272,9 +264,7 @@ while (!$done)
# MDEV-15373 engine gtid_slave_pos table name disobeys lower-case-table-names
# This snippet verifies that engine gtid_slave_pos table is found,
# its data are up-to-date.
--write_file $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
wait
EOF
--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
--connection server_2
--shutdown_server
--source include/wait_until_disconnected.inc

View File

@ -0,0 +1,138 @@
--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
}
--source include/save_master_gtid.inc
--connection slave
# due to MDEV-19801 on 10+.10+
CHANGE MASTER TO master_use_gtid= no;
--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

View File

@ -6,11 +6,26 @@ source include/master-slave.inc;
connection master;
sync_slave_with_master;
--let $iter=100
--echo # MDEV-32892: Repeatedly starting/stopping io_thread..
--disable_query_log
while ($iter)
{
stop slave io_thread;
start slave io_thread;
--dec $iter
}
--enable_query_log
source include/stop_slave.inc;
let SEARCH_FILE=$MYSQLTEST_VARDIR/tmp/slave_log.err;
let SEARCH_PATTERN=Error reading packet from server: Lost connection;
source include/search_pattern_in_file.inc;
let SEARCH_PATTERN=error code: 2013;
source include/search_pattern_in_file.inc;
source include/start_slave.inc;
source include/rpl_end.inc;

View File

@ -32,6 +32,10 @@
# MDEV-25616: Binlog event for XA COMMIT is generated without matching
# XA START, replication aborts
#
# MDEV-33921: Replication fails when XA transactions are used where the slave
# has replicate_do_db set and the client has touched a different
# database when running DML such as inserts.
#
--source include/have_log_bin.inc
--let $rpl_server_count= 3
@ -167,6 +171,133 @@ set @@global.binlog_format = row;
set @@binlog_format = @sav_binlog_format;
set @@global.binlog_format = @sav_binlog_format;
--echo #
--echo # MDEV-33921.1: If a slave's replication of an XA transaction results in
--echo # an empty transaction, e.g. due to replication filters, the slave
--echo # should not binlog any part of the XA transaction.
#
# Note that the MDEV-33921 report is actually about that XA END is filtered
# out (not executed), and then its corresponding XA PREPARE errors because the
# XA state of the transaction is incorrect. This test case inherently tests
# both bugs.
--connection server_1
create database db1;
create database db2;
create table db1.t1 (a int) engine=innodb;
--source include/save_master_gtid.inc
--connection server_3
--source include/sync_with_master_gtid.inc
--source include/stop_slave.inc
change master to master_use_gtid=slave_pos;
--connection server_2
--source include/stop_slave.inc
SET @@GLOBAL.replicate_ignore_db= "";
SET @@GLOBAL.replicate_do_db= "db2";
change master to master_use_gtid=slave_pos;
--source include/start_slave.inc
--connection server_1
--let $pre_xa_gtid= `SELECT @@global.gtid_binlog_pos`
use db1;
XA START "x1";
insert into db1.t1 values (1);
XA END "x1";
XA PREPARE "x1";
XA COMMIT "x1";
--source include/save_master_gtid.inc
--connection server_2
--source include/sync_with_master_gtid.inc
--let $slave_binlogged_gtid= `SELECT @@global.gtid_binlog_pos`
if (`SELECT strcmp("$slave_binlogged_gtid","$pre_xa_gtid")`)
{
--die Slave binlogged an empty XA transaction yet should not have
}
--connection server_2
--source include/save_master_gtid.inc
--connection server_3
--source include/start_slave.inc
--source include/sync_with_master_gtid.inc
--echo #
--echo # 33921.2: If the slave shuts down after "preparing" a filtered-to-empty
--echo # XA transaction (and not completing it), then when the respective
--echo # XA completion (COMMIT in this test) command is replicated, the slave
--echo # should not throw ER_XAER_NOTA. Note that internally, the error is
--echo # thrown, but it is ignored because the target db is filtered.
--connection server_3
--source include/stop_slave.inc
--connection server_1
--let $pre_xa_gtid= `SELECT @@global.gtid_binlog_pos`
# Used by mysqlbinlog in part 3
--let $pre_xa_pos = query_get_value(SHOW MASTER STATUS, Position, 1)
use db1;
XA START "x2";
insert into db1.t1 values (2);
XA END "x2";
XA PREPARE "x2";
--source include/save_master_gtid.inc
--connection server_2
--source include/sync_with_master_gtid.inc
--let $rpl_server_number= 2
--echo # Connection named slave is needed for reconnection
--connect(slave,localhost,root,,)
--connect(slave1,localhost,root,,)
--source include/rpl_restart_server.inc
--connection server_2
--source include/stop_slave.inc
SET @@GLOBAL.replicate_do_db= "db2";
change master to master_use_gtid=slave_pos;
--source include/start_slave.inc
--connection server_1
XA COMMIT "x2";
--source include/save_master_gtid.inc
--connection server_2
--source include/sync_with_master_gtid.inc
--source include/save_master_gtid.inc
--connection server_3
--source include/start_slave.inc
--source include/sync_with_master_gtid.inc
--echo #
--echo # 33921.3: Ensure XA commands are not considered by mysqlbinlog's
--echo # --database filter
--connection server_1
--let $datadir= `select @@datadir`
--let $binlog_file= query_get_value(SHOW MASTER STATUS, File, 1)
--let assert_file= $MYSQLTEST_VARDIR/tmp/binlog_decoded.out
--echo # MYSQL_BINLOG datadir/binlog_file --start-position=pre_xa_pos --database=db2 --result-file=assert_file
--exec $MYSQL_BINLOG $datadir/$binlog_file --start-position=$pre_xa_pos --database=db2 --result-file=$assert_file
--let assert_text= Mysqlbinlog should output all XA commands from the filtered transaction
--let assert_count= 4
--let assert_select= XA START|XA END|XA PREPARE|XA COMMIT
--source include/assert_grep.inc
--connection server_2
--source include/stop_slave.inc
SET @@GLOBAL.replicate_do_db="";
--source include/start_slave.inc
--connection server_1
drop database db1;
drop database db2;
#
# Cleanup
--connection server_1