Skip to content

Commit b3ec0a8

Browse files
philip-galeraNirbhay Choubey
authored andcommitted
Galera MTR Tests: a test for async slave + non-prim
1 parent db66d2f commit b3ec0a8

File tree

4 files changed

+208
-0
lines changed

4 files changed

+208
-0
lines changed
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
#
2+
# This .cnf file creates a setup with 1 standard MySQL server, followed by a 2-node Galera cluster
3+
#
4+
5+
# Use default setting for mysqld processes
6+
!include include/default_mysqld.cnf
7+
8+
[mysqld]
9+
log-slave-updates
10+
log-bin=mysqld-bin
11+
binlog-format=row
12+
13+
[mysqld.1]
14+
server-id=1
15+
16+
[mysqld.2]
17+
server-id=2
18+
19+
wsrep_provider=@ENV.WSREP_PROVIDER
20+
wsrep_cluster_address='gcomm://'
21+
wsrep_provider_options='base_port=@mysqld.2.#galera_port;evs.install_timeout = PT15S; evs.max_install_timeouts=1;'
22+
23+
# enforce read-committed characteristics across the cluster
24+
wsrep_causal_reads=ON
25+
wsrep_sync_wait = 7
26+
27+
wsrep_node_address=127.0.0.1
28+
wsrep_sst_receive_address=127.0.0.2:@mysqld.2.#sst_port
29+
wsrep_node_incoming_address=127.0.0.1:@mysqld.2.port
30+
31+
# Required for Galera
32+
innodb_autoinc_lock_mode=2
33+
34+
innodb_flush_log_at_trx_commit=2
35+
36+
[mysqld.3]
37+
wsrep_provider=@ENV.WSREP_PROVIDER
38+
wsrep_cluster_address='gcomm://127.0.0.1:@mysqld.2.#galera_port'
39+
wsrep_provider_options='base_port=@mysqld.3.#galera_port;evs.install_timeout = PT15S; evs.max_install_timeouts = 1;'
40+
41+
# enforce read-committed characteristics across the cluster
42+
wsrep_causal_reads=ON
43+
wsrep_sync_wait = 7
44+
45+
wsrep_node_address=127.0.0.1
46+
wsrep_sst_receive_address=127.0.0.2:@mysqld.3.#sst_port
47+
wsrep_node_incoming_address=127.0.0.1:@mysqld.3.port
48+
49+
# Required for Galera
50+
innodb_autoinc_lock_mode=2
51+
52+
innodb_flush_log_at_trx_commit=2
53+
54+
[mysqld.4]
55+
wsrep_provider=@ENV.WSREP_PROVIDER
56+
wsrep_cluster_address='gcomm://127.0.0.1:@mysqld.2.#galera_port'
57+
wsrep_provider_options='base_port=@mysqld.4.#galera_port;evs.install_timeout = PT15S; evs.max_install_timeouts = 1;'
58+
59+
# enforce read-committed characteristics across the cluster
60+
wsrep_causal_reads=ON
61+
wsrep_sync_wait = 7
62+
63+
wsrep_node_address=192.168.95.128
64+
wsrep_sst_receive_address=192.168.95.128:@mysqld.4.#sst_port
65+
wsrep_node_incoming_address=192.168.95.128:@mysqld.4.port
66+
67+
# Required for Galera
68+
innodb_autoinc_lock_mode=2
69+
70+
innodb_flush_log_at_trx_commit=2
71+
72+
[ENV]
73+
NODE_MYPORT_1= @mysqld.1.port
74+
NODE_MYSOCK_1= @mysqld.1.socket
75+
76+
NODE_MYPORT_2= @mysqld.2.port
77+
NODE_MYSOCK_2= @mysqld.2.socket
78+
79+
NODE_MYPORT_3= @mysqld.3.port
80+
NODE_MYSOCK_3= @mysqld.3.socket
81+
82+
NODE_MYPORT_3= @mysqld.4.port
83+
NODE_MYSOCK_3= @mysqld.4.socket
84+
85+
NODE_GALERAPORT_2= @mysqld.2.#galera_port
86+
NODE_GALERAPORT_3= @mysqld.3.#galera_port
87+
NODE_GALERAPORT_4= @mysqld.4.#galera_port
88+
89+
NODE_SSTPORT_2= @mysqld.2.#sst_port
90+
NODE_SSTPORT_3= @mysqld.3.#sst_port
91+
NODE_SSTPORT_4= @mysqld.4.#sst_port
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
START SLAVE USER='root';
2+
Warnings:
3+
Note 1759 Sending passwords in plain text without SSL/TLS is extremely insecure.
4+
SET SESSION wsrep_sync_wait = 0;
5+
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
6+
SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1';
7+
INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
8+
expected_error
9+
1
10+
SET GLOBAL wsrep_provider_options = 'gmcast.isolate=0';
11+
START SLAVE;
12+
DROP TABLE t1;
13+
STOP SLAVE;
14+
RESET SLAVE ALL;
15+
CALL mtr.add_suppression("Slave SQL: Error 'Unknown command' on query");
16+
CALL mtr.add_suppression("Slave: Unknown command Error_code: 1047");
17+
CALL mtr.add_suppression("Send action {\\(nil\\), 328, TORDERED} returned -107 \\(Transport endpoint is not connected\\)");
18+
CALL mtr.add_suppression("Slave SQL: Error in Xid_log_event: Commit could not be completed, 'Deadlock found when trying to get lock; try restarting transaction', Error_code: 1213");
19+
CALL mtr.add_suppression("Slave SQL: Node has dropped from cluster, Error_code: 1047");
20+
RESET MASTER;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
!include ../galera_3nodes_as_slave.cnf
Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
#
2+
# Test the behavior of a Galera async slave if it goes non-prim. Async replication
3+
# should abort with an error but it should be possible to restart it.
4+
#
5+
# The galera/galera_2node_slave.cnf describes the setup of the nodes
6+
#
7+
8+
--source include/have_innodb.inc
9+
--source include/have_log_bin.inc
10+
--source include/big_test.inc
11+
12+
# Step #1. Establish replication
13+
#
14+
# As node #1 is not a Galera node, we connect to node #2 in order to run include/galera_cluster.inc
15+
#
16+
--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2
17+
--source include/galera_cluster.inc
18+
19+
--connection node_2
20+
--disable_query_log
21+
--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$NODE_MYPORT_1;
22+
--enable_query_log
23+
START SLAVE USER='root';
24+
SET SESSION wsrep_sync_wait = 0;
25+
26+
--connection node_1
27+
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB;
28+
29+
--connection node_2
30+
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
31+
--source include/wait_condition.inc
32+
33+
# Step #2. Force async slave to go non-primary
34+
35+
SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1';
36+
37+
--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3
38+
--connection node_3
39+
--source include/wait_until_connected_again.inc
40+
--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
41+
--source include/wait_condition.inc
42+
43+
# Step #3. Force async replication to fail by creating a replication event while the slave is non-prim
44+
45+
--connection node_1
46+
INSERT INTO t1 VALUES (1),(2),(3),(4),(5);
47+
48+
--connection node_2
49+
--sleep 5
50+
51+
--let $value = query_get_value(SHOW SLAVE STATUS, Last_SQL_Error, 1)
52+
--connection node_3
53+
--disable_query_log
54+
--eval SELECT "$value" IN ("Error 'Unknown command' on query. Default database: 'test'. Query: 'BEGIN'", "Node has dropped from cluster") AS expected_error
55+
--enable_query_log
56+
57+
# Step #4. Bring back the async slave and restart replication
58+
--connection node_2
59+
SET GLOBAL wsrep_provider_options = 'gmcast.isolate=0';
60+
61+
--connection node_3
62+
--source include/wait_until_connected_again.inc
63+
--let $wait_condition = SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'
64+
--source include/wait_condition.inc
65+
66+
--connection node_2
67+
--source include/galera_wait_ready.inc
68+
--source include/wait_until_connected_again.inc
69+
70+
START SLAVE;
71+
72+
# Confirm that the replication events have arrived
73+
74+
--let $wait_condition = SELECT COUNT(*) = 5 FROM t1;
75+
--source include/wait_condition.inc
76+
77+
--connection node_1
78+
DROP TABLE t1;
79+
80+
--sleep 2
81+
--connection node_2
82+
--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1';
83+
--source include/wait_condition.inc
84+
85+
STOP SLAVE;
86+
RESET SLAVE ALL;
87+
88+
CALL mtr.add_suppression("Slave SQL: Error 'Unknown command' on query");
89+
CALL mtr.add_suppression("Slave: Unknown command Error_code: 1047");
90+
CALL mtr.add_suppression("Send action {\\(nil\\), 328, TORDERED} returned -107 \\(Transport endpoint is not connected\\)");
91+
CALL mtr.add_suppression("Slave SQL: Error in Xid_log_event: Commit could not be completed, 'Deadlock found when trying to get lock; try restarting transaction', Error_code: 1213");
92+
CALL mtr.add_suppression("Slave SQL: Node has dropped from cluster, Error_code: 1047");
93+
94+
95+
--connection node_1
96+
RESET MASTER;

0 commit comments

Comments
 (0)