Debian Codegraph @

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

raw
1 ################################################################################
2 # This test verifies whether the group_replication works fine when majority loss
3 # occurs while there are dml operations running on some server
4 #
5 # Test:
6 # 0. The test requires two servers: M1 and M2.
7 # 1. Start the group_replication on all the servers.
8 # 2. CREATE TABLE ON M1 and CREATE a procedure to perform the dml operations
9 # on the table
10 # 3. Call the procedure using send operation
11 # 4. Kill and restart the server M2
12 # 5. Wait until server M2 is in UNREACHABLE state.
13 # 6. SET group_replication_force_members value as local_address of server M1
14 # 7. Start GR on server M2.
15 # 8. Obtain the result of send command on M1 and wait until both
16 # the servers are ONLINE.
17 # 9. Verify that table t1 has same data across all the members.
18 # 10.Clean up
19 ################################################################################
20
21 # This test does crashes servers, thence we skip it on valgrind.
22 --source include/not_valgrind.inc
23 --source include/big_test.inc
24 --source include/force_restart.inc
25 --source include/set_privilege_checks_user_as_system_user.inc
26 --source include/have_group_replication_plugin.inc
27 --source include/group_replication.inc
28
29 --let $rpl_connection_name= server1
30 --source include/rpl_connection.inc
31
32 # Save the local address of server1
33 --let $local_address_server1= `SELECT @@GLOBAL.group_replication_local_address`
34 CREATE TABLE t1(a int primary key);
35
36 --source include/rpl_sync.inc
37
38 # Create a procedure to perform the dml operations.
39 delimiter $$;
40 CREATE PROCEDURE dml_operations()
41 BEGIN
42 declare x INT;
43 set x=1;
44 while x<300 do
45 insert into t1 values (x);
46 update t1 set a=x+300 where a=x;
47 delete from t1 where a<310;
48 set x=x+1;
49 end while;
50 end$$
51 delimiter ;$$
52 --echo
53
54 --echo ----call procedure----
55 --send call dml_operations()
56 --echo
57
58 --let $rpl_connection_name= server2
59 --source include/rpl_connection.inc
60
61 set sql_log_bin=0;
62 call mtr.add_suppression(".*Replica SQL for channel 'group_replication_applier': ... The replica coordinator and worker threads are stopped, possibly leaving data in inconsistent state*");
63 call mtr.add_suppression("Error in Log_event::read_log_event()");
64 set sql_log_bin=1;
65
66 # Wait until some data is entered into table t1 to ensure that the server2
67 # will get killed while there are dml operations running on server1
68 --let $wait_condition= SELECT COUNT(*) >20 FROM t1
69 --source include/wait_condition.inc
70
71 # Kill server2
72 --echo # killing
73 --let $group_replication_local_address= `SELECT @@GLOBAL.group_replication_local_address`
74 --let $group_replication_group_seeds= `SELECT @@GLOBAL.group_replication_group_seeds`
75
76 --let $restart_parameters=restart:--group_replication_local_address=$group_replication_local_address --group_replication_group_seeds=$group_replication_group_seeds --group_replication_group_name=$group_replication_group_name
77 --replace_result $group_replication_local_address GROUP_REPLICATION_LOCAL_ADDRESS $group_replication_group_seeds GROUP_REPLICATION_GROUP_SEEDS $group_replication_group_name GROUP_REPLICATION_GROUP_NAME
78 --source include/kill_and_restart_mysqld.inc
79 --echo # restarting
80
81 # Needed as we are not using rpl_restart_server.inc
82 --let $rpl_server_number= 2
83 --source include/rpl_reconnect.inc
84
85 --let $rpl_connection_name= server_1
86 --source include/rpl_connection.inc
87
88 # Verify that there are still two members in the group
89 --let $group_replication_number_of_members= 2
90 --source include/gr_wait_for_number_of_members.inc
91
92 # Verify that server2 is marked as UNREACHABLE.
93 let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.replication_group_members where member_state= "UNREACHABLE";
94 --source include/wait_condition.inc
95
96 --replace_result $local_address_server1 LOCAL_ADDRESS_SERVER_1
97 eval SET @@GLOBAL.group_replication_force_members= "$local_address_server1";
98
99 # Wait until there is only one member in group.
100 let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.replication_group_members;
101 --source include/wait_condition.inc
102
103 --let $rpl_connection_name= server2
104 --source include/rpl_connection.inc
105 # Start group replication on server2
106 --let $wait_timeout=300
107 --source include/start_group_replication.inc
108
109 --let $rpl_connection_name= server1
110 --source include/rpl_connection.inc
111 # Obtain the result of send command
112 reap;
113
114 # Sync all the servers.
115 --let $slave_timeout= 100
116 --source include/rpl_sync.inc
117
118 # Verify that table t1 has same data on both the servers.
119 --let $diff_tables=server1:t1, server2:t1
120 --source include/diff_tables.inc
121
122 # Clean up
123 drop table t1;
124 drop procedure dml_operations;
125 --source include/group_replication_end.inc