Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Galera MTR Tests: a test for async slave + non-prim
- Loading branch information
1 parent
a566bcf
commit 8c328d2
Showing
4 changed files
with
208 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
# | ||
# This .cnf file creates a setup with 1 standard MySQL server, followed by a 2-node Galera cluster | ||
# | ||
|
||
# Use default setting for mysqld processes | ||
!include include/default_mysqld.cnf | ||
|
||
[mysqld] | ||
log-slave-updates | ||
log-bin=mysqld-bin | ||
binlog-format=row | ||
|
||
[mysqld.1] | ||
server-id=1 | ||
|
||
[mysqld.2] | ||
server-id=2 | ||
|
||
wsrep_provider=@ENV.WSREP_PROVIDER | ||
wsrep_cluster_address='gcomm://' | ||
wsrep_provider_options='base_port=@mysqld.2.#galera_port;evs.install_timeout = PT15S; evs.max_install_timeouts=1;' | ||
|
||
# enforce read-committed characteristics across the cluster | ||
wsrep_causal_reads=ON | ||
wsrep_sync_wait = 7 | ||
|
||
wsrep_node_address=127.0.0.1 | ||
wsrep_sst_receive_address=127.0.0.2:@mysqld.2.#sst_port | ||
wsrep_node_incoming_address=127.0.0.1:@mysqld.2.port | ||
|
||
# Required for Galera | ||
innodb_autoinc_lock_mode=2 | ||
|
||
innodb_flush_log_at_trx_commit=2 | ||
|
||
[mysqld.3] | ||
wsrep_provider=@ENV.WSREP_PROVIDER | ||
wsrep_cluster_address='gcomm://127.0.0.1:@mysqld.2.#galera_port' | ||
wsrep_provider_options='base_port=@mysqld.3.#galera_port;evs.install_timeout = PT15S; evs.max_install_timeouts = 1;' | ||
|
||
# enforce read-committed characteristics across the cluster | ||
wsrep_causal_reads=ON | ||
wsrep_sync_wait = 7 | ||
|
||
wsrep_node_address=127.0.0.1 | ||
wsrep_sst_receive_address=127.0.0.2:@mysqld.3.#sst_port | ||
wsrep_node_incoming_address=127.0.0.1:@mysqld.3.port | ||
|
||
# Required for Galera | ||
innodb_autoinc_lock_mode=2 | ||
|
||
innodb_flush_log_at_trx_commit=2 | ||
|
||
[mysqld.4] | ||
wsrep_provider=@ENV.WSREP_PROVIDER | ||
wsrep_cluster_address='gcomm://127.0.0.1:@mysqld.2.#galera_port' | ||
wsrep_provider_options='base_port=@mysqld.4.#galera_port;evs.install_timeout = PT15S; evs.max_install_timeouts = 1;' | ||
|
||
# enforce read-committed characteristics across the cluster | ||
wsrep_causal_reads=ON | ||
wsrep_sync_wait = 7 | ||
|
||
wsrep_node_address=192.168.95.128 | ||
wsrep_sst_receive_address=192.168.95.128:@mysqld.4.#sst_port | ||
wsrep_node_incoming_address=192.168.95.128:@mysqld.4.port | ||
|
||
# Required for Galera | ||
innodb_autoinc_lock_mode=2 | ||
|
||
innodb_flush_log_at_trx_commit=2 | ||
|
||
[ENV] | ||
NODE_MYPORT_1= @mysqld.1.port | ||
NODE_MYSOCK_1= @mysqld.1.socket | ||
|
||
NODE_MYPORT_2= @mysqld.2.port | ||
NODE_MYSOCK_2= @mysqld.2.socket | ||
|
||
NODE_MYPORT_3= @mysqld.3.port | ||
NODE_MYSOCK_3= @mysqld.3.socket | ||
|
||
NODE_MYPORT_3= @mysqld.4.port | ||
NODE_MYSOCK_3= @mysqld.4.socket | ||
|
||
NODE_GALERAPORT_2= @mysqld.2.#galera_port | ||
NODE_GALERAPORT_3= @mysqld.3.#galera_port | ||
NODE_GALERAPORT_4= @mysqld.4.#galera_port | ||
|
||
NODE_SSTPORT_2= @mysqld.2.#sst_port | ||
NODE_SSTPORT_3= @mysqld.3.#sst_port | ||
NODE_SSTPORT_4= @mysqld.4.#sst_port |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
START SLAVE USER='root'; | ||
Warnings: | ||
Note 1759 Sending passwords in plain text without SSL/TLS is extremely insecure. | ||
SET SESSION wsrep_sync_wait = 0; | ||
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; | ||
SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1'; | ||
INSERT INTO t1 VALUES (1),(2),(3),(4),(5); | ||
expected_error | ||
1 | ||
SET GLOBAL wsrep_provider_options = 'gmcast.isolate=0'; | ||
START SLAVE; | ||
DROP TABLE t1; | ||
STOP SLAVE; | ||
RESET SLAVE ALL; | ||
CALL mtr.add_suppression("Slave SQL: Error 'Unknown command' on query"); | ||
CALL mtr.add_suppression("Slave: Unknown command Error_code: 1047"); | ||
CALL mtr.add_suppression("Send action {\\(nil\\), 328, TORDERED} returned -107 \\(Transport endpoint is not connected\\)"); | ||
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"); | ||
CALL mtr.add_suppression("Slave SQL: Node has dropped from cluster, Error_code: 1047"); | ||
RESET MASTER; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
!include ../galera_3nodes_as_slave.cnf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
# | ||
# Test the behavior of a Galera async slave if it goes non-prim. Async replication | ||
# should abort with an error but it should be possible to restart it. | ||
# | ||
# The galera/galera_2node_slave.cnf describes the setup of the nodes | ||
# | ||
|
||
--source include/have_innodb.inc | ||
--source include/have_log_bin.inc | ||
--source include/big_test.inc | ||
|
||
# Step #1. Establish replication | ||
# | ||
# As node #1 is not a Galera node, we connect to node #2 in order to run include/galera_cluster.inc | ||
# | ||
--connect node_2a, 127.0.0.1, root, , test, $NODE_MYPORT_2 | ||
--source include/galera_cluster.inc | ||
|
||
--connection node_2 | ||
--disable_query_log | ||
--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_PORT=$NODE_MYPORT_1; | ||
--enable_query_log | ||
START SLAVE USER='root'; | ||
SET SESSION wsrep_sync_wait = 0; | ||
|
||
--connection node_1 | ||
CREATE TABLE t1 (f1 INTEGER PRIMARY KEY) ENGINE=InnoDB; | ||
|
||
--connection node_2 | ||
--let $wait_condition = SELECT COUNT(*) = 1 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; | ||
--source include/wait_condition.inc | ||
|
||
# Step #2. Force async slave to go non-primary | ||
|
||
SET GLOBAL wsrep_provider_options = 'gmcast.isolate=1'; | ||
|
||
--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 | ||
--connection node_3 | ||
--source include/wait_until_connected_again.inc | ||
--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' | ||
--source include/wait_condition.inc | ||
|
||
# Step #3. Force async replication to fail by creating a replication event while the slave is non-prim | ||
|
||
--connection node_1 | ||
INSERT INTO t1 VALUES (1),(2),(3),(4),(5); | ||
|
||
--connection node_2 | ||
--sleep 5 | ||
|
||
--let $value = query_get_value(SHOW SLAVE STATUS, Last_SQL_Error, 1) | ||
--connection node_3 | ||
--disable_query_log | ||
--eval SELECT "$value" IN ("Error 'Unknown command' on query. Default database: 'test'. Query: 'BEGIN'", "Node has dropped from cluster") AS expected_error | ||
--enable_query_log | ||
|
||
# Step #4. Bring back the async slave and restart replication | ||
--connection node_2 | ||
SET GLOBAL wsrep_provider_options = 'gmcast.isolate=0'; | ||
|
||
--connection node_3 | ||
--source include/wait_until_connected_again.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 | ||
--source include/galera_wait_ready.inc | ||
--source include/wait_until_connected_again.inc | ||
|
||
START SLAVE; | ||
|
||
# Confirm that the replication events have arrived | ||
|
||
--let $wait_condition = SELECT COUNT(*) = 5 FROM t1; | ||
--source include/wait_condition.inc | ||
|
||
--connection node_1 | ||
DROP TABLE t1; | ||
|
||
--sleep 2 | ||
--connection node_2 | ||
--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; | ||
--source include/wait_condition.inc | ||
|
||
STOP SLAVE; | ||
RESET SLAVE ALL; | ||
|
||
CALL mtr.add_suppression("Slave SQL: Error 'Unknown command' on query"); | ||
CALL mtr.add_suppression("Slave: Unknown command Error_code: 1047"); | ||
CALL mtr.add_suppression("Send action {\\(nil\\), 328, TORDERED} returned -107 \\(Transport endpoint is not connected\\)"); | ||
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"); | ||
CALL mtr.add_suppression("Slave SQL: Node has dropped from cluster, Error_code: 1047"); | ||
|
||
|
||
--connection node_1 | ||
RESET MASTER; |