Debian Codegraph @

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

raw
1 ################################################################################
2 # WL#9053
3 # Desc : Stop group replication on M1 using a client when some DML's(inserts) are
4 # happening in some other clients connected to M1
5 # Test:
6 # 0. This test requires 3 servers
7 # M1 -> server1, M2 -> server2, M3 -> server3
8 # 1. Start 3 servers and add them to group replication group
9 # 2. Start a insert operation on M1 which inserts 500 records
10 # using "send call"
11 # 3. perform stop GR on M1 from a parallel client when insert operation is
12 # going on in another client connected to M1
13 # 4. Check the number of servers online and status of servers (M1,M2,M3)
14 # 5. Join M1 back to the group
15 # 6. Validate the record counts on different tables from M1 and M3
16 # 7. Cleanup
17 ################################################################################
18 --source include/big_test.inc
19 --source include/set_privilege_checks_user_as_system_user.inc
20 --source include/have_group_replication_plugin.inc
21 --let $rpl_server_count= 3
22 --source include/group_replication.inc
23
24 --let $rpl_connection_name= server1
25 --source include/rpl_connection.inc
26
27 SET SESSION sql_log_bin= 0;
28 call mtr.add_suppression("Transaction cannot be executed while Group Replication is stopping.");
29 call mtr.add_suppression("Run function 'before_commit' in plugin 'group_replication' failed");
30 SET SESSION sql_log_bin= 1;
31
32 CREATE TABLE test.t1 ( a int primary key);
33 --source include/rpl_sync.inc
34 USE test;
35 delimiter $$;
36 CREATE PROCEDURE insert_into_t1()
37 BEGIN
38 declare x INT;
39 set x=1;
40 while x<500 do
41 insert into t1 values (x);
42 set x=x+1;
43 end while;
44 end$$
45 delimiter ;$$
46 --source include/rpl_sync.inc
47 --echo
48
49 # Connect a client (server1_1) to server1 and perform insert
50 # operation using send call
51 --let $rpl_connection_name= server_1_1
52 --source include/rpl_connection.inc
53 --echo ----call procedure----
54 --send call insert_into_t1()
55 --echo
56
57 --let $rpl_connection_name= server1
58 --source include/rpl_connection.inc
59 --echo ####### Wait for atleast 50 records to be inserted from the parallel client #######
60 --let $wait_condition= SELECT COUNT(*)>=50 FROM test.t1
61 --source include/wait_condition.inc
62
63 --echo ###### Stop the group replication from the parallel client on Server 1 ######
64 --source include/stop_group_replication.inc
65
66 --let $rpl_connection_name= server_1_1
67 --source include/rpl_connection.inc
68 --echo ####### Performing a reap for send operation #######
69 --error ER_RUN_HOOK_ERROR
70 --reap
71
72 --let $rpl_connection_name= server2
73 --source include/rpl_connection.inc
74
75 --echo ####### Checking the member count having online status #######
76 --let $wait_condition=SELECT COUNT(*)=2 FROM performance_schema.replication_group_members where MEMBER_STATE="ONLINE"
77 --source include/wait_condition.inc
78
79 --let $rpl_connection_name= server3
80 --source include/rpl_connection.inc
81 --echo ####### Checking the member count having online status #######
82 --let $wait_condition=SELECT COUNT(*)=2 FROM performance_schema.replication_group_members where MEMBER_STATE="ONLINE"
83 --source include/wait_condition.inc
84
85 #
86 ## Connect a client to S1 and start the group replication again
87 #
88 --echo
89 --let $rpl_connection_name= server1
90 --source include/rpl_connection.inc
91 --source include/start_group_replication.inc
92
93 let $wait_condition=SELECT COUNT(*)=3 FROM performance_schema.replication_group_members where MEMBER_STATE="ONLINE";
94 --source include/wait_condition.inc
95
96 --echo
97 --let $rpl_connection_name= server1
98 --source include/rpl_connection.inc
99 CREATE TABLE test.t2 ( a int primary key);
100 --disable_query_log
101 --let $i=10
102 while($i)
103 {
104 --EVAL INSERT INTO t2 VALUES ($i)
105 --dec $i
106 }
107 --enable_query_log
108 --source include/rpl_sync.inc
109
110 # Validate the record count in all the tables in server1
111 --echo # Validating the records in server1 #
112 --let $assert_text= 'Checking the number of records in test.t1'
113 --let $assert_cond= [SELECT COUNT(*) as count FROM test.t1,count, 1] >= 50
114 --source include/assert.inc
115
116 --let $assert_text= 'Checking the number of records in test.t2'
117 --let $assert_cond= [SELECT COUNT(*) as count FROM test.t2,count, 1] = 10
118 --source include/assert.inc
119
120 --echo
121 --let $rpl_connection_name= server3
122 --source include/rpl_connection.inc
123 --let $assert_text= 'Checking the number of records in test.t1'
124 --let $assert_cond= [SELECT COUNT(*) as count FROM test.t1,count, 1] >= 50
125 --source include/assert.inc
126
127 --let $assert_text= 'Checking the number of records in test.t2'
128 --let $assert_cond= [SELECT COUNT(*) as count FROM test.t2,count, 1] = 10
129 --source include/assert.inc
130
131 # Validate the record count in all the tables in server2
132 --let $rpl_connection_name= server2
133 --source include/rpl_connection.inc
134 --echo # Validating the records in server2 #
135 --let $assert_text= 'Checking the number of records in test.t1'
136 --let $assert_cond= [SELECT COUNT(*) as count FROM test.t1,count, 1] >= 50
137 --source include/assert.inc
138
139 --let $assert_text= 'Checking the number of records in test.t2'
140 --let $assert_cond= [SELECT COUNT(*) as count FROM test.t2,count, 1] = 10
141 --source include/assert.inc
142
143 --let $diff_tables=server1:t1, server2:t1, server3:t1
144 --source include/diff_tables.inc
145
146 --let $diff_tables=server1:t2, server2:t2, server3:t2
147 --source include/diff_tables.inc
148
149 #Cleanup
150 --echo #cleanup#
151
152 DROP TABLE test.t2;
153 DROP PROCEDURE insert_into_t1;
154 DROP TABLE test.t1;
155
156 --source include/group_replication_end.inc
157