Debian Codegraph @

mysql-test/suite/clone/t/monitor_progress.test

raw
1 # Monitor clone operations using performance schema's stage and statement events.
2
3 --source include/have_debug.inc
4 --source include/have_debug_sync.inc
5 --source include/count_sessions.inc
6
7 # Disable PFS monitoring for threads by default
8 connect (con1,localhost,root,,);
9 CALL sys.ps_setup_disable_thread(CONNECTION_ID());
10
11 connect (con2,localhost,root,,);
12 CALL sys.ps_setup_disable_thread(CONNECTION_ID());
13
14 connect (con3,localhost,root,,);
15 CALL sys.ps_setup_disable_thread(CONNECTION_ID());
16
17 --let $CLONE_DATADIR = $MYSQL_TMP_DIR/data_new
18 --let $MYSQLD_DATADIR = `SELECT @@datadir`
19
20 --replace_result $CLONE_PLUGIN CLONE_PLUGIN
21 --eval INSTALL PLUGIN clone SONAME '$CLONE_PLUGIN'
22
23 # Enable all the required PFS instruments.
24 --replace_regex /[0-9]/X/
25 CALL sys.ps_setup_enable_instrument('%stage/innodb/clone%');
26 --replace_regex /[0-9]/X/
27 CALL sys.ps_setup_enable_instrument('statement/clone/%');
28
29 --replace_regex /[0-9]/X/
30 CALL sys.ps_setup_enable_consumer('events_statements%');
31 --replace_regex /[0-9]/X/
32 CALL sys.ps_setup_enable_consumer('events_stages%');
33
34 SELECT *
35 FROM performance_schema.setup_instruments
36 WHERE name LIKE "%stage/innodb/clone%"
37 OR name LIKE "statement/clone/%"
38 OR name LIKE "wait/io/file/innodb/innodb_clone_file"
39 ORDER BY NAME;
40
41 SELECT *
42 FROM performance_schema.setup_consumers
43 WHERE name LIKE "events_statements_%" OR name LIKE "events_stages_%"
44 ORDER BY NAME;
45
46 TRUNCATE TABLE performance_schema.events_stages_history;
47 TRUNCATE TABLE performance_schema.events_stages_history_long;
48 TRUNCATE TABLE performance_schema.events_statements_history;
49 TRUNCATE TABLE performance_schema.events_statements_history_long;
50
51 --echo # Case 1 - Monitoring a normal Clone operation.
52 --connection con1
53 CALL sys.ps_setup_enable_thread(CONNECTION_ID());
54 --source ../include/clone_command.inc
55
56 --replace_regex /FROM '.*'@'.*':[0-9]+ /FROM USER@HOST:PORT / /DATA DIRECTORY = '.*'/DATA DIRECTORY = '$CLONE_DATADIR'/
57 SELECT EVENT_NAME, TIMER_START > 0, TIMER_END > 0, TIMER_WAIT > 0,
58 SQL_TEXT, CURRENT_SCHEMA
59 FROM performance_schema.events_statements_history_long
60 WHERE event_name LIKE "statement/clone/%"
61 ORDER BY EVENT_NAME;
62
63 SELECT EVENT_NAME, TIMER_START > 0,
64 TIMER_END > 0, WORK_COMPLETED = WORK_ESTIMATED
65 FROM performance_schema.events_stages_history_long
66 WHERE event_name LIKE "%stage/innodb/clone%"
67 ORDER BY EVENT_NAME;
68
69 TRUNCATE TABLE performance_schema.events_stages_history;
70 TRUNCATE TABLE performance_schema.events_stages_history_long;
71 TRUNCATE TABLE performance_schema.events_statements_history;
72 TRUNCATE TABLE performance_schema.events_statements_history_long;
73
74 --force-rmdir $CLONE_DATADIR
75
76 --echo # Case 2 - Monitoring Clone operation which has more estimated work
77 --echo # during file and page copy stage than in a default run.
78
79 --connection con1
80
81 DELIMITER |;
82 CREATE PROCEDURE prepare_data(IN val INT)
83 BEGIN
84 DECLARE i INT DEFAULT 0;
85
86 WHILE i < val DO
87 INSERT INTO t1 (b,c) VALUES (REPEAT(a,500), REPEAT(b,100));
88 INSERT INTO t2 (b,c) VALUES (REPEAT(a,500), REPEAT(b,100));
89 INSERT INTO t3 (b,c) VALUES (REPEAT(a,500), REPEAT(b,100));
90 SET i = i + 1;
91 END WHILE;
92 END|
93 DELIMITER ;|
94
95 CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b LONGBLOB, c LONGBLOB);
96 CREATE TABLE t2 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b LONGBLOB, c LONGBLOB);
97 CREATE TABLE t3 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b LONGBLOB, c LONGBLOB);
98
99 SET GLOBAL innodb_buf_flush_list_now = 1;
100
101 SET DEBUG_SYNC = 'clone_file_copy SIGNAL page_signal WAIT_FOR go_page';
102 SET DEBUG_SYNC = 'clone_page_copy SIGNAL redo_signal WAIT_FOR go_redo';
103
104 --source ../include/clone_command_send.inc
105
106 --connection con2
107 SET DEBUG_SYNC = 'now WAIT_FOR page_signal';
108
109 # Insert data in the middle of file copy to add extra pages which will
110 # need to be copied across during page copy.
111 CALL prepare_data(50);
112 SET GLOBAL innodb_buf_flush_list_now = 1;
113
114 SET DEBUG_SYNC = 'now SIGNAL go_page';
115
116 # Check PFS statement event and insert data in the middle of page copy
117 # to add extra redo chunks to be copied across during redo copy.
118
119 --connection con3
120 SET DEBUG_SYNC = 'now WAIT_FOR redo_signal';
121
122 --replace_regex /FROM '.*'@'.*':[0-9]+ /FROM USER@HOST:PORT / /DATA DIRECTORY = '.*'/DATA DIRECTORY = '$CLONE_DATADIR'/
123 SELECT EVENT_NAME, TIMER_START > 0, TIMER_END > 0, TIMER_WAIT > 0,
124 SQL_TEXT, CURRENT_SCHEMA
125 FROM performance_schema.events_statements_current
126 WHERE event_name LIKE "statement/clone/%"
127 ORDER BY EVENT_NAME;
128
129 CALL prepare_data(50);
130
131 SET DEBUG_SYNC = 'now SIGNAL go_redo';
132
133 --connection con1
134 --reap
135
136 # Check PFS stage and statements event in their corresponding
137 # history_long tables.
138
139 SELECT EVENT_NAME, WORK_COMPLETED > 0, TIMER_START > 0,
140 TIMER_END > 0, WORK_COMPLETED = WORK_ESTIMATED
141 FROM performance_schema.events_stages_history_long
142 WHERE event_name LIKE "%stage/innodb/clone%"
143 ORDER BY EVENT_NAME;
144
145 --replace_regex /FROM '.*'@'.*':[0-9]+ /FROM USER@HOST:PORT / /DATA DIRECTORY = '.*'/DATA DIRECTORY = '$CLONE_DATADIR'/
146 SELECT EVENT_NAME, TIMER_START > 0, TIMER_END > 0, TIMER_WAIT > 0,
147 SQL_TEXT, CURRENT_SCHEMA
148 FROM performance_schema.events_statements_history_long
149 WHERE thread_id = ps_thread_id(CONNECTION_ID())
150 AND event_name LIKE "statement/clone/%";
151
152 SET DEBUG_SYNC='RESET';
153
154 TRUNCATE TABLE performance_schema.events_stages_history;
155 TRUNCATE TABLE performance_schema.events_stages_history_long;
156 TRUNCATE TABLE performance_schema.events_statements_history;
157 TRUNCATE TABLE performance_schema.events_statements_history_long;
158
159 DROP TABLE t1;
160 DROP TABLE t2;
161 DROP TABLE t3;
162
163 --force-rmdir $CLONE_DATADIR
164
165 --echo # Case 3 - Monitoring progress in the middle of file copy.
166
167 --connection con1
168 CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b INT);
169 CREATE TABLE t2 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b INT);
170 CREATE TABLE t3 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b INT);
171
172 SET DEBUG_SYNC = 'clone_file_copy SIGNAL file_signal WAIT_FOR go_file';
173 --source ../include/clone_command_send.inc
174
175 --connection con2
176 SET DEBUG_SYNC= 'now WAIT_FOR file_signal';
177
178 SELECT EVENT_NAME, WORK_COMPLETED <= WORK_ESTIMATED
179 FROM performance_schema.events_stages_current
180 WHERE event_name LIKE "%file copy%"
181 ORDER BY EVENT_NAME;
182
183 SET DEBUG_SYNC= 'now SIGNAL go_file';
184
185 --connection con1
186 --reap
187 SET DEBUG_SYNC = 'RESET';
188 DROP TABLE t1;
189 DROP TABLE t2;
190 DROP TABLE t3;
191
192 TRUNCATE TABLE performance_schema.events_stages_history;
193 TRUNCATE TABLE performance_schema.events_stages_history_long;
194 TRUNCATE TABLE performance_schema.events_statements_history;
195 TRUNCATE TABLE performance_schema.events_statements_history_long;
196
197 --force-rmdir $CLONE_DATADIR
198
199 --echo # Case 4 - Monitoring progress in the middle of page copy.
200 --connection con1
201 CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b LONGBLOB, c LONGBLOB);
202 CREATE TABLE t2 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b LONGBLOB, c LONGBLOB);
203 CREATE TABLE t3 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b LONGBLOB, c LONGBLOB);
204 SET GLOBAL innodb_buf_flush_list_now = 1;
205
206 SET DEBUG_SYNC = 'clone_file_copy SIGNAL page_signal WAIT_FOR go_page';
207 SET DEBUG_SYNC = 'clone_page_copy SIGNAL page_middle_signal WAIT_FOR go_page_middle';
208 --source ../include/clone_command_send.inc
209
210 --connection con2
211 SET DEBUG_SYNC = 'now WAIT_FOR page_signal';
212 CALL prepare_data(50);
213 SET GLOBAL innodb_buf_flush_list_now = 1;
214 SET DEBUG_SYNC = 'now SIGNAL go_page';
215
216 --connection con3
217 SET DEBUG_SYNC = 'now WAIT_FOR page_middle_signal';
218
219 SELECT EVENT_NAME, WORK_COMPLETED <= WORK_ESTIMATED
220 FROM performance_schema.events_stages_current
221 WHERE event_name LIKE "%page copy%"
222 ORDER BY EVENT_NAME;
223
224 SET DEBUG_SYNC = 'now SIGNAL go_page_middle';
225
226 --connection con1
227 --reap
228 SET DEBUG_SYNC = 'RESET';
229 DROP TABLE t1;
230 DROP TABLE t2;
231 DROP TABLE t3;
232
233 TRUNCATE TABLE performance_schema.events_stages_history;
234 TRUNCATE TABLE performance_schema.events_stages_history_long;
235 TRUNCATE TABLE performance_schema.events_statements_history;
236 TRUNCATE TABLE performance_schema.events_statements_history_long;
237
238 --force-rmdir $CLONE_DATADIR
239
240 --echo # Case 5 - Monitoring progress in the middle of redo copy.
241
242 --connection con1
243 CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b LONGBLOB, c LONGBLOB);
244 CREATE TABLE t2 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b LONGBLOB, c LONGBLOB);
245 CREATE TABLE t3 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b LONGBLOB, c LONGBLOB);
246
247 SET DEBUG_SYNC = 'clone_page_copy SIGNAL redo_signal WAIT_FOR go_redo';
248 SET DEBUG_SYNC = 'clone_redo_copy SIGNAL redo_middle_signal WAIT_FOR go_redo_middle';
249 --source ../include/clone_command_send.inc
250
251 --connection con2
252 SET DEBUG_SYNC= 'now WAIT_FOR redo_signal';
253
254 CALL prepare_data(50);
255 SET DEBUG_SYNC= 'now SIGNAL go_redo';
256
257 --connection con3
258 SET DEBUG_SYNC = 'now WAIT_FOR redo_middle_signal';
259
260 SELECT EVENT_NAME, WORK_COMPLETED <= WORK_ESTIMATED
261 FROM performance_schema.events_stages_current
262 WHERE event_name LIKE "%redo copy%"
263 ORDER BY EVENT_NAME;
264
265 SET DEBUG_SYNC = 'now SIGNAL go_redo_middle';
266 --connection con1
267 --reap
268 SET DEBUG_SYNC = 'RESET';
269 DROP PROCEDURE prepare_data;
270
271 USE test;
272 DROP TABLE t1;
273 DROP TABLE t2;
274 DROP TABLE t3;
275
276 --connection default
277
278 --force-rmdir $CLONE_DATADIR
279 UNINSTALL PLUGIN clone;
280
281 --disconnect con1
282 --disconnect con2
283 --disconnect con3
284
285 --source include/wait_until_count_sessions.inc