Debian Codegraph @

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

raw
1 ################################################################################
2 # Validate that when the "Group replication applier module" thread is killed, on
3 # the next event that goes through it, the member moves to ERROR state.
4 #
5 # Test:
6 # 0. The test requires two servers M1 & M2
7 # 1. Create a table t1 on the group.
8 # 2. Kill the "Group replication applier module" thread on
9 # 3. Commit a transaction on server2.
10 # Once the transaction message is delivered to server1,
11 # the applier module will be awaken and it will detect
12 # that its thread was killed, which will move the
13 # member to ERROR state.
14 # 4. Server1 will move to ERROR state.
15 # 5. Server2 is ONLINE and alone on the group.
16 # 6. Clean up
17 ################################################################################
18 --source include/have_group_replication_plugin.inc
19 --source include/group_replication.inc
20
21
22 --echo
23 --echo ############################################################
24 --echo # 1. Create a table t1 on the group.
25 --let $rpl_connection_name= server1
26 --source include/rpl_connection.inc
27 SET sql_log_bin=0;
28 call mtr.add_suppression("The group replication applier thread has received KILL request.");
29 call mtr.add_suppression("Fatal error during execution on the Applier process of Group Replication. The server will now leave the group.");
30 call mtr.add_suppression("The server was automatically set into read only mode after an error was detected.");
31 call mtr.add_suppression("Error writing relay log configuration.");
32 call mtr.add_suppression("Failed to stop the group replication applier thread.");
33 SET sql_log_bin=1;
34
35 CREATE TABLE test.t1 (c1 INT NOT NULL PRIMARY KEY);
36 --source include/rpl_sync.inc
37
38
39 --echo
40 --echo ############################################################
41 --echo # 2. Kill the "Group replication applier module" thread on
42 --echo # server1.
43 --let $rpl_connection_name= server1
44 --source include/rpl_connection.inc
45 --let $processlist_id= `SELECT PROCESSLIST_ID FROM performance_schema.threads WHERE NAME="thread/group_rpl/THD_applier_module_receiver"`
46 --replace_result $processlist_id PROCESSLIST_ID
47 --eval KILL $processlist_id
48
49
50 --echo
51 --echo ############################################################
52 --echo # 3. Commit a transaction on server2.
53 --echo # Once the transaction message is delivered to server1,
54 --echo # the applier module will be awaken and it will detect
55 --echo # that its thread was killed, which will move the
56 --echo # member to ERROR state.
57 --let $rpl_connection_name= server2
58 --source include/rpl_connection.inc
59 INSERT INTO t1 VALUES (1);
60
61
62 --echo
63 --echo ############################################################
64 --echo # 4. Server1 will move to ERROR state.
65 --let $rpl_connection_name= server1
66 --source include/rpl_connection.inc
67 --let $group_replication_member_state = ERROR
68 --source include/gr_wait_for_member_state.inc
69
70 --let $wait_condition=SELECT COUNT(*)=0 FROM performance_schema.threads WHERE NAME="thread/group_rpl/THD_applier_module_receiver"
71 --source include/wait_condition.inc
72
73 # Assert that the expected entry is in the error log during KILL command
74 --let $assert_text= Assert that the expected entry is in the error log during KILL command
75 --let $assert_file=$MYSQLTEST_VARDIR/log/mysqld.1.err
76 --let $assert_only_after = Received SQL KILL from user
77 --let $assert_select= The group replication applier thread has received KILL request
78 --let $assert_count= 1
79 --source include/assert_grep.inc
80
81
82 --echo
83 --echo ############################################################
84 --echo # 5. Server2 is ONLINE and alone on the group.
85 --let $rpl_connection_name= server2
86 --source include/rpl_connection.inc
87 --let $wait_condition=SELECT COUNT(*)=1 FROM performance_schema.replication_group_members where MEMBER_STATE="ONLINE"
88 --source include/wait_condition.inc
89
90
91 --echo
92 --echo ############################################################
93 --echo # 6. Clean up.
94 --let $rpl_connection_name= server1
95 --source include/rpl_connection.inc
96 --source include/stop_group_replication.inc
97 --source include/start_group_replication.inc
98 DROP TABLE t1;
99
100 --source include/group_replication_end.inc