summaryrefslogtreecommitdiff
path: root/mysql-test/suite/galera_3nodes/t/galera_safe_to_bootstrap.test
blob: 053c0bd8ce97b0d8954ad54c96a5dd7f7c249460 (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
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
#
# Test the safe_to_bootstrap in grastate.dat 
#
--source include/galera_cluster.inc

#
# Create connection node_3 and save auto increment variables.
#
--let $galera_connection_name = node_3
--let $galera_server_number = 3
--source include/galera_connect.inc

--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) ENGINE=InnoDB;

#
# At start, all grastate.dat files have safe_to_boostrap: 0
#

--let $assert_text= grastate.dat does not have 'safe_to_bootstrap: 0'
--let $assert_select= safe_to_bootstrap: 0
--let $assert_count= 1

--let $assert_file= $MYSQLTEST_VARDIR/mysqld.1/data/grastate.dat
--source include/assert_grep.inc

--let $assert_file= $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat
--source include/assert_grep.inc

--let $assert_file= $MYSQLTEST_VARDIR/mysqld.3/data/grastate.dat
--source include/assert_grep.inc

#
# Shut down one node
#

--connection node_2
--source include/shutdown_mysqld.inc

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

# Still, all grastate.dat files should have safe_to_boostrap: 0

--let $assert_file= $MYSQLTEST_VARDIR/mysqld.1/data/grastate.dat
--source include/assert_grep.inc

--let $assert_file= $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat
--source include/assert_grep.inc

--let $assert_file= $MYSQLTEST_VARDIR/mysqld.3/data/grastate.dat
--source include/assert_grep.inc

#
# Shut down one more node
#

--connection node_3
--source include/shutdown_mysqld.inc

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

# Now, nodes 2,3 should have safe_to_boostrap: 0

--let $assert_file= $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat
--source include/assert_grep.inc

--let $assert_file= $MYSQLTEST_VARDIR/mysqld.3/data/grastate.dat
--source include/assert_grep.inc

# But node #1 should have safe_to_boostrap: 1

--let $assert_text= grastate.dat does not have 'safe_to_bootstrap: 1'
--let $assert_select= safe_to_bootstrap: 1

--let $assert_file= $MYSQLTEST_VARDIR/mysqld.1/data/grastate.dat
--source include/assert_grep.inc

# Restart one node

--connection node_2
--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
--source include/start_mysqld.inc

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

# All nodes should be back to 'safe_to_bootstrap: 0'

--let $assert_text= grastate.dat does not have 'safe_to_bootstrap: 0'
--let $assert_select= safe_to_bootstrap: 0

--let $assert_file= $MYSQLTEST_VARDIR/mysqld.1/data/grastate.dat
--source include/assert_grep.inc

--let $assert_file= $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat
--source include/assert_grep.inc

--let $assert_file= $MYSQLTEST_VARDIR/mysqld.3/data/grastate.dat
--source include/assert_grep.inc

#
# Kill the cluster
#

--connection node_2
--source include/shutdown_mysqld.inc

--connection node_1
SET SESSION wsrep_on = OFF;
--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
--source include/wait_condition.inc

--source ../galera/include/kill_galera.inc

#
# Only node #1 should have safe_to_bootstrap: 1
# include/assert_grep.inc requires a running server, so we revert to simple grep
#

--error 0
--exec grep 'safe_to_bootstrap: 1' $MYSQLTEST_VARDIR/mysqld.1/data/grastate.dat

--error 0
--exec grep 'safe_to_bootstrap: 0' $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat

--error 0
--exec grep 'safe_to_bootstrap: 0' $MYSQLTEST_VARDIR/mysqld.3/data/grastate.dat

#
# Attempt to bootstrap nodes #2, #3, should fail 
#

--error 1
--exec $MYSQLD --defaults-group-suffix=.2 --defaults-file=$MYSQLTEST_VARDIR/my.cnf --wsrep-new-cluster --wsrep-cluster-address='gcomm://' | grep 'This node is not safe to bootstrap the cluster'
--error 1
--exec $MYSQLD --defaults-group-suffix=.3 --defaults-file=$MYSQLTEST_VARDIR/my.cnf --wsrep-new-cluster --wsrep-cluster-address='gcomm://' | grep 'This node is not safe to bootstrap the cluster'

#
# Attempt to bootstrap starting from node #1, should succeed
#

--connection node_1
--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect
--source include/start_mysqld.inc
--source include/wait_until_connected_again.inc

--connection node_2
--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.2.expect
--source include/start_mysqld.inc

--connection node_3
--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.3.expect
--source include/start_mysqld.inc

--let $wait_condition = SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
--source include/wait_condition.inc

--connection node_2
CALL mtr.add_suppression("WSREP: no nodes coming from prim view, prim not possible");
CALL mtr.add_suppression("WSREP: It may not be safe to bootstrap the cluster from this node");
CALL mtr.add_suppression("WSREP: wsrep::connect(.*) failed: 7");
CALL mtr.add_suppression("Aborting");
CALL mtr.add_suppression("WSREP: moving position backwards: [0-9]+ -> 0");
CALL mtr.add_suppression("Failed to prepare for incremental state transfer");
CALL mtr.add_suppression("It may not be safe to bootstrap the cluster from this node");
CALL mtr.add_suppression("Aborting");

--connection node_3
CALL mtr.add_suppression("WSREP: no nodes coming from prim view, prim not possible");
CALL mtr.add_suppression("WSREP: It may not be safe to bootstrap the cluster from this node");
CALL mtr.add_suppression("WSREP: wsrep::connect(.*) failed: 7");
CALL mtr.add_suppression("Aborting");
CALL mtr.add_suppression("WSREP: moving position backwards: [0-9]+ -> 0");
CALL mtr.add_suppression("Failed to prepare for incremental state transfer");
CALL mtr.add_suppression("It may not be safe to bootstrap the cluster from this node");
CALL mtr.add_suppression("Aborting");
SHOW CREATE TABLE t1;

DROP TABLE t1;

#
# Restore auto increment variables.
#
--source ../galera/include/auto_increment_offset_restore.inc