mirror of
https://github.com/MariaDB/server.git
synced 2025-09-11 05:52:26 +03:00
When executing a Query_log_event that is a COMMIT query, gtid_slave_pos is updated before other replication status variables, so when an MTR test syncs a replica with primaries via GTID, there is a slight window where accessing status variables, e.g. via SHOW ALL SLAVES STATUS, results in "stale" values because gtid_slave_pos has been updated before the *_last_event_time fields have been updated. This patch only fixes the test by switching from using GTIDs to using binlog file coordinates when synchronizing replicas with their primaries.
138 lines
4.1 KiB
Plaintext
138 lines
4.1 KiB
Plaintext
include/rpl_init.inc [topology=1->2->3]
|
|
connection server_3;
|
|
include/stop_slave.inc
|
|
connection server_1;
|
|
call mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
|
|
alter table mysql.gtid_slave_pos engine=innodb;
|
|
create table t1 (a int) engine=aria;
|
|
create table t2 (a int) engine=innodb;
|
|
include/save_master_gtid.inc
|
|
# Sleep 1 to ensure setup DDL and test statements have different binlog timestamps
|
|
connection server_2;
|
|
set @old_par_thds= @@global.slave_parallel_threads;
|
|
#
|
|
# Ensure that the slave doesn't overwrite exec_time when binlogging
|
|
#
|
|
connection server_2;
|
|
include/sync_with_master_gtid.inc
|
|
include/stop_slave.inc
|
|
change master to master_delay=SLAVE_DELAY;
|
|
include/start_slave.inc
|
|
connection server_2;
|
|
include/stop_slave.inc
|
|
set @@global.slave_parallel_threads= 0;
|
|
include/start_slave.inc
|
|
connection server_2;
|
|
flush logs;
|
|
connection server_1;
|
|
# Only sleep on master so the real execution time on the slave is less
|
|
insert into t1 values (sleep(if(@@global.server_id=1, 2, 0)));
|
|
include/save_master_gtid.inc
|
|
# Waiting for slave to delay and commit transaction..
|
|
connection server_2;
|
|
include/sync_with_master_gtid.inc
|
|
# MYSQL_BINLOG slave_local_binlog > slave_outfile
|
|
include/assert_grep.inc [Ensure serial slave doesn't overwrite exec_time in the binlog event (0s)]
|
|
include/assert_grep.inc [Ensure serial slave doesn't overwrite exec_time in the binlog event (1s)]
|
|
#
|
|
# Test that changes are properly applied by server_2 and server_3
|
|
#
|
|
connection server_1;
|
|
include/save_master_pos.inc
|
|
connection server_2;
|
|
include/wait_for_slave_param.inc [Relay_Master_Log_File]
|
|
include/wait_for_slave_param.inc [Exec_Master_Log_Pos]
|
|
include/save_master_pos.inc
|
|
# Show that the server_2 received the insert from master
|
|
select * from t1;
|
|
a
|
|
0
|
|
master <> NULL; Should be 1
|
|
1
|
|
master_time == slave_time ; Should be 1
|
|
1
|
|
connection server_3;
|
|
include/start_slave.inc
|
|
include/wait_for_slave_param.inc [Relay_Master_Log_File]
|
|
include/wait_for_slave_param.inc [Exec_Master_Log_Pos]
|
|
# Show that the server_3 received the insert from master
|
|
select * from t1;
|
|
a
|
|
0
|
|
master <> NULL; Should be 1
|
|
1
|
|
master_time == slave_time ; Should be 1
|
|
1
|
|
include/stop_slave.inc
|
|
connection server_1;
|
|
connection server_2;
|
|
include/stop_slave.inc
|
|
set @@global.slave_parallel_threads= @old_par_thds;
|
|
include/start_slave.inc
|
|
connection server_2;
|
|
include/stop_slave.inc
|
|
set @@global.slave_parallel_threads= 1;
|
|
include/start_slave.inc
|
|
connection server_2;
|
|
flush logs;
|
|
connection server_1;
|
|
# Only sleep on master so the real execution time on the slave is less
|
|
insert into t1 values (sleep(if(@@global.server_id=1, 2, 0)));
|
|
include/save_master_gtid.inc
|
|
# Waiting for slave to delay and commit transaction..
|
|
connection server_2;
|
|
include/sync_with_master_gtid.inc
|
|
# MYSQL_BINLOG slave_local_binlog > slave_outfile
|
|
include/assert_grep.inc [Ensure parallel slave doesn't overwrite exec_time in the binlog event (0s)]
|
|
include/assert_grep.inc [Ensure parallel slave doesn't overwrite exec_time in the binlog event (1s)]
|
|
#
|
|
# Test that changes are properly applied by server_2 and server_3
|
|
#
|
|
connection server_1;
|
|
include/save_master_pos.inc
|
|
connection server_2;
|
|
include/wait_for_slave_param.inc [Relay_Master_Log_File]
|
|
include/wait_for_slave_param.inc [Exec_Master_Log_Pos]
|
|
include/save_master_pos.inc
|
|
# Show that the server_2 received the insert from master
|
|
select * from t1;
|
|
a
|
|
0
|
|
0
|
|
master <> NULL; Should be 1
|
|
1
|
|
master_time == slave_time ; Should be 1
|
|
1
|
|
connection server_3;
|
|
include/start_slave.inc
|
|
include/wait_for_slave_param.inc [Relay_Master_Log_File]
|
|
include/wait_for_slave_param.inc [Exec_Master_Log_Pos]
|
|
# Show that the server_3 received the insert from master
|
|
select * from t1;
|
|
a
|
|
0
|
|
0
|
|
master <> NULL; Should be 1
|
|
1
|
|
master_time == slave_time ; Should be 1
|
|
1
|
|
include/stop_slave.inc
|
|
connection server_1;
|
|
connection server_2;
|
|
include/stop_slave.inc
|
|
set @@global.slave_parallel_threads= @old_par_thds;
|
|
include/start_slave.inc
|
|
#
|
|
# Cleanup
|
|
connection server_2;
|
|
include/stop_slave.inc
|
|
change master to master_delay=0;
|
|
include/start_slave.inc
|
|
connection server_3;
|
|
include/start_slave.inc
|
|
connection server_1;
|
|
drop table t1;
|
|
drop table t2;
|
|
include/rpl_end.inc
|
|
# End of master_last_event_time_stmt
|