Debian Codegraph @

mysql-test/suite/group_replication/t/gr_savepoint_crash_on_rollback.test

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