| 1 |
if ($failover_to_slave) |
| 2 |
{ |
| 3 |
--let $server_to_crash=1 |
| 4 |
--let $server_to_promote=2 |
| 5 |
--let $new_master_port=$SERVER_MYPORT_2 |
| 6 |
--let $client_port=$SERVER_MYPORT_1 |
| 7 |
|
| 8 |
--connect (conn_client,127.0.0.1,root,,test,$SERVER_MYPORT_1,) |
| 9 |
} |
| 10 |
if (!$failover_to_slave) |
| 11 |
{ |
| 12 |
--let $server_to_crash=2 |
| 13 |
--let $server_to_promote=1 |
| 14 |
--let $new_master_port=$SERVER_MYPORT_1 |
| 15 |
--let $client_port=$SERVER_MYPORT_2 |
| 16 |
|
| 17 |
--connect (conn_client,127.0.0.1,root,,test,$SERVER_MYPORT_2,) |
| 18 |
} |
| 19 |
|
| 20 |
|
| 21 |
# Hold insert after write to binlog and before "run_commit_ordered" in engine |
| 22 |
|
| 23 |
|
| 24 |
if ($case == 1) |
| 25 |
{ |
| 26 |
SET DEBUG_SYNC= "commit_after_release_LOCK_after_binlog_sync SIGNAL con1_ready WAIT_FOR con1_go"; |
| 27 |
--send_eval $query_to_crash |
| 28 |
--connection server_$server_to_crash |
| 29 |
SET DEBUG_SYNC= "now WAIT_FOR con1_ready"; |
| 30 |
--source include/kill_mysqld.inc |
| 31 |
} |
| 32 |
|
| 33 |
# complicate recovery with an extra binlog file |
| 34 |
if ($case == 2) |
| 35 |
{ |
| 36 |
SET DEBUG_SYNC= "commit_before_get_LOCK_commit_ordered SIGNAL con1_ready WAIT_FOR con1_go"; |
| 37 |
SET DEBUG_SYNC= "commit_after_release_LOCK_after_binlog_sync WAIT_FOR con1_go1"; |
| 38 |
--send_eval $query_to_crash |
| 39 |
--connect (conn_client_2,127.0.0.1,root,,test,$SERVER_MYPORT_2,) |
| 40 |
# use the same signal with $query_to_crash |
| 41 |
SET DEBUG_SYNC= "now WAIT_FOR con1_ready"; |
| 42 |
SET DEBUG_SYNC= "commit_before_get_LOCK_after_binlog_sync SIGNAL con1_go"; |
| 43 |
SET DEBUG_SYNC= "commit_before_get_LOCK_commit_ordered SIGNAL con2_ready"; |
| 44 |
--send_eval $query2_to_crash |
| 45 |
--connection server_$server_to_crash |
| 46 |
SET DEBUG_SYNC= "now WAIT_FOR con2_ready"; |
| 47 |
--source include/kill_mysqld.inc |
| 48 |
} |
| 49 |
|
| 50 |
# complicate recovery with an extra binlog file |
| 51 |
if ($case == 3) |
| 52 |
{ |
| 53 |
SET DEBUG_SYNC= "commit_before_get_LOCK_commit_ordered SIGNAL con1_ready WAIT_FOR con1_go"; |
| 54 |
--send_eval $query_to_crash |
| 55 |
--connect (conn_client_3,127.0.0.1,root,,test,$SERVER_MYPORT_1,) |
| 56 |
SET DEBUG_SYNC= "now WAIT_FOR con1_ready"; |
| 57 |
# use the same signal with $query_to_crash |
| 58 |
SET DEBUG_SYNC= "commit_before_update_binlog_end_pos SIGNAL con3_ready WAIT_FOR con1_go"; |
| 59 |
--send_eval $query2_to_crash |
| 60 |
--connection server_$server_to_crash |
| 61 |
SET DEBUG_SYNC= "now WAIT_FOR con3_ready"; |
| 62 |
--source include/kill_mysqld.inc |
| 63 |
} |
| 64 |
|
| 65 |
--connection server_$server_to_promote |
| 66 |
--let $slave_param= Slave_SQL_Running_State |
| 67 |
--let $slave_param_value= Slave has read all relay log; waiting for more updates |
| 68 |
source include/wait_for_slave_param.inc; |
| 69 |
|
| 70 |
--error 2003 |
| 71 |
--source include/stop_slave.inc |
| 72 |
|
| 73 |
--eval select count(*) 'on slave must be $expected_rows_on_slave' from t1 |
| 74 |
|
| 75 |
SELECT @@GLOBAL.gtid_current_pos; |
| 76 |
|
| 77 |
--let $restart_parameters=--skip-slave-start=1 --rpl-semi-sync-slave-enabled=1 --init-rpl-role=SLAVE |
| 78 |
--let $allow_rpl_inited=1 |
| 79 |
--source include/start_mysqld.inc |
| 80 |
--connection server_$server_to_crash |
| 81 |
--enable_reconnect |
| 82 |
--source include/wait_until_connected_again.inc |
| 83 |
|
| 84 |
--let $slave_semi_sync_enabled= query_get_value(SHOW VARIABLES LIKE 'Rpl_semi_sync_slave_enabled', Value, 1) |
| 85 |
--echo # Ensuring variable rpl_semi_sync_slave_enabled is ON.. |
| 86 |
if (`SELECT strcmp("ON", "$slave_semi_sync_enabled") != 0`) |
| 87 |
{ |
| 88 |
--die Slave started with rpl_semi_sync_slave_enabled=1 yet it is OFF in the variable output |
| 89 |
} |
| 90 |
|
| 91 |
--let $slave_semi_sync_status= query_get_value(SHOW STATUS LIKE 'Rpl_semi_sync_slave_status', Value, 1) |
| 92 |
--echo # Ensuring status rpl_semi_sync_slave_status is OFF.. |
| 93 |
if (`SELECT strcmp("OFF", "$slave_semi_sync_status") != 0`) |
| 94 |
{ |
| 95 |
--die Slave started with skip-slave-start yet started with rpl_semi_sync_slave_status=ON |
| 96 |
} |
| 97 |
|
| 98 |
--eval select count(*) 'on master must be $expected_rows_on_master' from t1 |
| 99 |
|
| 100 |
# Check error log for correct messages. |
| 101 |
let $log_error_ = $MYSQLTEST_VARDIR/log/mysqld.$server_to_crash.err; |
| 102 |
--let SEARCH_FILE=$log_error_ |
| 103 |
--let SEARCH_PATTERN=$log_search_pattern |
| 104 |
--source include/search_pattern_in_file.inc |
| 105 |
|
| 106 |
--disconnect conn_client |
| 107 |
|
| 108 |
# |
| 109 |
# FAIL OVER now to new master |
| 110 |
# |
| 111 |
--connection server_$server_to_promote |
| 112 |
set global rpl_semi_sync_master_enabled = 1; |
| 113 |
set global rpl_semi_sync_master_wait_point=AFTER_SYNC; |
| 114 |
|
| 115 |
--connection server_$server_to_crash |
| 116 |
--let $master_port=$SERVER_MYPORT_2 |
| 117 |
if (`select $server_to_crash = 2`) |
| 118 |
{ |
| 119 |
--let $master_port=$SERVER_MYPORT_1 |
| 120 |
} |
| 121 |
evalp CHANGE MASTER TO master_host='127.0.0.1', master_port=$new_master_port, master_user='root', master_ssl_verify_server_cert=0, master_use_gtid=SLAVE_POS; |
| 122 |
set global rpl_semi_sync_slave_enabled = 1; |
| 123 |
set @@global.gtid_slave_pos=@@global.gtid_binlog_pos; |
| 124 |
--source include/start_slave.inc |