diff options
author | asklavou <angelique.sklavounos@mariadb.com> | 2022-09-12 19:17:52 -0400 |
---|---|---|
committer | asklavou <angelique.sklavounos@mariadb.com> | 2022-09-12 19:17:52 -0400 |
commit | 13a8efaaedeb894a936f4855f32c087308369dd5 (patch) | |
tree | 056c8ac623bbc613e1703b895fc43e52cfe2dd19 | |
parent | 04899d6d9167acc2132ee86e011dcdc026f73d51 (diff) | |
download | mariadb-git-bb-10.3-MDEV-26633.tar.gz |
MDEV-26633, MDEV-27950: intermediate commit to test changesbb-10.3-MDEV-26633
-rw-r--r-- | mysql-test/suite/rpl/include/delayed_slave_wait_on_query2.inc | 59 | ||||
-rw-r--r-- | mysql-test/suite/rpl/r/rpl_delayed_slave.result | 21 | ||||
-rw-r--r-- | mysql-test/suite/rpl/t/rpl_delayed_slave.test | 81 |
3 files changed, 123 insertions, 38 deletions
diff --git a/mysql-test/suite/rpl/include/delayed_slave_wait_on_query2.inc b/mysql-test/suite/rpl/include/delayed_slave_wait_on_query2.inc new file mode 100644 index 00000000000..e5e30afe78c --- /dev/null +++ b/mysql-test/suite/rpl/include/delayed_slave_wait_on_query2.inc @@ -0,0 +1,59 @@ +# ==== Purpose ==== +# +# Auxiliary file used by rpl_delayed_slave.test. This assumes that an +# 'INSERT INTO t1...' query has been executed on the master. It does +# this: +# +# - After half the delay, check the status. It should be delaying and +# the query should not have executed. +# +# - After one and a half delay, check the status. It should not be +# delaying and the query should be executed. +# +# +# ==== Usage ==== +# +# --let $query_number= 4 +# --source suite/rpl/include/delayed_slave_wait_on_query.inc +# +# Parameters: +# $query_number +# The value of the 'b' column in t1 for the row inserted by the query +# we are waiting for. + +connection master; + +--echo [on slave] +#--let $slave_timeout= $time1 +--source include/sync_slave_io_with_master.inc +#--echo # sleep 1*T +#--sleep $time1 + +--let $assert_text= Query $query_number should not be executed +--let $assert_cond= MAX(b) < $query_number FROM t1 +--source include/rpl_assert.inc + +--let $assert_text= Status should be 'Waiting until MASTER_DELAY...' +--let $assert_cond= "[SHOW SLAVE STATUS, Slave_SQL_Running_State, 1]" LIKE "Waiting until MASTER_DELAY%" +--source include/rpl_assert.inc + +#--echo # sleep 1*T +#--sleep $time1 + +--echo # sync with master +--source include/sync_with_master.inc +--let $timestamp_after_sync= `SELECT UNIX_TIMESTAMP()` + +--let $assert_text= Query $query_number should be executed +--let $assert_cond= MAX(b) = $query_number FROM t1 +--source include/rpl_assert.inc + +--let $assert_text= Status should be 'Has read all relay log...' +--let $assert_cond= "[SHOW SLAVE STATUS, Slave_SQL_Running_State, 1]" LIKE "Slave has read all relay log%" +--source include/rpl_assert.inc + +--let $assert_text= Query should have taken at least delay time +--let $assert_cond= $timestamp_after_sync - $timestamp_before_start >= $time3 +--source include/rpl_assert.inc + +--source include/check_slave_is_running.inc diff --git a/mysql-test/suite/rpl/r/rpl_delayed_slave.result b/mysql-test/suite/rpl/r/rpl_delayed_slave.result index bcfd49934b4..3003a438365 100644 --- a/mysql-test/suite/rpl/r/rpl_delayed_slave.result +++ b/mysql-test/suite/rpl/r/rpl_delayed_slave.result @@ -78,59 +78,56 @@ connection slave; # Asserted this: Seconds_Behind_Master should be at least 2*T ==== STOP SLAVE / START SLAVE + DML ==== include/stop_slave.inc -# CHANGE MASTER TO MASTER_DELAY = 3*T +# CHANGE MASTER TO MASTER_DELAY = a long time to test STOP/START REPLICA do not wait for the delay include/start_slave.inc [on master] connection master; INSERT INTO t1 VALUES ('stop slave and start slave: DML', 7); [on slave] connection slave; -# sleep 1*T include/stop_slave.inc -# Asserted this: STOP SLAVE should finish quickly, not wait for the ongoing sleep to finish # Asserted this: SQL thread position should not increase after STOP SLAVE # Asserted this: Query should not be executed after STOP SLAVE # Asserted this: Status should be '' after STOP SLAVE +# CHANGE MASTER TO MASTER_DELAY = a shorter time to test remaining functionality include/start_slave.inc -# Asserted this: START SLAVE should finish quickly connection master; [on slave] include/sync_slave_io_with_master.inc -# sleep 1*T # Asserted this: Query 7 should not be executed # Asserted this: Status should be 'Waiting until MASTER_DELAY...' -# sleep 1*T -# sync with master (with timeout 1*T) +# sync with master include/wait_for_slave_param.inc [Relay_Master_Log_File] include/wait_for_slave_param.inc [Exec_Master_Log_Pos] # Asserted this: Query 7 should be executed # Asserted this: Status should be 'Has read all relay log...' +# Asserted this: Query should have taken at least delay time include/check_slave_is_running.inc ==== STOP SLAVE / START SLAVE + DDL ==== This verifies BUG#56442 +# CHANGE MASTER TO MASTER_DELAY = a long time to test STOP/START REPLICA do not wait for the delay +include/stop_slave.inc +include/start_slave.inc [on master] connection master; CREATE TABLE t_check_dml_not_executed_prematurely (a INT); include/save_master_pos.inc [on slave] connection slave; -# sleep 1*T include/stop_slave.inc -# Asserted this: STOP SLAVE should finish quickly, not wait for the ongoing sleep to finish # Asserted this: SQL thread position should not increase after STOP SLAVE # Asserted this: Query should not be executed after STOP SLAVE # Asserted this: Status should be '' after STOP SLAVE +# CHANGE MASTER TO MASTER_DELAY = a shorter time to test remaining functionality include/start_slave.inc -# Asserted this: START SLAVE should finish quickly -# sleep 1*T # Asserted this: DDL Query should not be executed after START SLAVE # Asserted this: Status should be 'Waiting until MASTER_DELAY...' -# sleep 1*T # sync with master (with timeout 1*T) include/wait_for_slave_param.inc [Relay_Master_Log_File] include/wait_for_slave_param.inc [Exec_Master_Log_Pos] # Asserted this: DDL Query should be executed # Asserted this: Status should be 'Has read all relay log...' +# Asserted this: Query should have taken at least delay time include/check_slave_is_running.inc ==== Change back to no delay ==== [on slave] diff --git a/mysql-test/suite/rpl/t/rpl_delayed_slave.test b/mysql-test/suite/rpl/t/rpl_delayed_slave.test index 7dd7b9cf6d9..eba95eb3064 100644 --- a/mysql-test/suite/rpl/t/rpl_delayed_slave.test +++ b/mysql-test/suite/rpl/t/rpl_delayed_slave.test @@ -78,7 +78,6 @@ if (`SELECT '$max_query_execution_time' > 0`) { --let $time1= $max_query_execution_time } --let $time2= `SELECT 2 * $time1` ---let $time3= `SELECT 3 * $time1` --echo [on master] @@ -216,9 +215,9 @@ INSERT INTO t1 VALUES (delay_on_slave(1), 6); # Set up a longer delay. --source include/stop_slave.inc ---echo # CHANGE MASTER TO MASTER_DELAY = 3*T +--echo # CHANGE MASTER TO MASTER_DELAY = a long time to test STOP/START REPLICA do not wait for the delay --disable_query_log -eval CHANGE MASTER TO MASTER_DELAY = $time3; +eval CHANGE MASTER TO MASTER_DELAY = 1000; --enable_query_log --source include/start_slave.inc @@ -229,15 +228,18 @@ INSERT INTO t1 VALUES ('stop slave and start slave: DML', 7); --echo [on slave] --connection slave ---echo # sleep 1*T ---sleep $time1 ---let $timestamp_before_stop= `SELECT UNIX_TIMESTAMP()` +let $wait_condition= SELECT COUNT(*)=1 FROM information_schema.processlist WHERE state = "Waiting until MASTER_DELAY seconds after master executed event"; +--source include/wait_condition.inc +#--echo # sleep 1*T +#--sleep $time1 +#--let $timestamp_before_stop= `SELECT UNIX_TIMESTAMP()` --let $relay_log_pos_before_stop= query_get_value(SHOW SLAVE STATUS, Relay_Log_Pos, 1) --source include/stop_slave.inc ---let $assert_text= STOP SLAVE should finish quickly, not wait for the ongoing sleep to finish ---let $assert_cond= UNIX_TIMESTAMP() - $timestamp_before_stop < $time1 ---source include/rpl_assert.inc +# This $time1 check for an "instant" slave stop/start is problematic on BB. For the stop/start to occur without the query being executed should suffice. +#--let $assert_text= STOP SLAVE should finish quickly, not wait for the ongoing sleep to finish +#--let $assert_cond= UNIX_TIMESTAMP() - $timestamp_before_stop < $time1 +#--source include/rpl_assert.inc --let $assert_text= SQL thread position should not increase after STOP SLAVE --let $assert_cond= [SHOW SLAVE STATUS, Relay_Log_Pos, 1] = $relay_log_pos_before_stop @@ -251,20 +253,34 @@ INSERT INTO t1 VALUES ('stop slave and start slave: DML', 7); --let $assert_cond= "[SHOW SLAVE STATUS, Slave_SQL_Running_State, 1]" = "" --source include/rpl_assert.inc +--echo # CHANGE MASTER TO MASTER_DELAY = a shorter time to test remaining functionality +--let $time3= `SELECT 5` +--disable_query_log +eval CHANGE MASTER TO MASTER_DELAY = $time3; +--enable_query_log +# Get time at which slave starts to check that query execution takes >= MASTER_DELAY +--let $timestamp_before_start= `SELECT UNIX_TIMESTAMP()` --source include/start_slave.inc ---let $assert_text= START SLAVE should finish quickly ---let $assert_cond= UNIX_TIMESTAMP() - $timestamp_before_stop < $time1 ---source include/rpl_assert.inc +#--let $assert_text= START SLAVE should finish quickly +#--let $assert_cond= UNIX_TIMESTAMP() - $timestamp_before_stop < $time1 +#--source include/rpl_assert.inc --let $query_number= 7 ---source include/delayed_slave_wait_on_query.inc +--source include/delayed_slave_wait_on_query2.inc --echo ==== STOP SLAVE / START SLAVE + DDL ==== --echo This verifies BUG#56442 +--echo # CHANGE MASTER TO MASTER_DELAY = a long time to test STOP/START REPLICA do not wait for the delay +--source include/stop_slave.inc +--disable_query_log +eval CHANGE MASTER TO MASTER_DELAY = 1000; +--enable_query_log +--source include/start_slave.inc + --echo [on master] --connection master CREATE TABLE t_check_dml_not_executed_prematurely (a INT); @@ -272,16 +288,18 @@ CREATE TABLE t_check_dml_not_executed_prematurely (a INT); --echo [on slave] --connection slave ---echo # sleep 1*T ---sleep $time1 +let $wait_condition= SELECT COUNT(*)=1 FROM information_schema.processlist WHERE state = "Waiting until MASTER_DELAY seconds after master executed event"; +--source include/wait_condition.inc +#--echo # sleep 1*T +#--sleep $time1 ---let $timestamp_before_stop= `SELECT UNIX_TIMESTAMP()` +#--let $timestamp_before_stop= `SELECT UNIX_TIMESTAMP()` --let $relay_log_pos_before_stop= query_get_value(SHOW SLAVE STATUS, Relay_Log_Pos, 1) --source include/stop_slave.inc ---let $assert_text= STOP SLAVE should finish quickly, not wait for the ongoing sleep to finish ---let $assert_cond= UNIX_TIMESTAMP() - $timestamp_before_stop < $time1 ---source include/rpl_assert.inc +#--let $assert_text= STOP SLAVE should finish quickly, not wait for the ongoing sleep to finish +#--let $assert_cond= UNIX_TIMESTAMP() - $timestamp_before_stop < $time1 +#--source include/rpl_assert.inc --let $assert_text= SQL thread position should not increase after STOP SLAVE --let $assert_cond= [SHOW SLAVE STATUS, Relay_Log_Pos, 1] = $relay_log_pos_before_stop @@ -295,14 +313,21 @@ CREATE TABLE t_check_dml_not_executed_prematurely (a INT); --let $assert_cond= "[SHOW SLAVE STATUS, Slave_SQL_Running_State, 1]" = "" --source include/rpl_assert.inc +--echo # CHANGE MASTER TO MASTER_DELAY = a shorter time to test remaining functionality +--let $time3= `SELECT 5` +--disable_query_log +eval CHANGE MASTER TO MASTER_DELAY = $time3; +--enable_query_log +# Get time at which slave starts to check that query execution takes >= MASTER_DELAY +--let $timestamp_before_start= `SELECT UNIX_TIMESTAMP()` --source include/start_slave.inc ---let $assert_text= START SLAVE should finish quickly ---let $assert_cond= UNIX_TIMESTAMP() - $timestamp_before_stop < $time1 ---source include/rpl_assert.inc +#--let $assert_text= START SLAVE should finish quickly +#--let $assert_cond= UNIX_TIMESTAMP() - $timestamp_before_stop < $time1 +#--source include/rpl_assert.inc ---echo # sleep 1*T ---sleep $time1 +#--echo # sleep 1*T +#--sleep $time1 --let $assert_text= DDL Query should not be executed after START SLAVE --let $assert_cond= COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = "t_check_dml_not_executed_prematurely" @@ -312,11 +337,12 @@ CREATE TABLE t_check_dml_not_executed_prematurely (a INT); --let $assert_cond= "[SHOW SLAVE STATUS, Slave_SQL_Running_State, 1]" LIKE "Waiting until MASTER_DELAY%" --source include/rpl_assert.inc ---echo # sleep 1*T ---sleep $time1 +#--echo # sleep 1*T +#--sleep $time1 --echo # sync with master (with timeout 1*T) --source include/sync_with_master.inc +--let $timestamp_after_sync= `SELECT UNIX_TIMESTAMP()` --let $assert_text= DDL Query should be executed --let $assert_cond= COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = "t_check_dml_not_executed_prematurely" @@ -326,6 +352,9 @@ CREATE TABLE t_check_dml_not_executed_prematurely (a INT); --let $assert_cond= "[SHOW SLAVE STATUS, Slave_SQL_Running_State, 1]" LIKE "Slave has read all relay log%" --source include/rpl_assert.inc +--let $assert_text= Query should have taken at least delay time +--let $assert_cond= $timestamp_after_sync - $timestamp_before_start >= $time3 +--source include/rpl_assert.inc --source include/check_slave_is_running.inc |