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.
10
# We don't 'show status like 'slave_retried_transactions'' because this
11
# is not repeatable (depends on sleeps).
13
-- source include/master-slave.inc
16
eval CREATE TABLE t1 (a INT NOT NULL, KEY(a)) ENGINE=$engine_type;
17
eval CREATE TABLE t2 (a INT NOT NULL, KEY(a)) ENGINE=$engine_type;
18
# requiring 'unique' for the timeout part of the test
19
eval CREATE TABLE t3 (a INT UNIQUE) ENGINE=$engine_type;
20
eval CREATE TABLE t4 (a INT) ENGINE=$engine_type;
21
show variables like 'slave_transaction_retries';
22
sync_slave_with_master;
26
show variables like 'slave_transaction_retries';
33
# Let's keep BEGIN and the locked statement in two different relay logs.
34
insert into t2 values (0); # t2,t1 actors of deadlock in repl-ed ta
35
#insert into t3 select * from t2 for update;
40
eval insert into t3 values( $1 );
44
insert into t1 values(1);
50
# Let's make our transaction large so that it's repl-ed msta that's victim
55
eval insert into t4 values( $1 );
59
select * from t1 for update; # t1,t2 on local slave's
62
# bad option, todo: replicate a non-transactional t_sync with the transaction
63
# and use wait_until_rows_count macro below
64
--real_sleep 3 # hope that slave is blocked now
67
#--include wait_until_rows_count.inc
69
select * from t2 for update /* dl */; # provoke deadlock, repl-ed should be victim
72
select * from t1; # check that repl-ed succeeded finally
73
select * from t2 /* must be 1 */;
74
# check that no error is reported
75
--replace_column 1 # 7 # 8 # 9 # 16 # 22 # 23 # 33 # 35 # 36 #
76
--replace_result $MASTER_MYPORT MASTER_MYPORT
81
# 2) Test lock wait timeout
85
change master to master_log_pos=549; # the BEGIN log event
87
select * from t2 for update; # hold lock
89
--real_sleep 10 # repl-ed should have blocked, and be retrying
90
select count(*) from t3 /* must be zero */; # replaying begins after rollback
93
select * from t1; # check that repl-ed succeeded finally
95
# check that no error is reported
96
--replace_column 1 # 7 # 8 # 9 # 11 # 16 # 22 # 23 # 33 #
97
--replace_result $MASTER_MYPORT MASTER_MYPORT
102
# Now we repeat 2), but with BEGIN in the same relay log as
103
# COMMIT (to see if seeking into hot log is ok).
104
set @my_max_relay_log_size= @@global.max_relay_log_size;
105
set global max_relay_log_size=0;
107
# This is really copy-paste of 2) of above
110
change master to master_log_pos=549;
112
select * from t2 for update;
115
select count(*) from t3 /* must be zero */; # replaying begins after rollback
120
--replace_column 1 # 7 # 8 # 9 # 11 # 16 # 22 # 23 # 33 # 35 # 36 #
121
--replace_result $MASTER_MYPORT MASTER_MYPORT
127
drop table t1,t2,t3,t4;
128
sync_slave_with_master;
129
set global max_relay_log_size= @my_max_relay_log_size;
131
--echo End of 5.1 tests