|
| 1 | +# |
| 2 | +# Test the safe_to_bootstrap in grastate.dat |
| 3 | +# |
| 4 | + |
| 5 | +--source include/galera_cluster.inc |
| 6 | +--source include/have_innodb.inc |
| 7 | +CREATE TABLE t1 (f1 INTEGER) ENGINE=InnoDB; |
| 8 | + |
| 9 | +# |
| 10 | +# At start, all grastate.dat files have safe_to_boostrap: 0 |
| 11 | +# |
| 12 | + |
| 13 | +--let $assert_text= grastate.dat does not have 'safe_to_bootstrap: 0' |
| 14 | +--let $assert_select= safe_to_bootstrap: 0 |
| 15 | +--let $assert_count= 1 |
| 16 | + |
| 17 | +--let $assert_file= $MYSQLTEST_VARDIR/mysqld.1/data/grastate.dat |
| 18 | +--source include/assert_grep.inc |
| 19 | + |
| 20 | +--let $assert_file= $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat |
| 21 | +--source include/assert_grep.inc |
| 22 | + |
| 23 | +--let $assert_file= $MYSQLTEST_VARDIR/mysqld.3/data/grastate.dat |
| 24 | +--source include/assert_grep.inc |
| 25 | + |
| 26 | +# |
| 27 | +# Shut down one node |
| 28 | +# |
| 29 | + |
| 30 | +--connection node_2 |
| 31 | +--source include/shutdown_mysqld.inc |
| 32 | + |
| 33 | +--connection node_1 |
| 34 | +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; |
| 35 | +--source include/wait_condition.inc |
| 36 | + |
| 37 | +# Still, all grastate.dat files should have safe_to_boostrap: 0 |
| 38 | + |
| 39 | +--let $assert_file= $MYSQLTEST_VARDIR/mysqld.1/data/grastate.dat |
| 40 | +--source include/assert_grep.inc |
| 41 | + |
| 42 | +--let $assert_file= $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat |
| 43 | +--source include/assert_grep.inc |
| 44 | + |
| 45 | +--let $assert_file= $MYSQLTEST_VARDIR/mysqld.3/data/grastate.dat |
| 46 | +--source include/assert_grep.inc |
| 47 | + |
| 48 | +# |
| 49 | +# Shut down one more node |
| 50 | +# |
| 51 | + |
| 52 | +--connect node_3, 127.0.0.1, root, , test, $NODE_MYPORT_3 |
| 53 | +--connection node_3 |
| 54 | +--source include/shutdown_mysqld.inc |
| 55 | + |
| 56 | +--connection node_1 |
| 57 | +--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; |
| 58 | +--source include/wait_condition.inc |
| 59 | + |
| 60 | +# Now, nodes 2,3 should have safe_to_boostrap: 0 |
| 61 | + |
| 62 | +--let $assert_file= $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat |
| 63 | +--source include/assert_grep.inc |
| 64 | + |
| 65 | +--let $assert_file= $MYSQLTEST_VARDIR/mysqld.3/data/grastate.dat |
| 66 | +--source include/assert_grep.inc |
| 67 | + |
| 68 | +# But node #1 should have safe_to_boostrap: 1 |
| 69 | + |
| 70 | +--let $assert_text= grastate.dat does not have 'safe_to_bootstrap: 1' |
| 71 | +--let $assert_select= safe_to_bootstrap: 1 |
| 72 | + |
| 73 | +--let $assert_file= $MYSQLTEST_VARDIR/mysqld.1/data/grastate.dat |
| 74 | +--source include/assert_grep.inc |
| 75 | + |
| 76 | +# Restart one node |
| 77 | + |
| 78 | +--connection node_2 |
| 79 | +--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.2.expect |
| 80 | +--source include/start_mysqld.inc |
| 81 | + |
| 82 | +--connection node_1 |
| 83 | +--let $wait_condition = SELECT VARIABLE_VALUE = 2 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; |
| 84 | +--source include/wait_condition.inc |
| 85 | + |
| 86 | +# All nodes should be back to 'safe_to_bootstrap: 0' |
| 87 | + |
| 88 | +--let $assert_text= grastate.dat does not have 'safe_to_bootstrap: 0' |
| 89 | +--let $assert_select= safe_to_bootstrap: 0 |
| 90 | + |
| 91 | +--let $assert_file= $MYSQLTEST_VARDIR/mysqld.1/data/grastate.dat |
| 92 | +--source include/assert_grep.inc |
| 93 | + |
| 94 | +--let $assert_file= $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat |
| 95 | +--source include/assert_grep.inc |
| 96 | + |
| 97 | +--let $assert_file= $MYSQLTEST_VARDIR/mysqld.3/data/grastate.dat |
| 98 | +--source include/assert_grep.inc |
| 99 | + |
| 100 | +# |
| 101 | +# Kill the cluster |
| 102 | +# |
| 103 | + |
| 104 | +--connection node_2 |
| 105 | +--source include/shutdown_mysqld.inc |
| 106 | + |
| 107 | +--connection node_1 |
| 108 | +SET SESSION wsrep_on = OFF; |
| 109 | +--let $wait_condition = SELECT VARIABLE_VALUE = 1 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; |
| 110 | +--source include/wait_condition.inc |
| 111 | + |
| 112 | +--source include/kill_galera.inc |
| 113 | + |
| 114 | +# |
| 115 | +# Only node #1 should have safe_to_bootstrap: 1 |
| 116 | +# include/assert_grep.inc requires a running server, so we revert to simple grep |
| 117 | +# |
| 118 | + |
| 119 | +--error 0 |
| 120 | +--exec grep 'safe_to_bootstrap: 1' $MYSQLTEST_VARDIR/mysqld.1/data/grastate.dat |
| 121 | + |
| 122 | +--error 0 |
| 123 | +--exec grep 'safe_to_bootstrap: 0' $MYSQLTEST_VARDIR/mysqld.2/data/grastate.dat |
| 124 | + |
| 125 | +--error 0 |
| 126 | +--exec grep 'safe_to_bootstrap: 0' $MYSQLTEST_VARDIR/mysqld.3/data/grastate.dat |
| 127 | + |
| 128 | +# |
| 129 | +# Attempt to bootstrap nodes #2, #3, should fail |
| 130 | +# |
| 131 | + |
| 132 | +--error 1 |
| 133 | +--exec $MYSQLD --defaults-group-suffix=.2 --defaults-file=$MYSQLTEST_VARDIR/my.cnf --wsrep-new-cluster | grep 'This node is not safe to bootstrap the cluster' |
| 134 | +--error 1 |
| 135 | +--exec $MYSQLD --defaults-group-suffix=.3 --defaults-file=$MYSQLTEST_VARDIR/my.cnf --wsrep-new-cluster | grep 'This node is not safe to bootstrap the cluster' |
| 136 | + |
| 137 | +# |
| 138 | +# Attempt to bootstrap starting from node #1, should succeed |
| 139 | +# |
| 140 | + |
| 141 | +--connection node_1 |
| 142 | +--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.1.expect |
| 143 | +--source include/start_mysqld.inc |
| 144 | +--source include/wait_until_connected_again.inc |
| 145 | + |
| 146 | +--connection node_2 |
| 147 | +--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.2.expect |
| 148 | +--source include/start_mysqld.inc |
| 149 | + |
| 150 | +--connection node_3 |
| 151 | +--let $_expect_file_name= $MYSQLTEST_VARDIR/tmp/mysqld.3.expect |
| 152 | +--source include/start_mysqld.inc |
| 153 | + |
| 154 | +--let $wait_condition = SELECT VARIABLE_VALUE = 3 FROM INFORMATION_SCHEMA.GLOBAL_STATUS WHERE VARIABLE_NAME = 'wsrep_cluster_size'; |
| 155 | +--source include/wait_condition.inc |
| 156 | + |
| 157 | +--connection node_2 |
| 158 | +CALL mtr.add_suppression("Failed to prepare for incremental state transfer"); |
| 159 | + |
| 160 | +--connection node_3 |
| 161 | +CALL mtr.add_suppression("Failed to prepare for incremental state transfer"); |
| 162 | +SHOW CREATE TABLE t1; |
| 163 | + |
| 164 | +DROP TABLE t1; |
0 commit comments