-
Notifications
You must be signed in to change notification settings - Fork 3.7k
/
gr_check_stage_values_correctness.test
188 lines (145 loc) · 9.16 KB
/
gr_check_stage_values_correctness.test
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
################################################################################
# Validate the behaviour of Group Replication stage events.
#
# Test:
# 01. GR Stage events are present when GR is running.
# 02. GR Stage events are cleaned on STOP GR.
# 03. Create some data on server1.
# Recovery channel will have some data on server2.
# 04. Start GR on server2 and block it in recovery.
# Applier is suspended while recovery is executing.
# Stage events are updated.
# 05. Lock table t1 to block recovery during state transfer.
# Applier is suspended while recovery is transferring state.
# Stage events are updated.
# 06. Block recovery before it terminates.
# Applier is executing while recovery is cleaning stage events.
# 07. Wait for server2 to be ONLINE.
# Applier is executing while recovery data from tables is cleaned.
# 08. Cleanup.
################################################################################
--source include/have_debug_sync.inc
--source include/have_group_replication_plugin.inc
--source include/group_replication.inc
CREATE TABLE test.t1 (a INT PRIMARY KEY);
--source include/rpl_sync.inc
--echo
--echo # 01. GR Stage events are present when GR is running.
--echo
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
--let $member2_uuid= query_get_value(SELECT @@SERVER_UUID, @@SERVER_UUID, 1)
--let $assert_text= Group replication applier executing is present in events_stages_current table.
--let $assert_cond= [SELECT COUNT(*) FROM performance_schema.events_stages_current WHERE event_name LIKE "stage/group_rpl/Group Replication Module: Executing" AND source LIKE "applier%"] = 1
--source include/assert.inc
--let $assert_text= Group replication applier thread is present in threads table.
--let $assert_cond= [SELECT COUNT(*) FROM performance_schema.threads WHERE name LIKE "thread/group_rpl/THD_applier_module_receiver" AND processlist_state LIKE "Group Replication Module: Executing"] = 1
--source include/assert.inc
--let $assert_text= Group replication recovery is not present in events_stages_current table.
--let $assert_cond= [SELECT COUNT(*) FROM performance_schema.events_stages_current WHERE event_name LIKE "stage/group_rpl/Group Replication Module:%" AND source LIKE "recovery%"] = 0
--source include/assert.inc
--let $assert_text= Group replication recovery thread is not present in threads table.
--let $assert_cond= [SELECT COUNT(*) FROM performance_schema.threads WHERE name LIKE "thread/group_rpl/THD_recovery"] = 0
--source include/assert.inc
--echo
--echo # 02. GR Stage events are cleaned on STOP GR.
--echo
--source include/stop_group_replication.inc
--let $assert_text= No group replication entries are present in events_stages_current table.
--let $assert_cond= [SELECT COUNT(*) FROM performance_schema.events_stages_current WHERE event_name LIKE "%/group_rpl/%"] = 0
--source include/assert.inc
--let $assert_text= 2 group replication entries are present in threads table.
--let $assert_cond= [SELECT COUNT(*) FROM performance_schema.threads WHERE name LIKE "%/group_rpl/%"] = 2
--source include/assert.inc
--let $assert_text= THD_mysql_thread_handler* are present in threads table.
--let $assert_cond= [SELECT COUNT(*) FROM performance_schema.threads WHERE name LIKE "%/group_rpl/THD_mysql_thread%"] = 2
--source include/assert.inc
--echo
--echo # 03. Create some data on server1.
--echo # Recovery channel will have some data on server2.
--echo
--let $rpl_connection_name= server1
--source include/rpl_connection.inc
INSERT INTO test.t1 values (1);
--let $rpl_connection_name= server2
--source include/rpl_connection.inc
SET @debug_save_2= @@GLOBAL.DEBUG;
SET @@GLOBAL.DEBUG='+d,recovery_thread_start_wait';
SET @@GLOBAL.DEBUG='+d,recovery_thread_wait_before_cleanup';
--echo
--echo # 04. Start GR on server2 and block it in recovery.
--echo # Applier is suspended while recovery is executing.
--echo # Stage events are updated.
--echo
--let $group_replication_start_member_state= RECOVERING
--source include/start_group_replication.inc
--echo Suspending state of applier is visible in events_stages_current table.
--let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.events_stages_current WHERE event_name LIKE "stage/group_rpl/Group Replication Module: Suspending" AND source LIKE "applier%"
--source include/wait_condition_or_abort.inc
--echo Suspending state of applier is visible in threads table.
--let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.threads WHERE name LIKE "thread/group_rpl/THD_applier_module_receiver" AND processlist_state LIKE "Group Replication Module: Suspending"
--source include/wait_condition_or_abort.inc
--echo Executing state of recovery is visible in events_stages_current table.
--let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.events_stages_current WHERE event_name LIKE "stage/group_rpl/Group Replication Module: Executing" AND source LIKE "recovery%"
--source include/wait_condition_or_abort.inc
--echo Executing state of recovery is visible in threads table.
--let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.threads WHERE name LIKE "thread/group_rpl/THD_recovery" AND processlist_state LIKE "Group Replication Module: Executing"
--source include/wait_condition_or_abort.inc
--echo
--echo # 05. Lock table t1 to block recovery during state transfer.
--echo # Applier is suspended while recovery is transferring state.
--echo # Stage events are updated.
--echo
LOCK TABLE test.t1 READ;
SET DEBUG_SYNC= "now SIGNAL signal.recovery_continue";
--echo Transferring state from donor state of recovery is visible in events_stages_current table.
--let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.events_stages_current WHERE event_name LIKE "stage/group_rpl/Group Replication Recovery: Transferring state from donor"
--source include/wait_condition.inc
--echo Suspending state of applier is visible in events_stages_current table.
--let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.events_stages_current WHERE event_name LIKE "stage/group_rpl/Group Replication Module: Suspending" AND source LIKE "applier%"
--source include/wait_condition.inc
UNLOCK TABLES;
--echo
--echo # 06. Block recovery before it terminates.
--echo # Applier is executing while recovery is cleaning stage events.
--echo
--echo mysql_end_stage has removed recovery entry in events_stages_current table.
--let $wait_condition= SELECT COUNT(*)=0 FROM performance_schema.events_stages_current WHERE event_name LIKE "stage/group_rpl/Group Replication Module: Executing" AND source LIKE "recovery%"
--source include/wait_condition_or_abort.inc
# Recovery is blocked in recovery_thread_wait_before_cleanup, so thd has not been cleaned up.
# Its taking time to reflect changes in threads table so use wait_condition.
--echo mysql_end_stage has cleared recovery state in threads table.
--let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.threads WHERE name LIKE "thread/group_rpl/THD_recovery" AND processlist_state IS NULL
--source include/wait_condition_or_abort.inc
--echo Executing state of applier is visible in events_stages_current table.
--let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.events_stages_current WHERE event_name LIKE "stage/group_rpl/Group Replication Module: Executing" AND source LIKE "applier%"
--source include/wait_condition_or_abort.inc
--echo Executing state of applier is visible in threads table.
--let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.threads WHERE name LIKE "thread/group_rpl/THD_applier_module_receiver" AND processlist_state LIKE "Group Replication Module: Executing"
--source include/wait_condition_or_abort.inc
SET DEBUG_SYNC= "now SIGNAL signal.recovery_end_end";
--echo
--echo # 07. Wait for server2 to be ONLINE.
--echo # Applier is executing while recovery data from tables is cleaned.
--echo
--let $group_replication_member_state= ONLINE
--let $group_replication_member_id= $member2_uuid
--source include/gr_wait_for_member_state.inc
--echo Executing state of applier is visible in events_stages_current table.
--let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.events_stages_current WHERE event_name LIKE "stage/group_rpl/Group Replication Module: Executing" AND source LIKE "applier%"
--source include/wait_condition_or_abort.inc
--echo Executing state of applier is visible in threads table.
--let $wait_condition= SELECT COUNT(*)=1 FROM performance_schema.threads WHERE name LIKE "thread/group_rpl/THD_applier_module_receiver" AND processlist_state LIKE "Group Replication Module: Executing"
--source include/wait_condition_or_abort.inc
--echo Recovery thread is not visible in events_stages_current table.
--let $wait_condition= SELECT COUNT(*)=0 FROM performance_schema.events_stages_current WHERE event_name LIKE "stage/group_rpl/Group Replication Module: Executing" AND source LIKE "recovery%"
--source include/wait_condition_or_abort.inc
--echo Recovery thread is not visible in threads table.
--let $wait_condition= SELECT COUNT(*)=0 FROM performance_schema.threads WHERE name LIKE "thread/group_rpl/THD_recovery"
--source include/wait_condition_or_abort.inc
--echo
--echo # 08. Cleanup.
--echo
SET @@GLOBAL.DEBUG= @debug_save_2;
DROP TABLE test.t1;
--source include/group_replication_end.inc