1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109
|
################################################################################
# This test verifies the impact when a server is crashed during a incomplete
# transaction when 'rollback to savepoint' is in progress
#
# Test:
# 0. The test requires two servers: M1, M2
# 1. Create a table on M1.
# 2. Start a transaction t1 on M1, crash the server when 'rollback [work] to
# savepoint' in progress.
# 3. Check that incomplete transaction t1 is rolled back.
# 4. Clean up
################################################################################
# This test does crashes servers, thence we skip it on valgrind.
--source include/not_valgrind.inc
--source include/big_test.inc
--source include/force_restart.inc
--source include/have_debug.inc
--source include/have_debug_sync.inc
--source include/have_group_replication_plugin.inc
--source include/group_replication.inc
--let $member1_group_replication_local_address= `SELECT @@GLOBAL.group_replication_local_address`
--let $group_replication_group_seeds= `SELECT @@GLOBAL.group_replication_group_seeds`
--let $member1_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)
SET @debug_save= @@GLOBAL.DEBUG;
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
--let $member2_group_replication_local_address= `SELECT @@GLOBAL.group_replication_local_address`
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--echo #1. Create table t1 on M1
CREATE TABLE table1(a int primary key);
# Insert some values
INSERT INTO table1 values (1),(2);
--source include/rpl_sync.inc
--echo #2. Start a transaction t1 on M1, crash the server when 'rollback [work] to savepoint' in progress
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--source include/rpl_sync.inc
connect(server1_1,localhost,root,,test,$SERVER_MYPORT_1,$SERVER_MYSOCK_1);
--echo [connection M1]
--connection server1_1
--enable_reconnect
# Set sync point such that M1 waits during rollback
SET @@GLOBAL.DEBUG='d,transaction_write_set_savepoint_block_before_rollback';
# Transaction t1.
BEGIN;
INSERT INTO table1 VALUES (3);
SAVEPOINT s1;
UPDATE table1 SET a= -1 where a=1;
SAVEPOINT s2;
--send ROLLBACK TO SAVEPOINT s1
# Crash server
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--let $wait_condition=SELECT COUNT(*)=1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE State = 'debug sync point: now'
--source include/wait_condition.inc
--replace_result $member1_group_replication_local_address GROUP_REPLICATION_LOCAL_ADDRESS1 $group_replication_group_seeds GROUP_REPLICATION_GROUP_SEEDS $group_replication_group_name GROUP_REPLICATION_GROUP_NAME
--let $restart_parameters=restart:--group_replication_local_address=$member1_group_replication_local_address --group_replication_group_seeds=$group_replication_group_seeds --group_replication_group_name=$group_replication_group_name
--source include/kill_and_restart_mysqld.inc
#reconnect clients
--disconnect server1_1
--let $rpl_server_number= 1
--source include/rpl_reconnect.inc
# unblock 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 include/gr_wait_for_member_state.inc
--replace_result $member2_group_replication_local_address GROUP_REPLICATION_LOCAL_ADDRESS1
eval SET GLOBAL group_replication_force_members= "$member2_group_replication_local_address";
# rejoin M1 to group
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
--source include/start_group_replication.inc
# Upon start wait until server M1 comes online.
let $wait_condition= SELECT COUNT(*)=2 FROM performance_schema.replication_group_members where member_state= "ONLINE";
--source include/wait_condition.inc
--echo #3. check that incomplete transaction t1 is rolled back, table1 should have only 2 tuples.
--let $assert_text= 'There should be two values in table1'
--let $assert_cond= [SELECT COUNT(*) AS count FROM table1, count, 1] = 2
--source include/assert.inc
--echo #4. Clean-up
DROP TABLE table1;
SET @@GLOBAL.DEBUG=@debug_save;
--source include/group_replication_end.inc
|