| 1 |
# ==== Purpose ==== |
| 2 |
# |
| 3 |
# Verifies that replica-preserve-commit-order maintains the commit order and stops |
| 4 |
# newer workers from committing (inserts and XA COMMIT) if one of the older |
| 5 |
# worker (executing XA ROLLBACK) have errored out. |
| 6 |
# |
| 7 |
# ==== Implementation ==== |
| 8 |
# |
| 9 |
# 1. We start replica (server2) with replica_preserve_commit_order |
| 10 |
# enabled and running with 2 applier workers. |
| 11 |
# |
| 12 |
# 2. On slave, we enable rpl_fake_commit_order_deadlock_for_timestamp_100 |
| 13 |
# debug sync point. The rpl_fake_commit_order_deadlock_for_timestamp_100 |
| 14 |
# debug sync point would make XA PREPARE fail with ER_UNKNOWN_ERROR error. |
| 15 |
# |
| 16 |
# 3. On slave, we add the same first insert statement which will be applied on |
| 17 |
# master in step 3, but we do not commit it, to take a lock on row and block |
| 18 |
# slave sql thread when transaction are applied on master in setp 3. |
| 19 |
# |
| 20 |
# 4. The master generates some transactions (including XA PREPARE transaction) |
| 21 |
# which can be applied in parallel, by setting same commit parents for all |
| 22 |
# the inserts. |
| 23 |
# |
| 24 |
# 5. On slave, we verify that all the other inserts are also blocked and waiting |
| 25 |
# for first insert to commit i.e. applier threads are in stage 'Waiting for |
| 26 |
# preceding transaction to commit' and their is no data in the table. |
| 27 |
# |
| 28 |
# 6. On slave, we rollback the first insert executed in step 2, and verify the |
| 29 |
# transactions are applied on table t2, but XA transaction still in prepared |
| 30 |
# stage so table t1 has two rows. |
| 31 |
# |
| 32 |
# 7. On slave, verify table t1 has only two rows which were inserted before |
| 33 |
# XA transaction. Wait for slave sql thread to fail with ER_UNKNOWN_ERROR |
| 34 |
# error and then remove rpl_fake_commit_order_deadlock_for_timestamp_100 |
| 35 |
# debug sync points, and then restart slave sql thread. |
| 36 |
# |
| 37 |
# 8. On master, execute XA COMMIT for prepared XA transaction. |
| 38 |
# |
| 39 |
# 9. Cleanup. |
| 40 |
|
| 41 |
--source include/have_debug.inc |
| 42 |
--source include/have_debug_sync.inc |
| 43 |
|
| 44 |
--let $rpl_skip_start_slave = 1 |
| 45 |
--source include/master-slave.inc |
| 46 |
CALL mtr.add_suppression("Statement is unsafe because it is being used inside a XA transaction"); |
| 47 |
|
| 48 |
--source include/rpl_connection_slave.inc |
| 49 |
CALL mtr.add_suppression(".*replica coordinator and worker threads are stopped.*"); |
| 50 |
CALL mtr.add_suppression("Could not execute Write_rows event on table test.*"); |
| 51 |
CALL mtr.add_suppression("Worker .* failed executing transaction"); |
| 52 |
CALL mtr.add_suppression("Error writing relay log configuration"); |
| 53 |
|
| 54 |
|
| 55 |
--let $debug_point=rpl_fake_commit_order_deadlock_for_timestamp_100 |
| 56 |
--source include/add_debug_point.inc |
| 57 |
|
| 58 |
|
| 59 |
--source include/rpl_connection_master.inc |
| 60 |
--let $mts_spco_start_statement = CREATE TABLE t1 (c1 INT PRIMARY KEY) ENGINE = InnoDB; CREATE TABLE t2 (c1 INT PRIMARY KEY) ENGINE = InnoDB; |
| 61 |
|
| 62 |
--let $mts_spco_block_statement = BEGIN; INSERT INTO t1 VALUES (1); |
| 63 |
|
| 64 |
--let $mts_spco_parallel_statement1 = INSERT INTO t1 VALUES (1); INSERT INTO t1 VALUES (2); XA START 'xa_test_xid1'; INSERT INTO t1 VALUES (3); XA END 'xa_test_xid1'; SET TIMESTAMP = 200; XA PREPARE 'xa_test_xid1'; |
| 65 |
--let $mts_spco_parallel_statement2 = BEGIN; INSERT INTO t2 VALUES (1); INSERT INTO t2 VALUES (2); COMMIT; |
| 66 |
|
| 67 |
--let $mts_spco_assert_text1 = Verify table t1 has two rows |
| 68 |
--let $mts_spco_assert_cond1 = "[SELECT count(*) COUNT FROM t1, COUNT, 1]" = "0" |
| 69 |
|
| 70 |
--let $mts_spco_assert_text2 = Verify table t2 is empty |
| 71 |
--let $mts_spco_assert_cond2 = "[SELECT count(*) COUNT FROM t2, COUNT, 1]" = "0" |
| 72 |
|
| 73 |
--let $mts_spco_rollback_statement = ROLLBACK; |
| 74 |
--source extra/rpl_tests/rpl_mts_replica_preserve_commit_order_nobinlog.inc |
| 75 |
|
| 76 |
|
| 77 |
--connection server_2 |
| 78 |
--let $wait_condition= SELECT count(*) = 0 FROM t2 |
| 79 |
--source include/wait_condition_or_abort.inc |
| 80 |
|
| 81 |
--let $wait_condition= SELECT count(*) = 2 FROM t1 |
| 82 |
--source include/wait_condition_or_abort.inc |
| 83 |
|
| 84 |
|
| 85 |
--echo |
| 86 |
--echo # On slave, verify table t1 has only two rows which were inserted before |
| 87 |
--echo # XA transaction. Wait for slave sql thread to fail with ER_UNKNOWN_ERROR |
| 88 |
--echo # error and then remove rpl_fake_commit_order_deadlock_for_timestamp_100 |
| 89 |
--echo # debug sync points, and then restart slave sql thread. |
| 90 |
--echo |
| 91 |
|
| 92 |
--let $slave_sql_errno= 1105, 1402, 3030 |
| 93 |
--source include/wait_for_slave_sql_error.inc |
| 94 |
|
| 95 |
--let $debug_point=rpl_fake_commit_order_deadlock_for_timestamp_100 |
| 96 |
--source include/remove_debug_point.inc |
| 97 |
|
| 98 |
--source include/start_slave_sql.inc |
| 99 |
|
| 100 |
|
| 101 |
--echo |
| 102 |
--echo # On master, execute XA COMMIT for prepared XA transaction. |
| 103 |
--echo |
| 104 |
|
| 105 |
--source include/rpl_connection_master.inc |
| 106 |
XA COMMIT 'xa_test_xid1'; |
| 107 |
|
| 108 |
|
| 109 |
--echo |
| 110 |
--echo # Cleanup |
| 111 |
--echo |
| 112 |
|
| 113 |
--source include/rpl_connection_master.inc |
| 114 |
|
| 115 |
DROP TABLE t1; |
| 116 |
DROP TABLE t2; |
| 117 |
|
| 118 |
SET GLOBAL binlog_transaction_dependency_tracking=@save_binlog_transaction_dependency_tracking; |
| 119 |
|
| 120 |
--source include/sync_slave_sql_with_master.inc |
| 121 |
--source include/stop_slave.inc |
| 122 |
|
| 123 |
SET GLOBAL replica_parallel_type= @save_replica_parallel_type; |
| 124 |
--disable_warnings |
| 125 |
SET GLOBAL replica_parallel_workers= @save_replica_parallel_workers; |
| 126 |
--enable_warnings |
| 127 |
SET GLOBAL replica_preserve_commit_order= @save_replica_preserve_commit_order; |
| 128 |
--source include/start_slave.inc |
| 129 |
|
| 130 |
--source include/rpl_end.inc |