1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
|
include/master-slave.inc
[connection master]
#
# Set up
#
connection master;
SET STATEMENT sql_log_bin=0 FOR CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format");
SET STATEMENT sql_log_bin=0 FOR CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format");
connection slave;
SET STATEMENT sql_log_bin=0 FOR CALL mtr.add_suppression("Slave log event execution was interrupted");
SET STATEMENT sql_log_bin=0 FOR CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format");
SET @save_slave_max_statement_time=@@GLOBAL.slave_max_statement_time;
#
# Test Case 1) Using a serial slave, the SQL thread should time out when
# its underlying event executes for longer than @@slave_max_statement_time.
#
connection master;
create table t1(a int not null auto_increment, b int, primary key(a)) engine=InnoDB;
include/save_master_gtid.inc
connection slave;
include/sync_with_master_gtid.inc
include/stop_slave.inc
SET @old_slave_max_statement_time=@@GLOBAL.slave_max_statement_time;
SET GLOBAL slave_max_statement_time=0.75;
connection master;
# Long running command due to a lock conflict
INSERT INTO t1(b) VALUES (1);
include/save_master_gtid.inc
connection slave1;
BEGIN;
INSERT INTO t1(b) VALUES (1);
connection slave;
# Starting slave to receive event which will take longer to execute
# than slave_max_statement_time
START SLAVE;
include/wait_for_slave_sql_error.inc [errno=4192]
# Ensuring event was not processed..
# ..success
# Remove slave timeout and catch up to master
SET GLOBAL slave_max_statement_time=0;
connection slave1;
ROLLBACK;
include/start_slave.inc
include/sync_with_master_gtid.inc
# Test case cleanup
connection master;
DROP TABLE t1;
include/save_master_gtid.inc
connection slave;
include/sync_with_master_gtid.inc
include/stop_slave.inc
SET GLOBAL slave_max_statement_time=@old_slave_max_statement_time;
include/start_slave.inc
#
# Test Case 2) Using a parallel slave, a worker thread should time out
# when its underlying event executes for longer than
# @@slave_max_statement_time
#
include/stop_slave.inc
SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads;
SET @old_parallel_mode=@@GLOBAL.slave_parallel_mode;
SET GLOBAL slave_parallel_threads=2;
SET GLOBAL slave_parallel_mode='optimistic';
include/start_slave.inc
connection master;
create table t1(a int not null auto_increment, b int, primary key(a)) engine=InnoDB;
include/save_master_gtid.inc
connection slave;
include/sync_with_master_gtid.inc
include/stop_slave.inc
SET @old_slave_max_statement_time=@@GLOBAL.slave_max_statement_time;
SET GLOBAL slave_max_statement_time=0.75;
connection master;
# Long running command due to a lock conflict
INSERT INTO t1(b) VALUES (1);
include/save_master_gtid.inc
connection slave1;
BEGIN;
INSERT INTO t1(b) VALUES (1);
connection slave;
# Starting slave to receive event which will take longer to execute
# than slave_max_statement_time
START SLAVE;
include/wait_for_slave_sql_error.inc [errno=4192]
# Ensuring event was not processed..
# ..success
# Remove slave timeout and catch up to master
SET GLOBAL slave_max_statement_time=0;
connection slave1;
ROLLBACK;
include/start_slave.inc
include/sync_with_master_gtid.inc
# Test case cleanup
connection master;
DROP TABLE t1;
include/save_master_gtid.inc
connection slave;
include/sync_with_master_gtid.inc
include/stop_slave.inc
SET GLOBAL slave_max_statement_time=@old_slave_max_statement_time;
include/start_slave.inc
include/stop_slave.inc
SET GLOBAL slave_parallel_mode=@old_parallel_mode;
SET GLOBAL slave_parallel_threads=@old_parallel_threads;
include/start_slave.inc
#
# Test Case 3) Load-based log events (from LOAD DATA INFILE) should time
# out if their execution time exceeds @@slave_max_statement_time
#
connection master;
create table t1(a int not null auto_increment, b int, primary key(a)) engine=InnoDB;
include/save_master_gtid.inc
connection slave;
include/sync_with_master_gtid.inc
include/stop_slave.inc
SET @old_slave_max_statement_time=@@GLOBAL.slave_max_statement_time;
SET GLOBAL slave_max_statement_time=0.75;
connection master;
# Long running command due to a lock conflict
load data infile '../../std_data/rpl_loaddata.dat' into table t1;
include/save_master_gtid.inc
connection slave1;
BEGIN;
INSERT INTO t1(b) VALUES (1);
connection slave;
# Starting slave to receive event which will take longer to execute
# than slave_max_statement_time
START SLAVE;
include/wait_for_slave_sql_error.inc [errno=4192]
# Ensuring event was not processed..
# ..success
# Remove slave timeout and catch up to master
SET GLOBAL slave_max_statement_time=0;
connection slave1;
ROLLBACK;
include/start_slave.inc
include/sync_with_master_gtid.inc
# Test case cleanup
connection master;
DROP TABLE t1;
include/save_master_gtid.inc
connection slave;
include/sync_with_master_gtid.inc
include/stop_slave.inc
SET GLOBAL slave_max_statement_time=@old_slave_max_statement_time;
include/start_slave.inc
#
# Test Case 4) Locally executed long running statements should not time
# out due to @@slave_max_statement_time
#
connection slave;
include/stop_slave.inc
SET @old_slave_max_statement_time=@@GLOBAL.slave_max_statement_time;
SET @old_gtid_domain_id=@@GLOBAL.gtid_domain_id;
SET @@GLOBAL.slave_max_statement_time=0.75;
SET @@GLOBAL.gtid_domain_id=1;
include/start_slave.inc
CREATE TABLE t2 (a int);
SET STATEMENT sql_log_bin=0 FOR INSERT INTO t2 SELECT SLEEP(1);
DROP TABLE t2;
include/stop_slave.inc
SET GLOBAL gtid_domain_id=@old_gtid_domain_id;
SET GLOBAL slave_max_statement_time=@old_slave_max_statement_time;
include/start_slave.inc
# Cleanup
include/stop_slave.inc
SET GLOBAL slave_max_statement_time=@save_slave_max_statement_time;
include/start_slave.inc
include/rpl_end.inc
# End of rpl_slave_max_statement_time.test
|