Debian Codegraph @

mysql-test/suite/rpl/include/rpl_slave_max_statement_time.inc

raw
1 #
2 # Helper test file to ensure that an event running on a slave which executes
3 # for longer than @@slave_max_statement_time will time out. By default, it will
4 # use the sleep function to imitate a long running function. This can be
5 # changed to use locks using the parameter with_lock.
6 #
7 # Parameters:
8 # with_lock (boolean, in) : Changes the long running command from using SLEEP
9 # to using locks. In particular, the MTR test will take the table level
10 # write lock on the slave side, while the slave concurrently tries to
11 # execute an insert statement.
12 #
13 # use_load_data (boolean, in) : If in row logging format, uses LOAD DATA
14 # INFILLE command to create Load_log_events to create the events which
15 # should time out
16 #
17
18 --connection master
19 create table t1(a int not null auto_increment, b int, primary key(a)) engine=InnoDB;
20 --source include/save_master_gtid.inc
21
22 --connection slave
23 --source include/sync_with_master_gtid.inc
24 --source include/stop_slave.inc
25 SET @old_slave_max_statement_time=@@GLOBAL.slave_max_statement_time;
26 SET GLOBAL slave_max_statement_time=0.75;
27
28 --connection master
29 --echo # Long running command due to a lock conflict
30 if (!$use_load_data)
31 {
32 INSERT INTO t1(b) VALUES (1);
33 }
34 if ($use_load_data)
35 {
36 load data infile '../../std_data/rpl_loaddata.dat' into table t1;
37 }
38 --source include/save_master_gtid.inc
39
40 --connection slave1
41 BEGIN; INSERT INTO t1(b) VALUES (1);
42
43 --connection slave
44
45 --echo # Starting slave to receive event which will take longer to execute
46 --echo # than slave_max_statement_time
47 START SLAVE;
48
49 # ER_SLAVE_STATEMENT_TIMEOUT
50 --let $slave_sql_errno= 4192
51 --source include/wait_for_slave_sql_error.inc
52
53 --echo # Ensuring event was not processed..
54 --let $t1_count= `select count(*) from t1`
55 if ($t1_count != 0)
56 {
57 --die Event should have timed out on the slave and not been executed
58 }
59 --echo # ..success
60
61 --echo # Remove slave timeout and catch up to master
62 SET GLOBAL slave_max_statement_time=0;
63
64 --connection slave1
65 ROLLBACK;
66
67 --source include/start_slave.inc
68 --source include/sync_with_master_gtid.inc
69
70 --echo # Test case cleanup
71 --connection master
72 DROP TABLE t1;
73 --source include/save_master_gtid.inc
74
75 --connection slave
76 --source include/sync_with_master_gtid.inc
77 --source include/stop_slave.inc
78 SET GLOBAL slave_max_statement_time=@old_slave_max_statement_time;
79 --source include/start_slave.inc