Debian Codegraph @

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

raw
1 #
2 # Purpose:
3 # This test ensures that the slave can limit the execution time of its
4 # events via the global system variable @@slave_max_statement_time.
5 #
6 # Methodology:
7 # This test uses the following test cases to ensure that a slave will
8 # correctly limit the execution time of its events:
9 # 1) Using a serial slave, the SQL thread should time out when its underlying
10 # event executes for longer than @@slave_max_statement_time.
11 # 2) Using a parallel slave, a worker thread should time out when its
12 # underlying event executes for longer than @@slave_max_statement_time.
13 # 3) Load-based log events (from LOAD DATA INFILE) should time out if their
14 # execution time exceeds @@slave_max_statement_time
15 # 4) Locally executed long running statements should not time out due to
16 # @@slave_max_statement_time.
17 #
18 # References:
19 # MDEV-27161: Add option for SQL thread to limit maximum execution time per
20 # query replicated
21 #
22 --source include/have_innodb.inc
23 --source include/master-slave.inc
24
25 --echo #
26 --echo # Set up
27 --echo #
28 --connection master
29 SET STATEMENT sql_log_bin=0 FOR CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format");
30 SET STATEMENT sql_log_bin=0 FOR CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format");
31 --connection slave
32 SET STATEMENT sql_log_bin=0 FOR CALL mtr.add_suppression("Slave log event execution was interrupted");
33 SET STATEMENT sql_log_bin=0 FOR CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format");
34 SET @save_slave_max_statement_time=@@GLOBAL.slave_max_statement_time;
35
36 --let $with_lock= 1
37
38 --echo #
39 --echo # Test Case 1) Using a serial slave, the SQL thread should time out when
40 --echo # its underlying event executes for longer than @@slave_max_statement_time.
41 --echo #
42 --source include/rpl_slave_max_statement_time.inc
43
44
45 --echo #
46 --echo # Test Case 2) Using a parallel slave, a worker thread should time out
47 --echo # when its underlying event executes for longer than
48 --echo # @@slave_max_statement_time
49 --echo #
50
51 --source include/stop_slave.inc
52 SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads;
53 SET @old_parallel_mode=@@GLOBAL.slave_parallel_mode;
54 SET GLOBAL slave_parallel_threads=2;
55 SET GLOBAL slave_parallel_mode='optimistic';
56 --source include/start_slave.inc
57
58 --source include/rpl_slave_max_statement_time.inc
59
60 --source include/stop_slave.inc
61 SET GLOBAL slave_parallel_mode=@old_parallel_mode;
62 SET GLOBAL slave_parallel_threads=@old_parallel_threads;
63 --source include/start_slave.inc
64
65
66 --echo #
67 --echo # Test Case 3) Load-based log events (from LOAD DATA INFILE) should time
68 --echo # out if their execution time exceeds @@slave_max_statement_time
69 --echo #
70 --let $use_load_data= 1
71 --source include/rpl_slave_max_statement_time.inc
72 --let $use_load_data=
73
74
75 --echo #
76 --echo # Test Case 4) Locally executed long running statements should not time
77 --echo # out due to @@slave_max_statement_time
78 --echo #
79
80 --connection slave
81 --source include/stop_slave.inc
82 SET @old_slave_max_statement_time=@@GLOBAL.slave_max_statement_time;
83 SET @old_gtid_domain_id=@@GLOBAL.gtid_domain_id;
84 SET @@GLOBAL.slave_max_statement_time=0.75;
85 SET @@GLOBAL.gtid_domain_id=1;
86 --source include/start_slave.inc
87
88 CREATE TABLE t2 (a int);
89 SET STATEMENT sql_log_bin=0 FOR INSERT INTO t2 SELECT SLEEP(1);
90 --let $t2_count= `SELECT COUNT(*) FROM t2`
91 if ($t2_count != 1)
92 {
93 --die Local long running insert statement should have completed
94 }
95 DROP TABLE t2;
96
97 --source include/stop_slave.inc
98 SET GLOBAL gtid_domain_id=@old_gtid_domain_id;
99 SET GLOBAL slave_max_statement_time=@old_slave_max_statement_time;
100 --source include/start_slave.inc
101
102
103 --echo # Cleanup
104 --source include/stop_slave.inc
105 SET GLOBAL slave_max_statement_time=@save_slave_max_statement_time;
106 --source include/start_slave.inc
107
108 --source include/rpl_end.inc
109
110 --echo # End of rpl_slave_max_statement_time.test