Debian Codegraph @

mysql-test/suite/rpl/t/rpl_sql_thd_start_errno_cleared.test

raw
1 #
2 # Ensure that when the slave restarts, the last error code displayed by
3 # SHOW SLAVE STATUS is cleared before Slave_SQL_Running is set.
4 #
5 # To ensure that, this test uses the debug_sync mechanism to pause an errored
6 # and restarting slave's SQL thread after it has set its running state to YES,
7 # and then ensures that Last_SQL_Errno is 0. The slave error is a forced innodb
8 # row lock timeout.
9 #
10 #
11 # References
12 # MDEV-31177: SHOW SLAVE STATUS Last_SQL_Errno Race Condition on Errored
13 # Slave Restart
14 #
15 source include/have_binlog_format_row.inc;
16 source include/have_innodb.inc;
17 source include/have_debug.inc;
18 source include/have_debug_sync.inc;
19 source include/master-slave.inc;
20
21 --connection master
22 create table t1 (a int primary key, b int) engine=innodb;
23 insert t1 values (1,1);
24 --source include/save_master_gtid.inc
25
26 --connection slave
27 --source include/sync_with_master_gtid.inc
28 --source include/stop_slave.inc
29 set @save_innodb_lock_wait_timeout= @@global.innodb_lock_wait_timeout;
30 set @save_slave_trans_retries= @@global.slave_transaction_retries;
31 set @@global.innodb_lock_wait_timeout= 1;
32 set @@global.slave_transaction_retries= 0;
33
34 --connection master
35 update t1 set b=b+10 where a=1;
36 --source include/save_master_gtid.inc
37
38 --connection slave1
39 BEGIN;
40 --eval SELECT * FROM t1 WHERE a=1 FOR UPDATE
41
42 --connection slave
43 --source include/start_slave.inc
44
45 --let $slave_sql_errno= 1205
46 --source include/wait_for_slave_sql_error.inc
47
48 --connection slave1
49 ROLLBACK;
50
51 --connection slave
52 set @save_dbug = @@global.debug_dbug;
53 set @@global.debug_dbug= "+d,delay_sql_thread_after_release_run_lock";
54 --source include/start_slave.inc
55 set debug_sync= "now wait_for sql_thread_run_lock_released";
56
57 --let $sql_running = query_get_value("SHOW SLAVE STATUS", Slave_SQL_Running, 1)
58 --echo # Validating that the SQL thread is running..
59 if (`SELECT strcmp("$sql_running", "YES") != 0`)
60 {
61 --echo # ..failed
62 --echo # Slave_SQL_Running: $sql_running
63 --die Slave SQL thread is not running
64 }
65 --echo # ..success
66
67 --let $last_error = query_get_value("SHOW SLAVE STATUS", Last_SQL_Errno, 1)
68 --echo # Validating that Last_SQL_Errno is cleared..
69 if ($last_error)
70 {
71 --echo # ..failed
72 --echo # Last_SQL_Errno: $last_error
73 --die SHOW SLAVE STATUS shows the error from the last session on startup
74 }
75 --echo # ..success
76
77 set debug_sync= "now signal sql_thread_continue";
78
79 --echo # Wait for debug_sync signal to have been received before issuing RESET
80 let $wait_condition= select count(*)=0 from information_schema.processlist where state like "debug sync point%";
81 source include/wait_condition.inc;
82
83 set @@global.debug_dbug= @saved_dbug;
84 set debug_sync= "RESET";
85
86 --echo # Cleanup
87 --connection master
88 drop table t1;
89
90 --connection slave
91 --source include/stop_slave.inc
92 set @@global.innodb_lock_wait_timeout= @save_innodb_lock_wait_timeout;
93 set @@global.slave_transaction_retries= @save_slave_trans_retries;
94 --source include/start_slave.inc
95
96 --source include/rpl_end.inc
97 --echo # End of rpl_sql_thd_start_errno_cleared.test