Current Path : /usr/opt/mysql57/mysql-test/suite/group_replication/t/ |
FreeBSD hs32.drive.ne.jp 9.1-RELEASE FreeBSD 9.1-RELEASE #1: Wed Jan 14 12:18:08 JST 2015 root@hs32.drive.ne.jp:/sys/amd64/compile/hs32 amd64 |
Current File : //usr/opt/mysql57/mysql-test/suite/group_replication/t/gr_crash_safe_master.test |
################################################################################ # Test to check the behavior of Group Replication members when the crash # happens on a member followed by a recovery on the same. # # Test: # 0. The test requires two servers: M1 and M2. # 1. With both the members are ONLINE, crash a member M1 after a transaction but # before the commit stage using DEBUG POINT. # 2. Restart the server M1. Data should ROLLBACK post restart. # 3. Check that no data is replicated on M2. # 4. Bring M1 ONLINE and check if group is working fine now. # 5. Crash a member M1 before the data is committed to make crash for # transaction using DEBUG POINT. # 6. Restart the server M1. Data should be recovered post restart. # 7. Check that data is replicated on M2. # 8. Bring M1 ONLINE and check if group is working fine now. # 9. Set DEBUG POINT after binlogging half of the transaction and then crash # the member M1. # 10. Restart the server M1. Data will not be recovered until GR start. # 11. Bring M1 ONLINE and check data is recovered from M2. # 12. Check if all members are running and group is working fine. ################################################################################ --source include/not_crashrep.inc # Don't test this under valgrind, memory leaks will occur --source include/not_asan.inc --source include/not_valgrind.inc --source include/big_test.inc --source include/have_debug.inc --source include/force_restart.inc --source ../inc/have_group_replication_plugin.inc --source ../inc/group_replication.inc SET sql_log_bin=0; call mtr.add_suppression("Attempting backtrace"); call mtr.add_suppression("allocated tablespace *., old maximum was 0"); call mtr.add_suppression("Error in Log_event::read_log_event()"); call mtr.add_suppression("Buffered warning: Performance schema disabled"); SET sql_log_bin=1; --let $_group_replication_local_address_server1= `SELECT @@GLOBAL.group_replication_local_address` --let $_group_replication_group_seeds_server1= `SELECT @@GLOBAL.group_replication_group_seeds` --let $_group_replication_group_whitelist= `SELECT @@GLOBAL.group_replication_ip_whitelist` --let $member1_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1) --let $old_debug = `select @@global.debug` --echo # Test case1: Set DEBUG POINT before binlog to make --echo # the first member crash for transaction CREATE TABLE t1(i INT, a LONGBLOB, PRIMARY KEY(i)) ENGINE=INNODB; BEGIN; --let $rows= 3 WHILE($rows) { --eval INSERT INTO t1 VALUES ($rows, REPEAT('a',2)); dec $rows; } # Write file to make mysql-test-run.pl expect crash and restart --exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --disable_query_log --eval SET SESSION debug=CONCAT(IF(LENGTH('$old_debug') > 0, "$old_debug:", ""), "d,debug,info,enter,return,crash_commit_after_prepare") --enable_query_log # Run the crashing query --error 2013 COMMIT; --enable_reconnect --echo # Restart the crashed member --exec echo "restart:--group_replication_local_address=$_group_replication_local_address_server1 --group_replication_group_seeds=$_group_replication_group_seeds_server1 --group_replication_ip_whitelist=$_group_replication_group_whitelist" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --source include/wait_until_connected_again.inc --disable_reconnect --let $rpl_server_number= 1 --source include/rpl_reconnect.inc --let $assert_cond= `SELECT COUNT(*) = 0 FROM t1` --let $assert_text= On server1, test the data will be rolled back after restart. --source include/assert.inc # Sync the second member with the first one. --source include/rpl_sync.inc --echo # On the second member, test replication will work fine, and the data --echo # is not replicated --let $diff_tables= server1:test.t1, server2:test.t1 --source include/diff_tables.inc # Wait until group has only 1 member, that is, server1 crash is detected by # the group. --let $rpl_connection_name= server2 --source include/rpl_connection.inc --let $group_replication_member_state= UNREACHABLE --let $group_replication_member_id= $member1_uuid --source ../inc/gr_wait_for_member_state.inc # unblock the group, since server1 has gone away and # there were only two in the group - majority lost --let $local_address_server2= `SELECT @@GLOBAL.group_replication_local_address` --disable_query_log # Reseting the group to server2 only --eval SET GLOBAL group_replication_force_members= "$local_address_server2" --enable_query_log --let $group_replication_number_of_members= 1 --source ../inc/gr_wait_for_number_of_members.inc --let $rpl_connection_name= server1 --source include/rpl_connection.inc --source include/start_group_replication.inc # Check if the group is still working CREATE TABLE temp (i INT PRIMARY KEY) engine=INNODB; INSERT INTO temp VALUES (1); --source include/rpl_sync.inc --connection server2 INSERT INTO temp VALUES (2); --source include/rpl_sync.inc --let $diff_tables= server1:test.temp, server2:test.temp --source include/diff_tables.inc DROP TABLE t1; DROP TABLE temp; --source include/rpl_sync.inc --echo # Test case2: Set DEBUG POINT after binlog, and before the data --echo # is committed to make crash for transaction --connection server1 CREATE TABLE t1(i INT, a LONGBLOB, PRIMARY KEY(i)) ENGINE=INNODB; BEGIN; --let $rows= 3 WHILE($rows) { --eval INSERT INTO t1 VALUES ($rows, REPEAT('a',2)); --dec $rows } # Write file to make mysql-test-run.pl expect crash and restart --exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --disable_query_log --eval SET SESSION debug=CONCAT(IF(LENGTH('$old_debug') > 0, "$old_debug:", ""), "d,debug,info,enter,return,crash_commit_after_log") --enable_query_log # Run the crashing query --error 2013 COMMIT; --source include/wait_until_disconnected.inc --enable_reconnect --echo # Restart the crashed member --exec echo "restart:--group_replication_local_address=$_group_replication_local_address_server1 --group_replication_group_seeds=$_group_replication_group_seeds_server1 --group_replication_ip_whitelist=$_group_replication_group_whitelist" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --source include/wait_until_connected_again.inc --disable_reconnect --let $rpl_server_number= 1 --source include/rpl_reconnect.inc --let $assert_cond= `SELECT COUNT(*) = 3 FROM t1` --let $assert_text= On server1, test the data will be recovered after the server1 restart. --source include/assert.inc --echo # On the second member, test that the replication is working fine, and --echo # data gets replicated here. --let $diff_tables= server1:test.t1, server2:test.t1 --source include/diff_tables.inc # Wait until group has only 1 member, that is, server1 crash is detected by # the group. --let $rpl_connection_name= server2 --source include/rpl_connection.inc --let $group_replication_member_state= UNREACHABLE --let $group_replication_member_id= $member1_uuid --source ../inc/gr_wait_for_member_state.inc # unblock the group, since server2 has gone away and # there were only two in the group - majority lost --let $local_address_server2= `SELECT @@GLOBAL.group_replication_local_address` --disable_query_log # Reseting the group to server2 only --eval SET GLOBAL group_replication_force_members= "$local_address_server2" --enable_query_log --let $group_replication_number_of_members= 1 --source ../inc/gr_wait_for_number_of_members.inc --let $rpl_connection_name= server1 --source include/rpl_connection.inc --source include/start_group_replication.inc # Check if the group is still working CREATE TABLE temp (i INT PRIMARY KEY) engine=INNODB; INSERT INTO temp VALUES (1); --source include/rpl_sync.inc --connection server2 INSERT INTO temp VALUES (2); --source include/rpl_sync.inc --let $diff_tables= server1:test.temp, server2:test.temp --source include/diff_tables.inc DROP TABLE t1; DROP TABLE temp; --source include/rpl_sync.inc # Test transaction with large data inserted --connection server1 CREATE TABLE t1(i INT AUTO_INCREMENT PRIMARY KEY, a LONGBLOB) ENGINE=INNODB; --echo # Test case3: Set DEBUG POINT after binlogging half of the transaction and --echo # then crash the member and followed by restarting the member. set AUTOCOMMIT=0; BEGIN; --let $rows= 24 WHILE($rows) { INSERT INTO t1 (a) VALUES ( REPEAT('a',6144)); --dec $rows } # Write file to make mysql-test-run.pl expect crash and restart --exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --disable_query_log --eval SET SESSION debug=CONCAT(IF(LENGTH('$old_debug') > 0, "$old_debug:", ""), "d,debug,info,enter,return,half_binlogged_transaction") --enable_query_log # Run the crashing query --error 2013 COMMIT; --source include/wait_until_disconnected.inc --enable_reconnect --echo # Restart the crashed member --exec echo "restart:--group_replication_local_address=$_group_replication_local_address_server1 --group_replication_group_seeds=$_group_replication_group_seeds_server1" > $MYSQLTEST_VARDIR/tmp/mysqld.1.expect --source include/wait_until_connected_again.inc --disable_reconnect --let $rpl_server_number= 1 --source include/rpl_reconnect.inc --echo # Test the data will not be recovered successfully --echo # after the crashed first member restarts. --let $assert_cond= `SELECT COUNT(*) = 0 FROM t1` --let $assert_text= On server1, test the data will be recovered after the server1 restart. --source include/assert.inc # Wait until group has only 1 member, that is, server1 crash is detected by # the group. --let $rpl_connection_name= server2 --source include/rpl_connection.inc --let $group_replication_member_state= UNREACHABLE --let $group_replication_member_id= $member1_uuid --source ../inc/gr_wait_for_member_state.inc # unblock the group, since server2 has gone away and # there were only two in the group - majority lost --let $local_address_server2= `SELECT @@GLOBAL.group_replication_local_address` --disable_query_log # Reseting the group to server2 only --eval SET GLOBAL group_replication_force_members= "$local_address_server2" --enable_query_log --let $group_replication_number_of_members= 1 --source ../inc/gr_wait_for_number_of_members.inc --let $rpl_connection_name= server1 --source include/rpl_connection.inc --source include/start_group_replication.inc # On restarting group replication on the first member it will be getting the transactions # from a donor and try to get in sync with the other members in the group. --let $diff_tables= server1:test.t1, server2:test.t1 --source include/diff_tables.inc --connection server2 --let $assert_cond= `SELECT COUNT(*) = 24 FROM t1` --let $assert_text= The table has 24 rows after the restart. --source include/assert.inc # Check if the group is still running --connection server1 CREATE TABLE temp (i INT PRIMARY KEY) engine=INNODB; INSERT INTO temp VALUES (1); --source include/rpl_sync.inc --connection server2 INSERT INTO temp VALUES (2); --source include/rpl_sync.inc --let $diff_tables= server1:test.temp, server2:test.temp --source include/diff_tables.inc DROP TABLE t1; DROP TABLE temp; --source ../inc/group_replication_end.inc