Debian Codegraph @

mysql-test/suite/galera/t/MDEV-32938.test

raw
1 #
2 # MDEV-32938: ALTER command is replicated and successfully applied while being BF-aborted locally.
3 #
4 # Why it happend:
5 # - ALTER went to prepare FK-referenced tables as TOI keys
6 # - to do this, it would open the main table with SHARED_HIGH_PRIO MDL lock which disregarded any
7 # other locks (including X-lock) waiting in the queue in case someone was already holding a
8 # compatible lock type (like any DML operation)
9 # - if there was other TOI operation on the same table, it would go through BF-abort cycle to grab
10 # the lock for itself
11 # - since the initial ALTER had not reached TOI yet, it would loose to real TOI operation and got
12 # BF-aborted with its THD marked as killed
13 # - then, ALTER would enter TOI and get replicated with no checks that it has already been aborted
14 # - after entering TOI mode, it would later find it'd been killed, and complete with an error
15 # - at the same time, the command would successfully apply on every other node except the initiator.
16 #
17 #
18 # NOTE : After MDL-lock conflict resolution rework this test behaviour has
19 # changed.
20 #
21
22 --source include/galera_cluster.inc
23 --source include/have_debug_sync.inc
24 --source include/have_debug.inc
25
26 --connect con1,127.0.0.1,root,,test,$NODE_MYPORT_1
27
28 call mtr.add_suppression("WSREP: ALTER TABLE isolation failure");
29
30 CREATE TABLE t1(c1 INT PRIMARY KEY, c2 INT) ENGINE=InnoDB;
31
32 # Run ALTER DROP COLUMN and hang before closing tables on adding FK keys and before entering TOI.
33 SET DEBUG_SYNC = 'wsrep_append_fk_toi_keys_before_close_tables SIGNAL may_alter';
34 --send
35 ALTER TABLE t1 DROP COLUMN c2;
36
37 --connection node_1
38 # Run ALTER ADD COLUMN
39 SET DEBUG_SYNC = 'now WAIT_FOR may_alter';
40 ALTER TABLE t1 ADD COLUMN c3 INT;
41
42 --connection con1
43 # ALTER DROP COLUMN waits
44 --reap
45
46 INSERT INTO t1 (c1, c3) VALUES (1, 0);
47
48 --connection node_2
49 # ALTER DROP COLUMN must be replicated.
50 INSERT INTO t1 (c1, c3) VALUES (2, 0);
51
52 # Cleanup.
53 --connection node_1
54 SET DEBUG_SYNC = 'RESET';
55 DROP TABLE t1;
56 --disconnect con1
57 --source include/galera_end.inc