Debian Codegraph @

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

raw
1 #
2 # Test wsrep_auto_increment_control = OFF
3 # We issue two concurrent INSERTs and one will fail with a deadlock error
4 #
5
6 --source include/galera_cluster.inc
7 --source include/have_innodb.inc
8
9 --let $auto_increment_control_orig = `SELECT @@wsrep_auto_increment_control`
10
11 #
12 # Preserve existing variable values
13 #
14
15 --connection node_1
16 --let $auto_increment_increment_node1 = `SELECT @@auto_increment_increment`
17 --let $auto_increment_offset_node1 = `SELECT @@auto_increment_offset`
18
19 # Restore stock MySQL defaults
20 SET GLOBAL wsrep_auto_increment_control = OFF;
21 SET GLOBAL auto_increment_increment = 1;
22 SET GLOBAL auto_increment_offset = 1;
23
24 #Open a fresh connection to node_1 so that the variables above take effect
25 --let $galera_connection_name = node_1a
26 --let $galera_server_number = 1
27 --source include/galera_connect.inc
28
29 --connection node_2
30 --let $auto_increment_increment_node2 = `SELECT @@auto_increment_increment`
31 --let $auto_increment_offset_node2 = `SELECT @@auto_increment_offset`
32
33 SET GLOBAL wsrep_auto_increment_control = OFF;
34 SET GLOBAL auto_increment_increment = 1;
35 SET GLOBAL auto_increment_offset = 1;
36
37 #Open a fresh connection to node_2
38 --let $galera_connection_name = node_2a
39 --let $galera_server_number = 2
40 --source include/galera_connect.inc
41
42 --connection node_1a
43 SELECT @@auto_increment_increment = 1;
44 SELECT @@auto_increment_offset = 1;
45
46 CREATE TABLE t1 (f1 INTEGER AUTO_INCREMENT PRIMARY KEY, node VARCHAR(10)) ENGINE=InnoDB;
47
48 #
49 # We expect that SHOW CREATE TABLE on both nodes will return identical values
50 #
51
52 SHOW CREATE TABLE t1;
53
54 --connection node_2a
55
56 SHOW CREATE TABLE t1;
57
58 --connection node_1a
59 SELECT @@auto_increment_increment = 1;
60 SELECT @@auto_increment_offset = 1;
61 SET AUTOCOMMIT=OFF;
62 START TRANSACTION;
63 INSERT INTO t1 (node) VALUES ('node1');
64 SELECT f1 FROM t1;
65
66 --connection node_2a
67 SELECT @@auto_increment_increment = 1;
68 SELECT @@auto_increment_offset = 1;
69 SET AUTOCOMMIT=OFF;
70 START TRANSACTION;
71 INSERT INTO t1 (node) VALUES ('node2');
72 SELECT f1 FROM t1;
73
74 --connection node_1a
75 COMMIT;
76
77 --connection node_2a
78 --error ER_LOCK_DEADLOCK
79 COMMIT;
80
81 --connection node_1a
82 SELECT * FROM t1;
83
84 --connection node_2a
85 SELECT * FROM t1;
86
87 #
88 # Restore all variables as they were
89 #
90
91 --disable_query_log
92
93 --connection node_1
94 --eval SET GLOBAL wsrep_auto_increment_control = $auto_increment_control_orig
95 --eval SET GLOBAL auto_increment_increment = $auto_increment_increment_node1
96 --eval SET GLOBAL auto_increment_offset = $auto_increment_offset_node1
97 --disconnect node_1a
98
99 --connection node_2
100 --eval SET GLOBAL wsrep_auto_increment_control = $auto_increment_control_orig
101 --eval SET GLOBAL auto_increment_increment = $auto_increment_increment_node2
102 --eval SET GLOBAL auto_increment_offset = $auto_increment_offset_node2
103 --disconnect node_2a
104
105 --enable_query_log
106
107 DROP TABLE t1;