Debian Codegraph @

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

raw
1 ################################################################################
2 # Validate that when a member is expelled from a group, its state is properly
3 # updated.
4 #
5 # Test:
6 # 0. The test requires three servers.
7 # 1. Suspend server 1 by sending a signal SIGSTOP to it.
8 # This will make server 1 to not answer to "I am alive"
9 # GCS messages and it will be expelled from the group.
10 # 2. Wait until group expel server 1.
11 # 3. Resume server 1 by sending a signal SIGCONT to it.
12 # Server will notice that was expelled from the group,
13 # will change to ERROR state and enabled super_read_only
14 # mode.
15 # 4. Stop and start server 1, it will be back to normal.
16 # 5. Check data.
17 # 6. Clean up.
18 ################################################################################
19
20
21 # Test involves sending SIGSTOP and SIGCONT signals using kill Linux command.
22 --source include/not_valgrind.inc
23 --source include/linux.inc
24 --source include/big_test.inc
25 --source include/force_restart.inc
26 --source include/have_group_replication_plugin.inc
27 --let $rpl_server_count= 3
28 --source include/group_replication.inc
29
30
31 --echo
32 --echo ############################################################
33 --echo # 0. Error suppressions.
34 --let $rpl_connection_name= server1
35 --source include/rpl_connection.inc
36 SET SESSION sql_log_bin= 0;
37 call mtr.add_suppression("Member was expelled from the group due to network failures, changing member status to ERROR.");
38 call mtr.add_suppression("The server was automatically set into read only mode after an error was detected.");
39 call mtr.add_suppression("\\[GCS\\] Unable to resolve peer address.");
40 SET SESSION sql_log_bin= 1;
41
42
43 --echo
44 --echo ############################################################
45 --echo # 1. Suspend server 1 by sending a signal SIGSTOP to it.
46 --echo # This will make server 1 to not answer to "I am alive"
47 --echo # GCS messages and it will be expelled from the group.
48 --let $rpl_connection_name= server1
49 --source include/rpl_connection.inc
50
51 --echo # Get server pid.
52 SET SESSION sql_log_bin= 0;
53 CREATE TABLE pid_table(pid_no INT);
54 --let $pid_file= `SELECT @@GLOBAL.pid_file`
55 --replace_result $pid_file pid_file
56 --eval LOAD DATA LOCAL INFILE '$pid_file' INTO TABLE pid_table
57 --let $server_pid=`SELECT pid_no FROM pid_table`
58 DROP TABLE pid_table;
59 SET SESSION sql_log_bin= 1;
60
61 --echo # Send signal SIGSTOP to server 1.
62 --exec kill -19 $server_pid
63
64
65 --echo
66 --echo ############################################################
67 --echo # 2. Wait until group expel server 1.
68 --let $rpl_connection_name= server2
69 --source include/rpl_connection.inc
70 --let $group_replication_number_of_members= 2
71 --source include/gr_wait_for_number_of_members.inc
72
73 --let $rpl_connection_name= server3
74 --source include/rpl_connection.inc
75 --let $group_replication_number_of_members= 2
76 --source include/gr_wait_for_number_of_members.inc
77
78
79 --echo
80 --echo ############################################################
81 --echo # 3. Resume server 1 by sending a signal SIGCONT to it.
82 --echo # Server will notice that was expelled from the group,
83 --echo # will change to ERROR state and enabled super_read_only
84 --echo # mode.
85 --let $rpl_connection_name= server1
86 --source include/rpl_connection.inc
87 --echo # Send signal SIGCONT to server 1.
88 --exec kill -18 $server_pid
89
90 --let $group_replication_member_state= ERROR
91 --source include/gr_wait_for_member_state.inc
92
93 --let $group_replication_number_of_members= 1
94 --source include/gr_wait_for_number_of_members.inc
95
96 --let $wait_condition= SELECT @@GLOBAL.super_read_only = '1'
97 --source include/wait_condition.inc
98
99 --error ER_OPTION_PREVENTS_STATEMENT
100 CREATE TABLE te (c1 INT NOT NULL PRIMARY KEY);
101
102
103 --echo
104 --echo ############################################################
105 --echo # 4. Stop and start server 1, it will be back to normal.
106 --source include/stop_group_replication.inc
107 --source include/start_group_replication.inc
108
109 CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY);
110 INSERT INTO t1 VALUES (1);
111 --source include/rpl_sync.inc
112
113
114 --echo
115 --echo ############################################################
116 --echo # 5. Check data.
117 --let $assert_text= 'There is a value 1 in table t1'
118 --let $assert_cond= [SELECT COUNT(*) AS count FROM t1 WHERE t1.c1 = 1, count, 1] = 1
119 --source include/assert.inc
120
121 --let $diff_tables= server1:test.t1, server2:test.t1, server3:test.t1
122 --source include/diff_tables.inc
123
124
125 --echo
126 --echo ############################################################
127 --echo # 6. Clean up.
128 DROP TABLE t1;
129 --source include/group_replication_end.inc