|
| 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