Debian Codegraph @

mysql-test/suite/galera/t/galera_toi_ddl_locking.test

raw
1 --source include/galera_cluster.inc
2 --source include/have_innodb.inc
3 --source include/have_debug.inc
4 --source include/have_debug_sync.inc
5
6 #
7 # Test that DDL indeed causes all nodes to block so even unrelated updates
8 # are not allowed to proceed. We block the DDL using DBUG_SYNC
9 #
10
11 CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB;
12 CREATE TABLE t2 (f1 INTEGER) ENGINE=InnoDB;
13
14 --let $galera_connection_name = node_1a
15 --let $galera_server_number = 1
16 --source include/galera_connect.inc
17 SET SESSION wsrep_sync_wait = 0;
18
19 --let $galera_connection_name = node_1b
20 --let $galera_server_number = 1
21 --source include/galera_connect.inc
22
23 # node_1c tests write to unrelated table trough a transaction
24 --let $galera_connection_name = node_1c
25 --let $galera_server_number = 1
26 --source include/galera_connect.inc
27
28 --connection node_1
29 SET DEBUG_SYNC= 'RESET';
30 SET DEBUG_SYNC = 'alter_table_before_open_tables SIGNAL before_open_tables WAIT_FOR continue';
31 --send ALTER TABLE t1 ADD COLUMN f2 INTEGER;
32
33 --connection node_1a
34 SET DEBUG_SYNC= 'now WAIT_FOR before_open_tables';
35
36 # if we would retry the insert, it would fail for wrong column count
37 # on second try
38 SET wsrep_retry_autocommit=0;
39
40 # Allowed
41 SELECT COUNT(*) = 0 FROM t1;
42
43 # Allowed
44 SELECT COUNT(*) = 0 FROM t2;
45
46 # Not allowed, this will hang because of ALTER
47 --send INSERT INTO t1 VALUES (1);
48
49 --connection node_1c
50 SET SESSION wsrep_sync_wait = 0;
51
52 SET AUTOCOMMIT=OFF;
53 START TRANSACTION;
54
55 # Allowed
56 SELECT COUNT(*) = 0 FROM t1;
57
58 # Allowed
59 SELECT COUNT(*) = 0 FROM t2;
60
61 # Allowed (until commit)
62 INSERT INTO t2 VALUES (1);
63
64 # Hangs
65 --send COMMIT;
66
67 --connection node_1b
68 SET SESSION wsrep_sync_wait = 0;
69
70 # The Commit issued above is still not done
71 --sleep 1
72 SELECT COUNT(*) = 0 FROM t2;
73
74 SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE INFO = 'Commit';
75
76 SET DEBUG_SYNC= 'now SIGNAL continue';
77
78 --connection node_1a
79 --error ER_LOCK_DEADLOCK
80 --reap
81
82 --connection node_1c
83 # this will succeeed, becaus the query will be replayed
84 --reap
85
86 --connection node_1
87 --reap
88
89 SELECT COUNT(*) = 0 FROM t1;
90 SELECT COUNT(*) = 1 FROM t2;
91 SET debug_sync='RESET';
92
93 --connection node_2
94 SELECT COUNT(*) = 0 FROM t1;
95 SELECT COUNT(*) = 1 FROM t2;
96
97 DROP TABLE t1;
98 DROP TABLE t2;