| 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_3nodes_as_slave.cnf describes the setup of the nodes |
| 6 |
# |
| 7 |
|
| 8 |
--source include/have_innodb.inc |
| 9 |
--source include/big_test.inc |
| 10 |
--source include/galera_cluster.inc |
| 11 |
|
| 12 |
# Step #1. Establish replication |
| 13 |
# |
| 14 |
# As node 4 is not a Galera node, and galera_cluster.inc does not open connetion to it |
| 15 |
# we open the node_4 connection here |
| 16 |
--connect node_4, 127.0.0.1, root, , test, $NODE_MYPORT_4 |
| 17 |
|
| 18 |
--connection node_2 |
| 19 |
--disable_query_log |
| 20 |
--eval CHANGE MASTER TO MASTER_HOST='127.0.0.1', MASTER_USER='root', MASTER_SSL_VERIFY_SERVER_CERT=0, MASTER_PORT=$NODE_MYPORT_4; |
| 21 |
--enable_query_log |
| 22 |
START SLAVE; |
| 23 |
|
| 24 |
SET SESSION wsrep_sync_wait = 0; |
| 25 |
|
| 26 |
--connection node_4 |
| 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 |
--connection node_1 |
| 38 |
--source include/wait_until_connected_again.inc |
| 39 |
--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' |
| 40 |
--source include/wait_condition.inc |
| 41 |
|
| 42 |
# Step #3. Force async replication to fail by creating a replication event while the slave is non-prim |
| 43 |
|
| 44 |
--connection node_4 |
| 45 |
INSERT INTO t1 VALUES (1),(2),(3),(4),(5); |
| 46 |
|
| 47 |
--connection node_2 |
| 48 |
wait_for_slave_to_stop; |
| 49 |
--let $value = query_get_value(SHOW SLAVE STATUS, Last_SQL_Error, 1) |
| 50 |
--disable_query_log |
| 51 |
--eval SELECT "$value" IN ("Error 'Unknown command' on query. Default database: 'test'. Query: 'BEGIN'", "Node has dropped from cluster") AS expected_error |
| 52 |
--enable_query_log |
| 53 |
|
| 54 |
# Step #4. Bring back the async slave and restart replication |
| 55 |
--connection node_2 |
| 56 |
SET GLOBAL wsrep_provider_options = 'gmcast.isolate=0'; |
| 57 |
|
| 58 |
--connection node_1 |
| 59 |
--source include/wait_until_connected_again.inc |
| 60 |
--let $wait_condition = SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' |
| 61 |
--source include/wait_condition.inc |
| 62 |
|
| 63 |
--connection node_2 |
| 64 |
--source include/wait_until_ready.inc |
| 65 |
--source include/wait_until_connected_again.inc |
| 66 |
|
| 67 |
START SLAVE; |
| 68 |
|
| 69 |
# Confirm that the replication events have arrived |
| 70 |
|
| 71 |
--let $wait_condition = SELECT COUNT(*) = 5 FROM t1; |
| 72 |
--source include/wait_condition.inc |
| 73 |
|
| 74 |
--connection node_4 |
| 75 |
DROP TABLE t1; |
| 76 |
|
| 77 |
--connection node_2 |
| 78 |
--let $wait_condition = SELECT COUNT(*) = 0 FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 't1'; |
| 79 |
--source include/wait_condition.inc |
| 80 |
|
| 81 |
STOP SLAVE; |
| 82 |
RESET SLAVE ALL; |
| 83 |
|
| 84 |
CALL mtr.add_suppression("Slave SQL: Error 'Unknown command' on query"); |
| 85 |
CALL mtr.add_suppression("Slave: Unknown command Error_code: 1047"); |
| 86 |
CALL mtr.add_suppression("(Transport endpoint|Socket) is not connected"); |
| 87 |
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"); |
| 88 |
CALL mtr.add_suppression("Slave SQL: Node has dropped from cluster, Error_code: 1047"); |
| 89 |
|
| 90 |
--connection node_4 |
| 91 |
RESET MASTER; |