Debian Codegraph @

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

raw
1 ################################################################################
2 # Verify that when Group Replication is used, on server
3 # start the certifier's sequence number is loaded from the
4 # relay log (already certified transactions, if any) and from
5 # GTID_EXECUTED (applied transactions).
6 #
7 # Test:
8 # 0. The test requires two servers: M1 and M2.
9 # 1. Bootstrap start group on M1. Start GR on M2. Stop applier thread on M2.
10 # Create table and insert some data on M1.
11 # 2. Wait until M2 receives and certify the transactions. Restart server M2.
12 # Verify that certifier sequence number is set from relay log certified
13 # transactions and view change transactions.
14 # Set DEBUG point and start GR on M2.
15 # 3. On M2, try to insert duplicate entry. It must fail with duplicate entry.
16 # Insert non duplicate entry. It must pass.
17 # 4. Kill M2 again and verify that certifier sequence number is set from
18 # GTID_EXECUTED. Set DEBUG point and start GR on M2.
19 # 5. Shutdown.
20 ################################################################################
21 # This test does crashes servers, thence we skip it on valgrind.
22 --source include/not_valgrind.inc
23 --source include/have_debug.inc
24 --source include/have_debug_sync.inc
25 --source include/force_restart.inc
26 --let $group_replication_group_name= 8a94f357-aab4-11df-86ab-c80aa9429576
27 --source include/have_group_replication_plugin.inc
28
29 --let $use_gtids=1
30 --let $wait_for_executed_gtid_set=1
31
32 --echo ############################################################
33 --echo # 1. Start servers, on which server2 has applier stopped so
34 --echo # that all remote transactions are only queued on relay log.
35 --echo # Execute some transactions on server1.
36 --connection server1
37 --source include/start_and_bootstrap_group_replication.inc
38
39 set session sql_log_bin=0;
40 call mtr.add_suppression("The member lost contact with a majority of the members in the group. Until the network is restored.*");
41 call mtr.add_suppression("The member resumed contact with a majority of the members in the group.*");
42 set session sql_log_bin=1;
43
44 --connection server2
45 SET SESSION sql_log_bin = 0;
46 call mtr.add_suppression("Replica SQL for channel 'group_replication_applier': Relay log read failure: Could not parse relay log event entry.*");
47 call mtr.add_suppression("The applier thread execution was aborted. Unable to process more transactions, this member will now leave the group.");
48 call mtr.add_suppression("Fatal error during execution on the Applier process of Group Replication. The server will now leave the group.");
49 call mtr.add_suppression("The server was automatically set into read only mode after an error was detected.");
50 call mtr.add_suppression("Skipping leave operation: concurrent attempt to leave the group is on-going.");
51 SET SESSION sql_log_bin = 1;
52 SET @debug_saved= @@GLOBAL.DEBUG;
53 --source include/start_group_replication.inc
54 --let $member2_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)
55
56 # Do not apply certified remote transactions.
57 SET @@GLOBAL.DEBUG='+d,block_applier_updates';
58
59 --connection server1
60 --let $group_replication_number_of_members= 2
61 --source include/gr_wait_for_number_of_members.inc
62 CREATE TABLE t1 (c1 INT NOT NULL PRIMARY KEY) ENGINE=InnoDB;
63 INSERT INTO t1 VALUES (1);
64
65 --echo
66 --echo #####################################################################
67 --echo # 2. Restart server2 and verify that certifier sequence number is set
68 --echo # from relay log certified transactions and view change transactions
69 --connection server2
70 SET DEBUG_SYNC = "now WAIT_FOR applier_read_blocked";
71 # Wait until server receives and certify the transactions.
72 --let $wait_condition= SELECT (Count_transactions_checked - Count_conflicts_detected) = 2 from performance_schema.replication_group_member_stats
73 --source include/wait_condition.inc
74
75 # Force GR to stop without commit the received transactions.
76 SET @@GLOBAL.DEBUG='-d,block_applier_updates';
77 SET @@GLOBAL.DEBUG='+d,force_sql_thread_error';
78 SET DEBUG_SYNC = "now SIGNAL resume_applier_read";
79 --let $group_replication_member_state= ERROR
80 --source include/gr_wait_for_member_state.inc
81 SET @@GLOBAL.DEBUG='-d,force_sql_thread_error';
82 SET DEBUG_SYNC= 'RESET';
83
84 --let $_group_replication_local_address= `SELECT @@GLOBAL.group_replication_local_address`
85 --let $_group_replication_group_seeds= `SELECT @@GLOBAL.group_replication_group_seeds`
86 --let $restart_parameters=restart:--group_replication_local_address=$_group_replication_local_address --group_replication_group_seeds=$_group_replication_group_seeds
87 --replace_result $_group_replication_local_address GROUP_REPLICATION_LOCAL_ADDRESS $_group_replication_group_seeds GROUP_REPLICATION_GROUP_SEEDS
88 --source include/restart_mysqld.inc
89 SET @@GLOBAL.DEBUG= '+d,certifier_assert_next_seqno_equal_5';
90 --source include/start_group_replication.inc
91 SET @@GLOBAL.DEBUG= @debug_saved;
92
93 --echo ############################################################
94 --echo # 3. Insert must fail with duplicate entry.
95 --error ER_DUP_ENTRY
96 INSERT INTO t1 VALUES (1);
97
98 INSERT INTO t1 VALUES (2);
99
100 --echo
101 --echo ############################################################
102 --echo # 4. Kill server2 again and verify that certifier sequence
103 --echo # number is set from GTID_EXECUTED.
104
105 # kill server 2
106 --let $restart_parameters=restart:--group_replication_local_address=$_group_replication_local_address --group_replication_group_seeds=$_group_replication_group_seeds
107 --replace_result $_group_replication_local_address GROUP_REPLICATION_LOCAL_ADDRESS $_group_replication_group_seeds GROUP_REPLICATION_GROUP_SEEDS
108 --source include/kill_and_restart_mysqld.inc
109
110 #Needed as we are not using rpl_restart_server.inc
111 --let $rpl_connection_name= server2
112 --source include/rpl_connection.inc
113 --enable_reconnect
114
115 # Wait until group has only 1 member, that is, server2 death is detected by
116 # the group.
117 --let $rpl_connection_name= server1
118 --source include/rpl_connection.inc
119
120 --let $group_replication_member_state= UNREACHABLE
121 --let $group_replication_member_id= $member2_uuid
122 --source include/gr_wait_for_member_state.inc
123
124 # unblock the group, since server1 has gone away and
125 # there were only two in the group - majority lost
126 --let $local_address_server1= `SELECT @@GLOBAL.group_replication_local_address`
127 --disable_query_log
128 # Reseting the group to server1 only
129 --eval SET GLOBAL group_replication_force_members= "$local_address_server1"
130 --enable_query_log
131
132 --let $group_replication_number_of_members= 1
133 --source include/gr_wait_for_number_of_members.inc
134
135 --let $rpl_connection_name= server2
136 --source include/rpl_connection.inc
137 SET @@GLOBAL.DEBUG= '+d,certifier_assert_next_seqno_equal_7';
138 --source include/start_group_replication.inc
139 SET @@GLOBAL.DEBUG= @debug_saved;
140
141 --echo
142 --echo ############################################################
143 --echo # 5. Shutdown.
144
145 --connection server1
146 --let $group_replication_number_of_members= 2
147 --source include/gr_wait_for_number_of_members.inc
148 DROP TABLE t1;
149
150 --let $sync_slave_connection= server2
151 --source include/sync_slave_sql_with_master.inc
152
153 --connection server1
154 --source include/stop_group_replication.inc
155 RESET SLAVE ALL FOR CHANNEL "group_replication_applier";
156 RESET MASTER;
157
158 --connection server2
159 --source include/stop_group_replication.inc
160 RESET SLAVE ALL FOR CHANNEL "group_replication_applier";
161 RESET MASTER;
162
163 --source include/gr_clear_configuration.inc