# Mock test --source include/paxos.inc --connect (conn1,127.0.0.1,root,,test,$MYPORT_1) --connect (conn2,127.0.0.1,root,,test,$MYPORT_2) --connect (conn3,127.0.0.1,root,,test,$MYPORT_3) # check leader is conn1 --connection conn1 select server_id, role from information_schema.alisql_cluster_local where role='leader'; --connection conn2 # now stop conn2 --exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.2.expect select server_id, voted_for, role from information_schema.alisql_cluster_local; --shutdown_server --source include/wait_until_disconnected.inc # generate more log --connection conn1 create table t1(id int); insert into t1 values (1); insert into t1 values (2); insert into t1 values (3); insert into t1 values (4); insert into t1 values (5); --let $logindex_leader = `select last_log_index from information_schema.alisql_cluster_local;` # restart conn3 with mock logindex --connection conn3 # wait conn3 receive all logs let $wait_condition= select last_log_index=$logindex_leader from information_schema.alisql_cluster_local; --source include/wait_condition.inc # record the logindex --let $logindex = `select last_log_index-2 from information_schema.alisql_cluster_local;` --replace_result $logindex LOGINDEX let $restart_parameters = restart: --cluster-start-index=$logindex; --source include/restart_mysqld_old.inc # stop conn1 --connection conn1 --enable_reconnect --exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --shutdown_server --source include/wait_until_disconnected.inc # start conn2 --connection conn2 #--exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.2.expect --enable_reconnect --exec $MYSQLD --defaults-file=$MYSQLTEST_VARDIR/my.cnf --defaults-group-suffix=.2 --loose-debug-sync-timeout=600 --core-file >$MYSQLTEST_VARDIR/log/mysqld_err2.log 2>&1 & --connection conn3 let $wait_condition= select role='Leader' from information_schema.alisql_cluster_local; --source include/wait_condition.inc --connection conn1 --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --enable_reconnect --sleep 1 --source include/wait_until_connected_again_old.inc --connection conn3 let $wait_condition= select SERVER_READY_FOR_RW='Yes' from information_schema.alisql_cluster_local; --source include/wait_condition.inc insert into t1 values (6); --let $logindex = `select last_log_index from information_schema.alisql_cluster_local;` --connection conn1 let $wait_condition= select last_log_index=$logindex from information_schema.alisql_cluster_local; --source include/wait_condition.inc --connection conn3 select count(distinct(match_index)) from information_schema.alisql_cluster_global where server_id <= 3; #change consensus_leader to 1; --replace_result $PAXOS_PORT_1 PAXOS_PORT_1 eval call dbms_consensus.change_leader("127.0.0.1:$PAXOS_PORT_1"); --sleep 1 --connection conn1 select count(distinct(match_index)) from information_schema.alisql_cluster_global where server_id <= 3; drop table t1;