summaryrefslogtreecommitdiffstats
path: root/mysql-test/suite/galera_3nodes/t/galera_pc_bootstrap.test
blob: 58a67c7b32b3c1e415c63905ecb022073d8cd2ba (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
#
# Test the operation of pc.bootstrap 
#
--source include/big_test.inc
--source include/galera_cluster.inc
--source include/have_innodb.inc

call mtr.add_suppression("WSREP: gcs/src/gcs_core.cpp:core_handle_uuid_msg\\(\\).*");

#
# 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);

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

# Force all nodes to become non-primary

SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1';

--connection node_2
SET SESSION wsrep_sync_wait=0;
--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
--source include/wait_condition.inc

SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1';

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

SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1';

# Node #3 should be non-primary
--let $wait_condition = SELECT variable_value = 'non-Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE variable_name = 'wsrep_cluster_status';
--source include/wait_condition.inc

--connection node_2
# Node #2 should be non-primary
--let $wait_condition = SELECT variable_value = 'non-Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE variable_name = 'wsrep_cluster_status';
--source include/wait_condition.inc

# Signal node #2 to bootstrap
SET GLOBAL wsrep_provider_options = 'pc.bootstrap=1';

# Wait until node becomes available for queries again
--source include/wait_until_connected_again.inc

# Node #2 should now be a primary of a 1-node cluster

SHOW STATUS LIKE 'wsrep_cluster_size';
SHOW STATUS LIKE 'wsrep_cluster_status';

# Perform an insert on node #2
INSERT INTO t1 VALUES (1);

# Reconnect all nodes 
--connection node_2
SET GLOBAL wsrep_provider_options = 'gmcast.isolate=0';

--source include/wait_until_connected_again.inc
--let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status';
--source include/wait_condition.inc
--let $wait_condition = SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment';
--source include/wait_condition.inc
--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
--source include/wait_condition.inc


--connection node_1
SET GLOBAL wsrep_provider_options = 'gmcast.isolate=0';
--source include/wait_until_connected_again.inc
--let $wait_condition = SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status';
--source include/wait_condition.inc
--let $wait_condition = SELECT VARIABLE_VALUE = 'Synced' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_local_state_comment';
--source include/wait_condition.inc
--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size';
--source include/wait_condition.inc


--connection node_3
SET GLOBAL wsrep_provider_options = 'gmcast.isolate=0';

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

# Check that all nodes have the same view of the database

--connection node_1
SELECT COUNT(*) FROM t1;

--connection node_2
SELECT COUNT(*) FROM t1;

--connection node_3
SELECT COUNT(*) FROM t1;

# Test cleanup
DROP TABLE t1;

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