summaryrefslogtreecommitdiff
path: root/mysql-test/suite/galera_3nodes_sr/t/galera_sr_threeway_split.test
blob: 62122fe42927012fccdaebbe662dd0f6131ab4c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
#
# Test the case where the cluster splits 3 ways . The master remains in the
# primary component and is able to commit its transaction.
#

--source include/galera_cluster.inc
--source include/have_innodb.inc

--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3
# Save original auto_increment_offset values.
--let $node_1=node_1
--let $node_2=node_2
--let $node_3=node_3
--source ../galera/include/auto_increment_offset_save.inc

--connection node_1
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;

#
# Begin a separate SR transaction on every node and confirm that each node
# has SR table entries for every transaction
#

SET SESSION wsrep_trx_fragment_size = 1;
SET AUTOCOMMIT=OFF;
START TRANSACTION;

INSERT INTO t1 VALUES (10);
INSERT INTO t1 VALUES (11);
INSERT INTO t1 VALUES (12);
INSERT INTO t1 VALUES (13);
INSERT INTO t1 VALUES (14);

SELECT COUNT(*) > 0 FROM mysql.wsrep_streaming_log;

--connection node_2
--let $wait_condition = SELECT COUNT(*) > 0 FROM mysql.wsrep_streaming_log
--source include/wait_condition.inc

SET SESSION wsrep_trx_fragment_size = 1;
SET AUTOCOMMIT=OFF;
START TRANSACTION;
INSERT INTO t1 VALUES (200);
INSERT INTO t1 VALUES (201);
INSERT INTO t1 VALUES (202);
INSERT INTO t1 VALUES (203);
INSERT INTO t1 VALUES (204);

--connection node_3
--let $wait_condition = SELECT COUNT(DISTINCT node_uuid) = 2 FROM mysql.wsrep_streaming_log
--source include/wait_condition.inc

SET SESSION wsrep_trx_fragment_size = 1;
SET AUTOCOMMIT=OFF;
START TRANSACTION;
INSERT INTO t1 VALUES (300);
INSERT INTO t1 VALUES (301);
INSERT INTO t1 VALUES (302);
INSERT INTO t1 VALUES (303);
INSERT INTO t1 VALUES (304);

--connect node_1a, 127.0.0.1, root, , test, $NODE_MYPORT_1
--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2
--connect node_3a, 127.0.0.1, root, , test, $NODE_MYPORT_3

--connection node_1a
--let $wait_condition = SELECT COUNT(DISTINCT node_uuid) = 3 FROM mysql.wsrep_streaming_log
--source include/wait_condition.inc

#
# Isolate nodes #2 and #3 into separate non-primary components
#

--connection node_2a
SET GLOBAL wsrep_provider_options='gmcast.isolate=1';

--connection node_3a
SET GLOBAL wsrep_provider_options='gmcast.isolate=1';

--connection node_1a
--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
--source include/wait_condition.inc

INSERT INTO t1 VALUES (20);
INSERT INTO t1 VALUES (21);
INSERT INTO t1 VALUES (22);
INSERT INTO t1 VALUES (23);
INSERT INTO t1 VALUES (24);

#
# Restore cluster
#

--connection node_2a
--source include/wsrep_wait_disconnect.inc
SET GLOBAL wsrep_provider_options='gmcast.isolate=0';
--source include/galera_wait_ready.inc

--connection node_3a
--source include/wsrep_wait_disconnect.inc
SET GLOBAL wsrep_provider_options='gmcast.isolate=0';
--source include/galera_wait_ready.inc

--connection node_1a
--let $wait_condition = SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
--source include/wait_condition.inc
--let $node_1_gcomm_uuid = `SELECT VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_gcomm_uuid'`

--connection node_2a
--source include/wait_condition.inc

--connection node_3a
--source include/wait_condition.inc


#
# Confirm that the rejoined nodes only have node #1's transaction in their SR tables
#

--connection node_2
--error ER_LOCK_DEADLOCK
COMMIT;
SELECT COUNT(DISTINCT node_uuid) = 1 FROM mysql.wsrep_streaming_log;
--disable_query_log
--eval SELECT DISTINCT node_uuid = '$node_1_gcomm_uuid' AS wsrep_gcomm_uuid_match FROM mysql.wsrep_streaming_log;
--enable_query_log

--connection node_3
--error ER_LOCK_DEADLOCK
COMMIT;
SELECT COUNT(DISTINCT node_uuid) = 1 FROM mysql.wsrep_streaming_log;
--disable_query_log
--eval SELECT DISTINCT node_uuid = '$node_1_gcomm_uuid' AS wsrep_gcomm_uuid_match FROM mysql.wsrep_streaming_log;
--enable_query_log

#
# Finalize transaction on node #1
#

--connection node_1
INSERT INTO t1 VALUES (30);
INSERT INTO t1 VALUES (31);
INSERT INTO t1 VALUES (32);
INSERT INTO t1 VALUES (33);
INSERT INTO t1 VALUES (34);
COMMIT;

#
# Confirm that transaction is replicated correctly and SR tables are empty at the end of the test
#

SELECT COUNT(*) = 15, MIN(f1) = 10, MAX(f1) = 34 FROM t1;
SELECT COUNT(*) = 0 FROM mysql.wsrep_streaming_log;
SET AUTOCOMMIT=ON;

--connection node_2
COMMIT;
SELECT COUNT(*) = 15, MIN(f1) = 10, MAX(f1) = 34 FROM t1;
SELECT COUNT(*) = 0 FROM mysql.wsrep_streaming_log;
SET AUTOCOMMIT=ON;

--connection node_3
COMMIT;
SELECT COUNT(*) = 15, MIN(f1) = 10, MAX(f1) = 34 FROM t1;
SELECT COUNT(*) = 0 FROM mysql.wsrep_streaming_log;
SET AUTOCOMMIT=ON;

DROP TABLE t1;

--connection node_1
CALL mtr.add_suppression("WSREP: failed to send SR rollback for ");
--connection node_2
CALL mtr.add_suppression("WSREP: failed to send SR rollback for ");
--connection node_3
CALL mtr.add_suppression("WSREP: failed to send SR rollback for ");

--source ../galera/include/auto_increment_offset_restore.inc