| 1 |
source include/have_binlog_format_row.inc; |
| 2 |
source include/have_innodb.inc; |
| 3 |
source include/master-slave.inc; |
| 4 |
|
| 5 |
call mtr.add_suppression("Deadlock found"); |
| 6 |
call mtr.add_suppression("Can't find record in 't.'"); |
| 7 |
|
| 8 |
connection master; |
| 9 |
CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=innodb; |
| 10 |
INSERT INTO t1 VALUES (1,1), (2,2), (3,3), (4,4); |
| 11 |
sync_slave_with_master; |
| 12 |
SHOW STATUS LIKE 'Slave_retried_transactions'; |
| 13 |
# since bug#31552/31609 idempotency is not default any longer. In order |
| 14 |
# the following UPDATE t1 to pass the mode is switched temprorarily |
| 15 |
set @@global.slave_exec_mode= 'IDEMPOTENT'; |
| 16 |
UPDATE t1 SET a = 5, b = 47 WHERE a = 1; |
| 17 |
SELECT * FROM t1 ORDER BY a; |
| 18 |
connection master; |
| 19 |
UPDATE t1 SET a = 5, b = 5 WHERE a = 1; |
| 20 |
SELECT * FROM t1 ORDER BY a; |
| 21 |
#SHOW BINLOG EVENTS; |
| 22 |
sync_slave_with_master; |
| 23 |
set @@global.slave_exec_mode= default; |
| 24 |
SHOW STATUS LIKE 'Slave_retried_transactions'; |
| 25 |
SELECT * FROM t1 ORDER BY a; |
| 26 |
source include/check_slave_is_running.inc; |
| 27 |
|
| 28 |
connection slave; |
| 29 |
call mtr.add_suppression("Slave SQL.*Could not execute Update_rows event on table test.t1"); |
| 30 |
call mtr.add_suppression("Slave SQL for channel '': worker thread retried transaction"); |
| 31 |
call mtr.add_suppression("The slave coordinator and worker threads are stopped"); |
| 32 |
# |
| 33 |
# Bug#24764800 REPLICATION FAILING ON SLAVE WITH XAER_RMFAIL ERROR |
| 34 |
# |
| 35 |
# Verify that a temporary failing replicated xa transaction completes |
| 36 |
# upon slave applier restart after previous |
| 37 |
# @@global.slave_transaction_retries number of retries in vain. |
| 38 |
# |
| 39 |
connection slave; |
| 40 |
|
| 41 |
set @save_innodb_lock_wait_timeout=@@global.innodb_lock_wait_timeout; |
| 42 |
set @save_slave_transaction_retries=@@global.slave_transaction_retries; |
| 43 |
|
| 44 |
# Slave applier parameters for the failed retry |
| 45 |
set @@global.innodb_lock_wait_timeout=1; |
| 46 |
set @@global.slave_transaction_retries=2; |
| 47 |
--source include/restart_slave_sql.inc |
| 48 |
|
| 49 |
# Temporary error implement: a record is blocked by slave local trx |
| 50 |
connection slave1; |
| 51 |
BEGIN; |
| 52 |
INSERT INTO t1 SET a = 6, b = 7; |
| 53 |
|
| 54 |
connection master; |
| 55 |
INSERT INTO t1 SET a = 99, b = 99; # slave applier warm up trx |
| 56 |
XA START 'xa1'; |
| 57 |
INSERT INTO t1 SET a = 6, b = 6; # this record eventually must be found on slave |
| 58 |
XA END 'xa1'; |
| 59 |
XA PREPARE 'xa1'; |
| 60 |
|
| 61 |
connection slave; |
| 62 |
# convert_error(ER_LOCK_WAIT_TIMEOUT) |
| 63 |
--let $err_timeout= 1205 |
| 64 |
# convert_error(ER_LOCK_DEADLOCK) |
| 65 |
--let $err_deadlock= 1213 |
| 66 |
--let $slave_sql_errno=$err_deadlock,$err_timeout |
| 67 |
--let $show_slave_sql_error= |
| 68 |
--source include/wait_for_slave_sql_error.inc |
| 69 |
|
| 70 |
# b. Slave applier parameters for successful retry after restart |
| 71 |
set @@global.innodb_lock_wait_timeout=1; |
| 72 |
set @@global.slave_transaction_retries=100; |
| 73 |
|
| 74 |
--let $rpl_allow_error=1 |
| 75 |
--source include/restart_slave_sql.inc |
| 76 |
--let $rpl_allow_error=0 |
| 77 |
|
| 78 |
--let $last_retries= query_get_value(SHOW GLOBAL STATUS LIKE 'Slave_retried_transactions', Value, 1) |
| 79 |
--let $status_type=GLOBAL |
| 80 |
--let $status_var=Slave_retried_transactions |
| 81 |
--let $status_var_value=`SELECT 1 + $last_retries` |
| 82 |
--let $status_var_comparsion= > |
| 83 |
--source include/wait_for_status_var.inc |
| 84 |
|
| 85 |
# Release the record after just one retry |
| 86 |
connection slave1; |
| 87 |
ROLLBACK; |
| 88 |
|
| 89 |
connection master; |
| 90 |
XA COMMIT 'xa1'; |
| 91 |
|
| 92 |
--source include/sync_slave_sql_with_master.inc |
| 93 |
|
| 94 |
# Proof of correctness: the committed XA is on the slave |
| 95 |
connection slave; |
| 96 |
--let $assert_text=XA transaction record must be in the table |
| 97 |
--let $assert_cond=count(*)=1 FROM t1 WHERE a=6 AND b=6 |
| 98 |
--source include/assert.inc |
| 99 |
|
| 100 |
# Bug#24764800 cleanup: |
| 101 |
set @@global.innodb_lock_wait_timeout=@save_innodb_lock_wait_timeout; |
| 102 |
set @@global.slave_transaction_retries= @save_slave_transaction_retries; |
| 103 |
|
| 104 |
# |
| 105 |
# Total cleanup: |
| 106 |
# |
| 107 |
connection master; |
| 108 |
DROP TABLE t1; |
| 109 |
--sync_slave_with_master |
| 110 |
--connection master |
| 111 |
|
| 112 |
# We must wait for the slave to stop. |
| 113 |
# Otherwise the warnings in the error log about deadlock may be written to |
| 114 |
# the error log only during shutdown, and currently the suppression of |
| 115 |
# "Deadlock found" set in this test case is not effective during server |
| 116 |
# shutdown. |
| 117 |
|
| 118 |
--source include/rpl_end.inc |