Debian Codegraph @

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

raw
1 #
2 # Test case to verify that asynchronous replication channel SQL and IO threads
3 # are also stopped when group replication is stopped.
4 #
5 # Test:
6 #
7 # 0. The test requires two servers: M1 and M2.
8 # 1. Setup Group Replication on server 1.
9 # 2. Create new channel ch2_1: server1(slave), server2(master).
10 # 3. Add some data to server2.
11 # 4. Verify data is replicated to server1.
12 # 5. Activate group_replication_stop_all_channels_failure
13 # debug sync point, which will return
14 # ER_GROUP_REPLICATION_COMMAND_FAILURE error, when stop
15 # group replication calls to stop all replication channels.
16 # 5.1. Stop Group Replication
17 # 5.2. Verify member is OFFLINE
18 # 5.3. Verify occurrence of error message
19 # 6. Add some more data to server2.
20 # 7. Verify channel ch2_1 IO and SQL THREADS are OFF.
21 # 8. Verify data isn't replicated to group i.e. server1.
22 # 9. Clean up.
23 #
24
25 --source include/have_debug.inc
26 --source include/have_group_replication_plugin.inc
27 --let $rpl_skip_group_replication_start= 1
28 --source include/group_replication.inc
29
30
31 --echo
32 --echo ############################################################
33 --echo # 1. Setup Group Replication on server 1.
34
35 --let $rpl_connection_name= server1
36 --source include/rpl_connection.inc
37
38 --source include/start_and_bootstrap_group_replication.inc
39
40
41 --echo
42 --echo ############################################################
43 --echo # 2. Setup a asynchronous replication connection from server 2
44 --echo # into group (server 1)
45
46 --let $rpl_connection_name= server1
47 --source include/rpl_connection.inc
48
49 --replace_result $SERVER_MYPORT_2 SERVER_2_PORT
50 --eval CHANGE REPLICATION SOURCE TO SOURCE_HOST='localhost', SOURCE_USER='root', SOURCE_PORT=$SERVER_MYPORT_2, SOURCE_AUTO_POSITION=1 for channel 'ch2_1'
51 --source include/start_slave.inc
52
53
54 --echo
55 --echo ############################################################
56 --echo # 3. Execute some transactions on server 2.
57
58 --let $rpl_connection_name= server2
59 --source include/rpl_connection.inc
60
61 CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
62 INSERT INTO t1 VALUES (0);
63
64
65 --echo
66 --echo ############################################################
67 --echo # 4. Wait until transactions executed on server 2 are applied
68 --echo # on group.
69
70 --let $sync_slave_connection= server1
71 --let $rpl_channel_name=ch2_1
72 --source include/sync_slave_sql_with_master.inc
73
74
75 --echo
76 --echo ############################################################
77 --echo # 5. Activate group_replication_stop_all_channels_failure
78 --echo # debug sync point, which will return
79 --echo # ER_GROUP_REPLICATION_COMMAND_FAILURE error, when stop
80 --echo # group replication calls to stop all replication channels.
81
82 --let $rpl_connection_name= server1
83 --source include/rpl_connection.inc
84
85 --echo # 5.1. Stop Group Replication
86
87 # Stop group replication will error out, but this will not stop bringing
88 # member to OFFLINE mode
89
90 SET @debug_save= @@GLOBAL.DEBUG;
91 SET @@GLOBAL.DEBUG='d,group_replication_stop_all_channels_failure';
92 --error ER_GROUP_REPLICATION_COMMAND_FAILURE
93 STOP GROUP_REPLICATION;
94 SET @@GLOBAL.DEBUG= @debug_save;
95
96 --echo # 5.2. Verify member is OFFLINE
97 --let $group_replication_member_state= OFFLINE
98 --source include/gr_wait_for_member_state.inc
99
100 --echo # 5.3. Verify occurrence of error message
101 --replace_regex /[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]T[0-9][0-9]:[0-9][0-9]:[0-9][0-9]\.[0-9][0-9][0-9][0-9][0-9][0-9][-+Z][0-9:]* *[0-9]* *\[/DATE_TIME [/
102
103 --let $grep_file= $MYSQLTEST_VARDIR/tmp/gr_stop_async_on_stop_gr.err
104 --let $grep_pattern= Error stopping channel: ch2_1. Got error: 1, Error_code: MY-000001
105 --let $grep_output= print_count
106 --source include/grep_pattern.inc
107
108 --let $grep_file= $MYSQLTEST_VARDIR/tmp/gr_stop_async_on_stop_gr.err
109 --let $grep_pattern= Error stopping channel: . Got error: 1, Error_code: MY-000001
110 --let $grep_output= print_count
111 --source include/grep_pattern.inc
112
113
114 --echo
115 --echo ############################################################
116 --echo # 6. Execute data on server 2 and ensure it is not accepted on server 1.
117
118 --let $rpl_connection_name= server2
119 --source include/rpl_connection.inc
120
121 INSERT INTO t1 VALUES (1);
122
123
124 --echo
125 --echo ############################################################
126 --echo # 7. Verify channel ch2_1 IO and SQL THREADS are OFF
127
128 --let $rpl_connection_name= server1
129 --source include/rpl_connection.inc
130
131 --let $rpl_channel_name='ch2_1'
132 --let $slave_io_errno= 1
133 --source include/wait_for_slave_to_stop.inc
134 --let $rpl_channel_name=
135
136 --let $assert_text= Verify channel ch2_1 IO_THREAD is OFF
137 --let $assert_cond= "[SELECT SERVICE_STATE FROM performance_schema.replication_connection_status WHERE channel_name = \'ch2_1\', SERVICE_STATE, 1]" = "OFF"
138 --source include/assert.inc
139
140 --let $assert_text= Verify channel ch2_1 SQL_THREAD is OFF
141 --let $assert_cond= "[SELECT SERVICE_STATE FROM performance_schema.replication_applier_status WHERE channel_name = \'ch2_1\', SERVICE_STATE, 1]" = "OFF"
142 --source include/assert.inc
143
144
145 --echo
146 --echo ############################################################
147 --echo # 8. Verify data isn't replicated to group i.e. server1
148
149 --let $assert_text= 'There is no value 1 in table t1'
150 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 1, count, 1] = 0
151 --source include/assert.inc
152
153
154 --echo
155 --echo ############################################################
156 --echo # 9. Clean Up
157
158 --let $rpl_connection_name= server1
159 --source include/rpl_connection.inc
160
161 SET GLOBAL read_only= 0;
162
163 RESET SLAVE ALL FOR CHANNEL 'ch2_1';
164
165 DROP TABLE test.t1;
166
167 --let $rpl_connection_name= server2
168 --source include/rpl_connection.inc
169
170 DROP TABLE test.t1;
171
172 --source include/group_replication_end.inc