| 1 |
# |
| 2 |
# MDEV-25717 Assertion `owning_thread_id_ == wsrep::this_thread::get_id()' |
| 3 |
# |
| 4 |
# This test exposes a race condition between rollbacker thread and rollback |
| 5 |
# fragment processing. |
| 6 |
# |
| 7 |
|
| 8 |
--source include/galera_cluster.inc |
| 9 |
--source include/have_debug_sync.inc |
| 10 |
|
| 11 |
--connection node_1 |
| 12 |
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) Engine=InnoDB; |
| 13 |
INSERT INTO t1 VALUES (1), (2), (3); |
| 14 |
|
| 15 |
# |
| 16 |
# On node_2 we start a SR transaction, it going to |
| 17 |
# be BF aborted later on |
| 18 |
# |
| 19 |
--connection node_2 |
| 20 |
SET SESSION wsrep_trx_fragment_size = 1; |
| 21 |
START TRANSACTION; |
| 22 |
INSERT INTO t1 VALUES (4); |
| 23 |
|
| 24 |
--connection node_1 |
| 25 |
SELECT COUNT(*) FROM t1; # Sync wait |
| 26 |
|
| 27 |
# |
| 28 |
# Issue a conflicting TRUNCATE statement on node_1: |
| 29 |
# - on node_2, block it before it is going to apply |
| 30 |
# - on node_1, block before the before it BF aborts the INSERT |
| 31 |
# |
| 32 |
--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 |
| 33 |
--connection node_2a |
| 34 |
SET GLOBAL DEBUG_DBUG = "d,sync.wsrep_apply_toi"; |
| 35 |
|
| 36 |
--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1 |
| 37 |
--connection node_1a |
| 38 |
SET GLOBAL DEBUG_DBUG = "d,sync.wsrep_bf_abort"; |
| 39 |
|
| 40 |
--connection node_1 |
| 41 |
--send TRUNCATE TABLE t1 |
| 42 |
|
| 43 |
--connection node_1a |
| 44 |
SET DEBUG_SYNC = "now WAIT_FOR sync.wsrep_bf_abort_reached"; |
| 45 |
|
| 46 |
--connection node_2a |
| 47 |
SET DEBUG_SYNC = "now WAIT_FOR sync.wsrep_apply_toi_reached"; |
| 48 |
|
| 49 |
# |
| 50 |
# Generate one more fragment on the SR transaction. |
| 51 |
# This is going to fail certification and results |
| 52 |
# in a rollback fragment. |
| 53 |
# |
| 54 |
--connection node_2 |
| 55 |
--let $expected_cert_failures = `SELECT VARIABLE_VALUE + 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_cert_failures'` |
| 56 |
|
| 57 |
--send INSERT INTO t1 VALUES (5) |
| 58 |
|
| 59 |
# |
| 60 |
# Wait until after certify and observe the certification |
| 61 |
# failure. Let both continue and we are done on node_2. |
| 62 |
# |
| 63 |
--connection node_2a |
| 64 |
SET SESSION wsrep_sync_wait = 0; |
| 65 |
--let $wait_condition = SELECT VARIABLE_VALUE = $expected_cert_failures FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_cert_failures' |
| 66 |
--source include/wait_condition.inc |
| 67 |
SET SESSION wsrep_sync_wait = DEFAULT; |
| 68 |
|
| 69 |
SET GLOBAL DEBUG_DBUG = ""; |
| 70 |
SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_toi"; |
| 71 |
|
| 72 |
--connection node_2 |
| 73 |
--error ER_LOCK_DEADLOCK |
| 74 |
--reap |
| 75 |
|
| 76 |
# |
| 77 |
# On node_1 we expect the following things: |
| 78 |
# - the TRUNCATE should successfully bf abort the transaction |
| 79 |
# - A rollback fragment should be delivered as a result of |
| 80 |
# certification failure. We expect the rollback fragment to |
| 81 |
# be delivered after TRUNCATE has bf aborted, therefore rollback |
| 82 |
# fragment logs a dummy writeset. |
| 83 |
# |
| 84 |
--connection node_1a |
| 85 |
SET SESSION wsrep_sync_wait=0; |
| 86 |
SET GLOBAL DEBUG_DBUG = "+d,sync.wsrep_log_dummy_write_set"; |
| 87 |
|
| 88 |
# Signal the TRUNCATE to continue and observe the BF abort |
| 89 |
--let $expected_bf_aborts = `SELECT VARIABLE_VALUE + 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts'` |
| 90 |
SET DEBUG_SYNC = "now SIGNAL signal.wsrep_bf_abort"; |
| 91 |
|
| 92 |
# Expect a timeout if bug is present |
| 93 |
--let $wait_condition = SELECT VARIABLE_VALUE = $expected_bf_aborts FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_bf_aborts' |
| 94 |
--source include/wait_condition.inc |
| 95 |
|
| 96 |
# Observe logging of dummy writeset |
| 97 |
SET DEBUG_SYNC = "now WAIT_FOR sync.wsrep_log_dummy_write_set_reached"; |
| 98 |
|
| 99 |
# TRUNCATE succeeds |
| 100 |
--connection node_1 |
| 101 |
--reap |
| 102 |
|
| 103 |
# |
| 104 |
# Cleanup |
| 105 |
# |
| 106 |
--connection node_2 |
| 107 |
SET GLOBAL DEBUG_DBUG = ""; |
| 108 |
SET DEBUG_SYNC = "RESET"; |
| 109 |
|
| 110 |
--connection node_1 |
| 111 |
SET GLOBAL DEBUG_DBUG = ""; |
| 112 |
SET DEBUG_SYNC = "RESET"; |
| 113 |
DROP TABLE t1; |