--source include/have_log_bin.inc --source include/have_gtid.inc --source include/have_debug_sync_new.inc call mtr.add_suppression("The consensus follower is not allowed to to do current operation."); --source include/paxos.inc # connect 3 server. must have test database --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) #1. basic write #leader --connection conn1 create table t(id int); insert into t values(0); --replace_column 2 # 5 # show master status; --replace_column 1 # select * from mysql.gtid_executed; --source include/wait_follower_catchup.inc --connection conn2 --replace_column 2 # 5 # show master status; --replace_column 1 # select * from mysql.gtid_executed; --connection conn1 flush logs; --replace_column 1 # select * from mysql.gtid_executed; drop table t; #2. switch role --connection conn1 create table t(id int); insert into t values(0); #change consensus_leader to 3; --replace_result $PAXOS_PORT_3 PAXOS_PORT_3 --eval call dbms_consensus.change_leader("127.0.0.1:$PAXOS_PORT_3") --connection conn3 --source include/wait_until_connected_again.inc insert into t values(1); --replace_column 2 # 5 # show master status; --source include/wait_follower_catchup.inc #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"); --connect (conn4,127.0.0.1,root,,test,$MYPORT_1) --connection conn4 --source include/wait_until_connected_again.inc --replace_column 2 # 5 # show master status; drop table t; #3 crash recovery --connection conn4 create table t(id int); insert into t values(0); --source include/wait_follower_catchup.inc # Request a crash, and restart the server. set debug='+d,crash_commit_before'; # Write file to make mysql-test-run.pl restart the server --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --error 2013 insert into t values(1); --disconnect conn1 --disconnect conn4 connection default; --enable_reconnect --source include/wait_until_connected_again.inc --disable_reconnect --replace_column 2 # 5 # show master status; drop table t; #4. leader degrade slow connection default; create table t(c text); insert into t values('kongzhi'); --source include/wait_follower_catchup.inc set global max_binlog_size=4096; set debug="+d,simulate_leader_degrade_slow"; #--send change consensus_leader to 2 --replace_result $PAXOS_PORT_2 PAXOS_PORT_2 --send_eval call dbms_consensus.change_leader("127.0.0.1:$PAXOS_PORT_2"); connection conn2; --enable_reconnect --source include/wait_until_connected_again.inc --disable_reconnect # old leader will store the paxos log in binlog mode insert into t values(repeat('1', 1024)); insert into t values(repeat('1', 1024)); insert into t values(repeat('1', 1024)); --replace_column 2 # 5 # show master status; connection default; reap; --enable_reconnect --source include/wait_until_connected_again_old.inc --disable_reconnect #flush logs; --replace_column 2 # 5 # show master status; --sleep 10 --replace_column 2 # 5 # show master status; connection conn2; set global max_binlog_size=(1024 * 1024 * 1024); drop table t; #5. duplicate gtid #connection default; #set global debug="+d, simulate_duplicate_gtid"; #connection conn2; #create table t(id int); #insert into t values(0); #--source include/wait_follower_catchup.inc #drop table t; #connection default; #set global debug="-d, simulate_duplicate_gtid"; #6. truncate log connection conn2; #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") connection default; --source include/wait_until_connected_again.inc create table t(id int); insert into t values(0); --replace_column 2 # 5 # show master status; set global debug="+d, skip_consensus_fifo_cache"; set global debug="+d, crash_before_large_trx_commit_early"; --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --error 2013 #this will be truncated insert into t values(1); --enable_reconnect --source include/wait_until_connected_again.inc --disable_reconnect --replace_column 2 # 5 # show master status; #bug22962305 init gtid set scan all binlog files flush logs; insert into t values(2); --exec echo "restart" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --shutdown_server --enable_reconnect --source include/wait_until_connected_again.inc --disable_reconnect #bug23162444 gtid error before the cluster has elected a leader --exec cat $MYSQLTEST_VARDIR/log/mysqld.1.err | grep "Can't find the log has the commit index 0" | wc -l drop table t;