| 1 |
# |
| 2 |
# BF-BF conflict on MDL locks between: DROP TABLE t2 and UPDATE on t1 |
| 3 |
# with t2 referencing t1 |
| 4 |
# |
| 5 |
|
| 6 |
--source include/galera_cluster.inc |
| 7 |
--source include/have_debug_sync.inc |
| 8 |
|
| 9 |
# |
| 10 |
# Setup |
| 11 |
# |
| 12 |
--connection node_2 |
| 13 |
SET GLOBAL wsrep_slave_threads=2; |
| 14 |
|
| 15 |
CREATE TABLE t1 ( |
| 16 |
id INTEGER PRIMARY KEY, |
| 17 |
f2 INTEGER); |
| 18 |
|
| 19 |
CREATE TABLE t2 ( |
| 20 |
f1 INT PRIMARY KEY, |
| 21 |
t1_id INT NOT NULL, |
| 22 |
f2 INTEGER NOT NULL, |
| 23 |
KEY key_t1_id(t1_id), |
| 24 |
CONSTRAINT key_t1_id FOREIGN KEY (t1_id) REFERENCES t1 (id) ON UPDATE CASCADE ON DELETE CASCADE); |
| 25 |
|
| 26 |
INSERT INTO t1 VALUES (1,0); |
| 27 |
INSERT INTO t1 VALUES (2,0); |
| 28 |
|
| 29 |
INSERT INTO t2 VALUES (1,1,1234); |
| 30 |
INSERT INTO t2 VALUES (2,2,1234); |
| 31 |
|
| 32 |
# |
| 33 |
# DROP TABLE t2 and wait for it to reach node_2 |
| 34 |
# |
| 35 |
--connection node_2 |
| 36 |
SET GLOBAL DEBUG_DBUG = "d,sync.wsrep_apply_toi"; |
| 37 |
|
| 38 |
--connection node_1 |
| 39 |
DROP TABLE t2; |
| 40 |
|
| 41 |
--connection node_2 |
| 42 |
SET DEBUG_SYNC = "now WAIT_FOR sync.wsrep_apply_toi_reached"; |
| 43 |
|
| 44 |
SET SESSION wsrep_sync_wait = 0; |
| 45 |
--let $expected_apply_waits = `SELECT VARIABLE_VALUE+1 FROM information_schema.global_status WHERE VARIABLE_NAME = 'wsrep_apply_waits'` |
| 46 |
--echo $expected_apply_waits |
| 47 |
|
| 48 |
# |
| 49 |
# Issue a UPDATE to table that references t1 |
| 50 |
# Notice that we update field f2, not the primary key, |
| 51 |
# and not foreign key. Bug does not manifest if we update |
| 52 |
# one of those fields (because FK keys appended in those cases). |
| 53 |
# |
| 54 |
--connection node_1 |
| 55 |
UPDATE t1 SET f2 = 1 WHERE id=2; |
| 56 |
|
| 57 |
|
| 58 |
# |
| 59 |
# Expect the UPDATE to depend on the DROP, |
| 60 |
# therefore it should wait for the DROP to |
| 61 |
# finish before it can be applied. |
| 62 |
# If bug is present, expect the wait condition |
| 63 |
# to timeout and when the UPDATE applies, it |
| 64 |
# will be granted a MDL lock of type SHARED_READ |
| 65 |
# for table t1. When resumed, the DROP TABLE will |
| 66 |
# also try to MDL lock t1, causing a BF-BF conflict |
| 67 |
# on that MDL lock. |
| 68 |
# |
| 69 |
--connection node_2 |
| 70 |
--let $wait_condition = SELECT VARIABLE_VALUE = $expected_apply_waits FROM information_schema.global_status WHERE VARIABLE_NAME = 'wsrep_apply_waits' |
| 71 |
--source include/wait_condition.inc |
| 72 |
SET DEBUG_SYNC = "now SIGNAL signal.wsrep_apply_toi"; |
| 73 |
|
| 74 |
SET SESSION wsrep_sync_wait = DEFAULT; |
| 75 |
SELECT * FROM t1; |
| 76 |
|
| 77 |
# |
| 78 |
# Cleanup |
| 79 |
# |
| 80 |
SET DEBUG_SYNC = 'RESET'; |
| 81 |
SET GLOBAL DEBUG_DBUG = ''; |
| 82 |
SET GLOBAL wsrep_slave_threads = DEFAULT; |
| 83 |
DROP TABLE t1; |