| 1 |
# |
| 2 |
# Test the pc.recovery=1 option. Killing all nodes simultaneously and |
| 3 |
# restarting them should succeed and the cluster should re-form. |
| 4 |
# |
| 5 |
|
| 6 |
--source include/have_innodb.inc |
| 7 |
--source include/galera_cluster.inc |
| 8 |
--source include/big_test.inc |
| 9 |
|
| 10 |
# Save galera ports |
| 11 |
--connection node_1 |
| 12 |
--source suite/galera/include/galera_base_port.inc |
| 13 |
--let $NODE_GALERAPORT_1 = $_NODE_GALERAPORT |
| 14 |
|
| 15 |
--connection node_2 |
| 16 |
--source suite/galera/include/galera_base_port.inc |
| 17 |
--let $NODE_GALERAPORT_2 = $_NODE_GALERAPORT |
| 18 |
|
| 19 |
--connection node_1 |
| 20 |
CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; |
| 21 |
INSERT INTO t1 VALUES (1); |
| 22 |
|
| 23 |
# Instruct MTR to not restart the nodes automatically when they are killed |
| 24 |
|
| 25 |
--let $NODE_1_PIDFILE = `SELECT @@pid_file` |
| 26 |
--connection node_2 |
| 27 |
SELECT COUNT(*) = 1 FROM t1; |
| 28 |
--let $NODE_2_PIDFILE = `SELECT @@pid_file` |
| 29 |
|
| 30 |
--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 31 |
--write_line wait $MYSQLTEST_VARDIR/tmp/mysqld.2.expect |
| 32 |
--exec kill -9 `cat $NODE_1_PIDFILE` `cat $NODE_2_PIDFILE` |
| 33 |
|
| 34 |
# Perform --wsrep-recover and preserve the positions into variables by placing them in $MYSQL_TMP_DIR/galera_wsrep_start_position.inc and then --source'ing it |
| 35 |
|
| 36 |
--exec $MYSQLD --defaults-group-suffix=.1 --defaults-file=$MYSQLTEST_VARDIR/my.cnf --wsrep-recover --loose-innodb --log-error=$MYSQL_TMP_DIR/galera_wsrep_recover.1.log > $MYSQL_TMP_DIR/galera_wsrep_recover.1.log 2>&1 |
| 37 |
--exec $MYSQLD --defaults-group-suffix=.2 --defaults-file=$MYSQLTEST_VARDIR/my.cnf --wsrep-recover --loose-innodb --log-error=$MYSQL_TMP_DIR/galera_wsrep_recover.2.log > $MYSQL_TMP_DIR/galera_wsrep_recover.2.log 2>&1 |
| 38 |
|
| 39 |
--perl |
| 40 |
use strict; |
| 41 |
my $wsrep_start_position1 = `grep -a 'WSREP: Recovered position:' $ENV{MYSQL_TMP_DIR}/galera_wsrep_recover.1.log | sed 's/.*WSREP\:\ Recovered\ position://' | sed 's/^[ \t]*//'`; |
| 42 |
chomp($wsrep_start_position1); |
| 43 |
|
| 44 |
my $wsrep_start_position2 = `grep -a 'WSREP: Recovered position:' $ENV{MYSQL_TMP_DIR}/galera_wsrep_recover.2.log | sed 's/.*WSREP\:\ Recovered\ position://' | sed 's/^[ \t]*//'`; |
| 45 |
chomp($wsrep_start_position2); |
| 46 |
|
| 47 |
die if $wsrep_start_position1 eq '' || $wsrep_start_position2 eq ''; |
| 48 |
|
| 49 |
open(FILE, ">", "$ENV{MYSQL_TMP_DIR}/galera_wsrep_start_position.inc") or die; |
| 50 |
print FILE "--let \$galera_wsrep_start_position1 = $wsrep_start_position1\n"; |
| 51 |
print FILE "--let \$galera_wsrep_start_position2 = $wsrep_start_position2\n"; |
| 52 |
close FILE; |
| 53 |
EOF |
| 54 |
|
| 55 |
--source $MYSQL_TMP_DIR/galera_wsrep_start_position.inc |
| 56 |
|
| 57 |
if ($galera_wsrep_start_position1 == '') { |
| 58 |
--die "Could not obtain wsrep_start_position." |
| 59 |
} |
| 60 |
|
| 61 |
if ($galera_wsrep_start_position2 == '') { |
| 62 |
--die "Could not obtain wsrep_start_position." |
| 63 |
} |
| 64 |
|
| 65 |
--remove_file $MYSQL_TMP_DIR/galera_wsrep_start_position.inc |
| 66 |
|
| 67 |
# Instruct MTR to perform the actual restart using --wsrep-start-position . Proper --wsrep_cluster_address is used as my.cnf only contains 'gcomm://' for node #1 |
| 68 |
|
| 69 |
--write_line "restart: --wsrep-start-position=$galera_wsrep_start_position1 --wsrep_cluster_address=gcomm://127.0.0.1:$NODE_GALERAPORT_1,127.0.0.1:$NODE_GALERAPORT_2" $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 70 |
--write_line "restart: --wsrep-start-position=$galera_wsrep_start_position2 --wsrep_cluster_address=gcomm://127.0.0.1:$NODE_GALERAPORT_1,127.0.0.1:$NODE_GALERAPORT_2" $MYSQLTEST_VARDIR/tmp/mysqld.2.expect |
| 71 |
|
| 72 |
--sleep 5 |
| 73 |
--connection node_1 |
| 74 |
--enable_reconnect |
| 75 |
--source include/wait_until_connected_again.inc |
| 76 |
|
| 77 |
# Confirm that the cluster has re-formed and data is present |
| 78 |
|
| 79 |
--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size' |
| 80 |
--source include/wait_condition.inc |
| 81 |
|
| 82 |
SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; |
| 83 |
SELECT COUNT(*) = 1 FROM t1; |
| 84 |
|
| 85 |
--connection node_2 |
| 86 |
--enable_reconnect |
| 87 |
--source include/wait_until_connected_again.inc |
| 88 |
SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; |
| 89 |
SELECT VARIABLE_VALUE = 'Primary' FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_status'; |
| 90 |
SELECT COUNT(*) = 1 FROM t1; |
| 91 |
|
| 92 |
DROP TABLE t1; |
| 93 |
|
| 94 |
--connection node_1 |
| 95 |
CALL mtr.add_suppression("points to own listening address, blacklisting"); |
| 96 |
CALL mtr.add_suppression("non weight changing install in S_PRIM"); |
| 97 |
CALL mtr.add_suppression("No re-merged primary component found"); |
| 98 |
|
| 99 |
--connection node_2 |
| 100 |
CALL mtr.add_suppression("points to own listening address, blacklisting"); |
| 101 |
CALL mtr.add_suppression("non weight changing install in S_PRIM"); |
| 102 |
CALL mtr.add_suppression("No re-merged primary component found"); |