mirror of
https://github.com/MariaDB/server.git
synced 2026-02-17 08:08:42 +01:00
In an addition to test rpl.rpl_parallel_sbm added by MDEV-32265, the test uses sleep statements alone to test Seconds_Behind_Master with delayed replication. On slow running machines, the test can pass the intended MASTER_DELAY duration and Seconds_Behind_Master can become 0, when the test expects the transaction to still be actively in a delaying state. This can be consistently reproduced by adding a sleep statement before the call to --let = query_get_value(SHOW SLAVE STATUS, Seconds_Behind_Master, 1) to sleep past the delay end point. This patch fixes this by locking the table which the delayed transaction targets so Second_Behind_Master cannot be updated before the test reads it for validation.
101 lines
3.3 KiB
Text
101 lines
3.3 KiB
Text
include/master-slave.inc
|
|
[connection master]
|
|
#
|
|
# MDEV-29639: Seconds_Behind_Master is incorrect for Delayed, Parallel Replicas
|
|
#
|
|
connection slave;
|
|
include/stop_slave.inc
|
|
set @@GLOBAL.debug_dbug= "d,negate_clock_diff_with_master";
|
|
set @@GLOBAL.slave_parallel_mode= CONSERVATIVE;
|
|
change master to master_delay=3, master_use_gtid=Slave_Pos;
|
|
include/start_slave.inc
|
|
connection master;
|
|
create table t1 (a int);
|
|
create table t2 (a int);
|
|
include/sync_slave_sql_with_master.inc
|
|
#
|
|
# Pt 1) Ensure SBM is updated immediately upon arrival of the next event
|
|
connection master;
|
|
# Sleep 2 to allow a buffer between events for SBM check
|
|
insert into t1 values (0);
|
|
include/save_master_gtid.inc
|
|
connection slave;
|
|
# Waiting for transaction to arrive on slave and begin SQL Delay..
|
|
# Validating SBM is updated on event arrival..
|
|
# ..done
|
|
# MDEV-32265. At time of STOP SLAVE, if the SQL Thread is currently
|
|
# delaying a transaction; then when the reciprocal START SLAVE occurs,
|
|
# if the event is still to be delayed, SBM should resume accordingly
|
|
include/stop_slave.inc
|
|
# Lock t1 on slave to ensure the event can't finish (and thereby update
|
|
# Seconds_Behind_Master) so slow running servers don't accidentally
|
|
# catch up to the master before checking SBM.
|
|
connection server_2;
|
|
LOCK TABLES t1 WRITE;
|
|
include/start_slave.inc
|
|
connection slave;
|
|
# Waiting for replica to resume the delay for the transaction
|
|
# Sleeping 1s to increment SBM
|
|
# Ensuring Seconds_Behind_Master increases after sleeping..
|
|
# ..done
|
|
connection server_2;
|
|
UNLOCK TABLES;
|
|
include/sync_with_master_gtid.inc
|
|
#
|
|
# Pt 2) If the worker threads have not entered an idle state, ensure
|
|
# following events do not update SBM
|
|
connection slave;
|
|
LOCK TABLES t1 WRITE;
|
|
connection master;
|
|
# Sleep 2 to allow a buffer between events for SBM check
|
|
insert into t1 values (1);
|
|
# Sleep 3 to create gap between events
|
|
insert into t1 values (2);
|
|
include/save_master_pos.inc
|
|
connection slave;
|
|
# Wait for first transaction to complete SQL delay and begin execution..
|
|
# Validate SBM calculation doesn't use the second transaction because worker threads shouldn't have gone idle..
|
|
# ..and that SBM wasn't calculated using prior committed transactions
|
|
# ..done
|
|
connection slave;
|
|
UNLOCK TABLES;
|
|
include/wait_for_slave_param.inc [Relay_Master_Log_File]
|
|
include/wait_for_slave_param.inc [Exec_Master_Log_Pos]
|
|
# Cleanup
|
|
include/stop_slave.inc
|
|
CHANGE MASTER TO master_delay=0;
|
|
include/start_slave.inc
|
|
#
|
|
# MDEV-30619: Parallel Slave SQL Thread Can Update Seconds_Behind_Master with Active Workers
|
|
#
|
|
connection slave;
|
|
# Ensure the replica is fully idle before starting transactions
|
|
# Lock t1 on slave so the first received transaction does not complete/commit
|
|
LOCK TABLES t1 WRITE;
|
|
connection master;
|
|
insert into t1 values (3);
|
|
include/save_master_gtid.inc
|
|
connection slave;
|
|
# Waiting for first transaction to begin..
|
|
connection master;
|
|
# Sleep 2 sec to create a gap between events
|
|
INSERT INTO t2 VALUES (1);
|
|
include/save_master_gtid.inc
|
|
connection slave;
|
|
# Waiting for second transaction to begin..
|
|
connection slave;
|
|
UNLOCK TABLES;
|
|
include/sync_with_master_gtid.inc
|
|
#
|
|
# Cleanup
|
|
connection master;
|
|
DROP TABLE t1, t2;
|
|
include/save_master_gtid.inc
|
|
connection slave;
|
|
include/sync_with_master_gtid.inc
|
|
include/stop_slave.inc
|
|
set @@GLOBAL.debug_dbug= "";
|
|
set @@GLOBAL.slave_parallel_mode= "$save_parallel_mode";
|
|
include/start_slave.inc
|
|
include/rpl_end.inc
|
|
# End of rpl_parallel_sbm.test
|