1 # See if slave restarts the transaction after failing on an InnoDB deadlock error.
3 # Note: testing what happens when too many retries is possible, but
4 # needs large waits when running with --debug, so we don't do it.
5 # The same way, this test may not test what is expected when run
6 # under Valgrind, timings are too short then (with --valgrind I
7 # (Guilhem) have seen the test manage to provoke lock wait timeout
8 # error but not deadlock error; that is ok as code deals with the two
9 # errors in exactly the same way.
11 --source include/master-slave.inc
13 # 0) Prepare tables and data
14 --echo *** Prepare tables and data ***
17 eval CREATE TABLE t1 (a INT NOT NULL, KEY(a)) ENGINE=$engine_type;
18 eval CREATE TABLE t2 (a INT) ENGINE=$engine_type;
19 eval CREATE TABLE t3 (a INT NOT NULL, KEY(a)) ENGINE=$engine_type;
20 sync_slave_with_master;
25 SHOW VARIABLES LIKE 'slave_transaction_retries';
26 --source include/stop_slave.inc
30 INSERT INTO t1 VALUES (1);
31 # We make a long transaction here
32 INSERT INTO t2 VALUES (2), (2), (2), (2), (2), (2), (2), (2), (2), (2);
33 INSERT INTO t3 VALUES (3);
36 # Save BEGIN event into variable
37 let $master_pos_begin= query_get_value(SHOW BINLOG EVENTS, Pos, 5);
41 # Block slave SQL thread, wait retries of transaction, unlock slave before lock timeout
42 --echo *** Test deadlock ***
46 SELECT * FROM t1 FOR UPDATE;
47 # Save variable 'Slave_retried_transactions' before deadlock
48 let $slave_retried_transactions= query_get_value(SHOW GLOBAL STATUS LIKE 'Slave_retried_transactions', Value, 1);
50 # Wait until SQL thread blocked: variable 'Slave_retried_transactions' will incremented
51 let $status_var= Slave_retried_transactions;
52 let $status_var_value= $slave_retried_transactions;
53 let $status_type= GLOBAL;
54 let $status_var_comparsion= >;
55 --source include/wait_for_status_var.inc
56 SELECT COUNT(*) FROM t2;
63 # Check that no error is reported
64 source include/check_slave_is_running.inc;
67 # 2) Test lock wait timeout
68 # Block slave and wait lock timeout error
69 --echo *** Test lock wait timeout ***
72 --source include/stop_slave.inc
74 # Set slave position to the BEGIN log event
75 --replace_result $master_pos_begin MASTER_POS_BEGIN
76 eval CHANGE MASTER TO MASTER_LOG_POS=$master_pos_begin;
79 SELECT * FROM t1 FOR UPDATE;
80 # Wait until slave stopped with error 'Lock wait timeout exceeded'
82 let $slave_sql_errno= 1205;
83 --source include/wait_for_slave_sql_error.inc
84 SELECT COUNT(*) FROM t2;
86 --source include/start_slave.inc
88 # Check data from tables
91 # Check that no error is reported
92 source include/check_slave_is_running.inc;
95 # 3) Test lock wait timeout and purged relay log
96 # Set max_relay_log_size=0, block slave and wait lock timeout error.
97 # Restart slave and check that no erros appear
98 --echo *** Test lock wait timeout and purged relay logs ***
101 SET @my_max_relay_log_size= @@global.max_relay_log_size;
102 SET global max_relay_log_size=0;
103 --source include/stop_slave.inc
105 # Set slave position to the BEGIN log event
106 --replace_result $master_pos_begin MASTER_POS_BEGIN
107 eval CHANGE MASTER TO MASTER_LOG_POS=$master_pos_begin;
110 SELECT * FROM t1 FOR UPDATE;
111 # Wait until slave stopped with error 'Lock wait timeout exceeded'
113 let $slave_sql_errno= 1205;
114 --source include/wait_for_slave_sql_error.inc
115 SELECT COUNT(*) FROM t2;
117 --source include/start_slave.inc
119 # Check data from tables
122 # Check that no error is reported
123 source include/check_slave_is_running.inc;
127 --echo *** Clean up ***
130 sync_slave_with_master;
131 SET global max_relay_log_size= @my_max_relay_log_size;
133 --echo End of 5.1 tests
134 --source include/rpl_end.inc