2014-05-08 14:20:18 +02:00
|
|
|
--source include/have_innodb.inc
|
|
|
|
--source include/have_debug.inc
|
|
|
|
--source include/have_debug_sync.inc
|
|
|
|
--let $rpl_topology=1->2
|
|
|
|
--source include/rpl_init.inc
|
|
|
|
|
|
|
|
--echo *** Test retry of transactions that fail to replicate due to deadlock or similar temporary error. ***
|
|
|
|
|
|
|
|
--connection server_1
|
|
|
|
ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
|
|
|
|
CREATE TABLE t1 (a int PRIMARY KEY, b INT) ENGINE=InnoDB;
|
|
|
|
INSERT INTO t1 VALUES (1,1);
|
|
|
|
--save_master_pos
|
|
|
|
|
|
|
|
# Use a stored function to inject a debug_sync into the appropriate THD.
|
|
|
|
# The function does nothing on the master, and on the slave it injects the
|
|
|
|
# desired debug_sync action(s).
|
|
|
|
SET sql_log_bin=0;
|
|
|
|
--delimiter ||
|
|
|
|
CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
|
|
|
|
RETURNS INT DETERMINISTIC
|
|
|
|
BEGIN
|
|
|
|
RETURN x;
|
|
|
|
END
|
|
|
|
||
|
|
|
|
--delimiter ;
|
|
|
|
SET sql_log_bin=1;
|
|
|
|
|
|
|
|
--connection server_2
|
|
|
|
SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads;
|
|
|
|
--source include/stop_slave.inc
|
|
|
|
SET GLOBAL slave_parallel_threads=5;
|
|
|
|
--source include/start_slave.inc
|
|
|
|
--sync_with_master
|
|
|
|
SET sql_log_bin=0;
|
|
|
|
--delimiter ||
|
|
|
|
CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500))
|
|
|
|
RETURNS INT DETERMINISTIC
|
|
|
|
BEGIN
|
|
|
|
IF d1 != '' THEN
|
|
|
|
SET debug_sync = d1;
|
|
|
|
END IF;
|
|
|
|
IF d2 != '' THEN
|
|
|
|
SET debug_sync = d2;
|
|
|
|
END IF;
|
|
|
|
RETURN x;
|
|
|
|
END
|
|
|
|
||
|
|
|
|
--delimiter ;
|
2014-05-13 13:42:06 +02:00
|
|
|
SET sql_log_bin=1;
|
2014-05-08 14:20:18 +02:00
|
|
|
--source include/stop_slave.inc
|
|
|
|
|
|
|
|
--connection server_1
|
|
|
|
SET gtid_seq_no = 100;
|
|
|
|
BEGIN;
|
|
|
|
INSERT INTO t1 VALUES (2,1);
|
|
|
|
UPDATE t1 SET b=b+1 WHERE a=1;
|
|
|
|
INSERT INTO t1 VALUES (3,1);
|
|
|
|
COMMIT;
|
|
|
|
SELECT * FROM t1 ORDER BY a;
|
|
|
|
--save_master_pos
|
|
|
|
|
|
|
|
--connection server_2
|
|
|
|
SET @old_dbug= @@GLOBAL.debug_dbug;
|
2014-05-13 13:42:06 +02:00
|
|
|
SET GLOBAL debug_dbug="+d,rpl_parallel_simulate_temp_err_gtid_0_x_100";
|
2014-05-08 14:20:18 +02:00
|
|
|
let $old_retry= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1);
|
|
|
|
--source include/start_slave.inc
|
|
|
|
--sync_with_master
|
|
|
|
SET GLOBAL debug_dbug=@old_dbug;
|
|
|
|
let $new_retry= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1);
|
|
|
|
--disable_query_log
|
|
|
|
eval SELECT $new_retry - $old_retry AS retries;
|
|
|
|
--enable_query_log
|
|
|
|
|
|
|
|
SELECT * FROM t1 ORDER BY a;
|
|
|
|
|
2014-05-13 13:42:06 +02:00
|
|
|
|
|
|
|
--echo *** Test that double retry works when the first retry also fails with temp error ***
|
|
|
|
--source include/stop_slave.inc
|
|
|
|
|
|
|
|
--connection server_1
|
|
|
|
SET gtid_seq_no = 100;
|
|
|
|
SET @old_server_id = @@server_id;
|
|
|
|
SET server_id = 10;
|
|
|
|
BEGIN;
|
|
|
|
INSERT INTO t1 VALUES (4,1);
|
|
|
|
UPDATE t1 SET b=b+1 WHERE a=1;
|
|
|
|
INSERT INTO t1 VALUES (5,1);
|
|
|
|
INSERT INTO t1 VALUES (6,1);
|
|
|
|
COMMIT;
|
|
|
|
SET server_id = @old_server_id;
|
|
|
|
SELECT * FROM t1 ORDER BY a;
|
|
|
|
--save_master_pos
|
|
|
|
|
|
|
|
--connection server_2
|
|
|
|
SET @old_dbug= @@GLOBAL.debug_dbug;
|
|
|
|
SET GLOBAL debug_dbug="+d,rpl_parallel_simulate_temp_err_gtid_0_x_100,rpl_parallel_simulate_double_temp_err_gtid_0_x_100";
|
|
|
|
let $old_retry= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1);
|
|
|
|
--source include/start_slave.inc
|
|
|
|
--sync_with_master
|
|
|
|
SET GLOBAL debug_dbug=@old_dbug;
|
|
|
|
let $new_retry= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1);
|
|
|
|
--disable_query_log
|
|
|
|
eval SELECT $new_retry - $old_retry AS retries;
|
|
|
|
--enable_query_log
|
|
|
|
|
|
|
|
SELECT * FROM t1 ORDER BY a;
|
|
|
|
|
|
|
|
|
|
|
|
--echo *** Test too many retries, eventually causing failure. ***
|
|
|
|
--source include/stop_slave.inc
|
|
|
|
|
|
|
|
--connection server_1
|
|
|
|
SET gtid_seq_no = 100;
|
|
|
|
SET @old_server_id = @@server_id;
|
|
|
|
SET server_id = 11;
|
|
|
|
BEGIN;
|
|
|
|
INSERT INTO t1 VALUES (7,1);
|
|
|
|
UPDATE t1 SET b=b+1 WHERE a=1;
|
|
|
|
INSERT INTO t1 VALUES (8,1);
|
|
|
|
INSERT INTO t1 VALUES (9,1);
|
|
|
|
COMMIT;
|
|
|
|
SET server_id = @old_server_id;
|
|
|
|
SELECT * FROM t1 ORDER BY a;
|
|
|
|
--save_master_pos
|
|
|
|
|
|
|
|
--connection server_2
|
|
|
|
SET sql_log_bin=0;
|
|
|
|
CALL mtr.add_suppression("Slave worker thread retried transaction 10 time\\(s\\) in vain, giving up");
|
|
|
|
CALL mtr.add_suppression("Slave: Deadlock found when trying to get lock; try restarting transaction");
|
|
|
|
SET sql_log_bin=1;
|
|
|
|
|
|
|
|
SET @old_dbug= @@GLOBAL.debug_dbug;
|
|
|
|
SET GLOBAL debug_dbug="+d,rpl_parallel_simulate_temp_err_gtid_0_x_100,rpl_parallel_simulate_infinite_temp_err_gtid_0_x_100";
|
|
|
|
let $old_retry= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1);
|
|
|
|
START SLAVE;
|
|
|
|
--let $slave_sql_errno= 1213
|
|
|
|
--let $slave_timeout= 10
|
|
|
|
--source include/wait_for_slave_sql_error.inc
|
|
|
|
SET GLOBAL debug_dbug=@old_dbug;
|
|
|
|
let $new_retry= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1);
|
|
|
|
--disable_query_log
|
|
|
|
eval SELECT $new_retry - $old_retry AS retries;
|
|
|
|
--enable_query_log
|
|
|
|
|
|
|
|
SELECT * FROM t1 ORDER BY a;
|
|
|
|
STOP SLAVE IO_THREAD;
|
|
|
|
--source include/start_slave.inc
|
|
|
|
--sync_with_master
|
|
|
|
SELECT * FROM t1 ORDER BY a;
|
|
|
|
|
|
|
|
|
2014-05-08 14:20:18 +02:00
|
|
|
--connection server_2
|
|
|
|
--source include/stop_slave.inc
|
|
|
|
SET GLOBAL slave_parallel_threads=@old_parallel_threads;
|
|
|
|
--source include/start_slave.inc
|
|
|
|
|
|
|
|
--connection server_1
|
|
|
|
DROP TABLE t1;
|
|
|
|
DROP function foo;
|
|
|
|
|
|
|
|
--source include/rpl_end.inc
|