|
| 1 | +# |
| 2 | +# MDEV-33133: MDL conflict handling code should skip transactions |
| 3 | +# BF-aborted before. |
| 4 | +# |
| 5 | +# It's possible that MDL conflict handling code is called more |
| 6 | +# than once for a transaction when: |
| 7 | +# - it holds more than one conflicting MDL lock |
| 8 | +# - reschedule_waiters() is executed, |
| 9 | +# which results in repeated attempts to BF-abort already aborted |
| 10 | +# transaction. |
| 11 | +# In such situations, it might be that BF-aborting logic sees |
| 12 | +# a partially rolled back transaction and erroneously decides |
| 13 | +# on future actions for such a transaction. |
| 14 | +# |
| 15 | +# The specific situation tested and fixed is when a SR transaction |
| 16 | +# applied in the node gets BF-aborted by a started TOI operation. |
| 17 | +# It's then caught with the server transaction already rolled back, |
| 18 | +# but with no MDL locks yet released. This caused wrong state |
| 19 | +# detection for such a transaction during repeated MDL conflict |
| 20 | +# handling code execution. |
| 21 | +# |
| 22 | + |
| 23 | +--source include/galera_cluster.inc |
| 24 | +--source include/have_debug_sync.inc |
| 25 | +--source include/have_debug.inc |
| 26 | + |
| 27 | +--connect node_1a,127.0.0.1,root,,test,$NODE_MYPORT_1 |
| 28 | + |
| 29 | +--connection node_1 |
| 30 | +CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; |
| 31 | +SET GLOBAL DEBUG_DBUG = 'd,sync.wsrep_rollback_mdl_release'; |
| 32 | + |
| 33 | +--connection node_2 |
| 34 | +SET SESSION wsrep_trx_fragment_size = 1; |
| 35 | +START TRANSACTION; |
| 36 | +INSERT INTO t1 VALUES (1); |
| 37 | + |
| 38 | +--connection node_1a |
| 39 | +# Sync wait for SR transaction to replicate and apply fragment. |
| 40 | +SELECT COUNT(*) FROM t1; |
| 41 | +SET SESSION wsrep_retry_autocommit = 0; |
| 42 | +SET DEBUG_SYNC = 'ha_write_row_start SIGNAL may_toi WAIT_FOR bf_abort'; |
| 43 | +--send |
| 44 | + INSERT INTO t1 VALUES (2); |
| 45 | + |
| 46 | +--connection node_1 |
| 47 | +SET DEBUG_SYNC = 'now WAIT_FOR may_toi'; |
| 48 | +# BF-abort SR transaction and wait until it reaches the point |
| 49 | +# prior to release MDL locks. |
| 50 | +# Then abort local INSERT, which will go through rescedule_waiters() |
| 51 | +# and see SR transaction holding MDL locks but already rolled back. |
| 52 | +# In this case SR transaction should be skipped in MDL conflict |
| 53 | +# handling code. |
| 54 | +SET DEBUG_SYNC = 'after_wsrep_thd_abort WAIT_FOR sync.wsrep_rollback_mdl_release_reached'; |
| 55 | +--send |
| 56 | + TRUNCATE TABLE t1; |
| 57 | + |
| 58 | +--connection node_1a |
| 59 | +# Local INSERT gets aborted. |
| 60 | +--error ER_LOCK_DEADLOCK |
| 61 | +--reap |
| 62 | +# Let the aborted SR transaction continue and finally release MDL locks, |
| 63 | +# which in turn allows TRUNCATE to complete. |
| 64 | +SET DEBUG_SYNC = 'now SIGNAL signal.wsrep_rollback_mdl_release'; |
| 65 | + |
| 66 | +--connection node_2 |
| 67 | +# SR transaction has been BF-aborted. |
| 68 | +--error ER_LOCK_DEADLOCK |
| 69 | +INSERT INTO t1 VALUES (3); |
| 70 | + |
| 71 | +--connection node_1 |
| 72 | +# TRUNCATE completes. |
| 73 | +--reap |
| 74 | + |
| 75 | +# Cleanup |
| 76 | +SET GLOBAL DEBUG_DBUG = ''; |
| 77 | +SET DEBUG_SYNC = 'RESET'; |
| 78 | +DROP TABLE t1; |
| 79 | +--disconnect node_1a |
| 80 | +--source include/galera_end.inc |
0 commit comments