File: monitor_progress.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (285 lines) | stat: -rw-r--r-- 9,208 bytes parent folder | download
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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
# Monitor clone operations using performance schema's stage and statement events.

--source include/have_debug.inc
--source include/have_debug_sync.inc
--source include/count_sessions.inc

# Disable PFS monitoring for threads by default
connect (con1,localhost,root,,);
CALL sys.ps_setup_disable_thread(CONNECTION_ID());

connect (con2,localhost,root,,);
CALL sys.ps_setup_disable_thread(CONNECTION_ID());

connect (con3,localhost,root,,);
CALL sys.ps_setup_disable_thread(CONNECTION_ID());

--let $CLONE_DATADIR = $MYSQL_TMP_DIR/data_new
--let $MYSQLD_DATADIR = `SELECT @@datadir`

--replace_result $CLONE_PLUGIN CLONE_PLUGIN
--eval INSTALL PLUGIN clone SONAME '$CLONE_PLUGIN'

# Enable all the required PFS instruments.
--replace_regex /[0-9]/X/
CALL sys.ps_setup_enable_instrument('%stage/innodb/clone%');
--replace_regex /[0-9]/X/
CALL sys.ps_setup_enable_instrument('statement/clone/%');

--replace_regex /[0-9]/X/
CALL sys.ps_setup_enable_consumer('events_statements%');
--replace_regex /[0-9]/X/
CALL sys.ps_setup_enable_consumer('events_stages%');

SELECT *
FROM performance_schema.setup_instruments
WHERE name LIKE "%stage/innodb/clone%"
OR name LIKE "statement/clone/%"
OR name LIKE "wait/io/file/innodb/innodb_clone_file"
ORDER BY NAME;

SELECT *
FROM performance_schema.setup_consumers
WHERE name LIKE "events_statements_%" OR name LIKE "events_stages_%"
ORDER BY NAME;

TRUNCATE TABLE performance_schema.events_stages_history;
TRUNCATE TABLE performance_schema.events_stages_history_long;
TRUNCATE TABLE performance_schema.events_statements_history;
TRUNCATE TABLE performance_schema.events_statements_history_long;

--echo # Case 1 - Monitoring a normal Clone operation.
--connection con1
CALL sys.ps_setup_enable_thread(CONNECTION_ID());
--source ../include/clone_command.inc

--replace_regex /FROM '.*'@'.*':[0-9]+ /FROM USER@HOST:PORT / /DATA DIRECTORY = '.*'/DATA DIRECTORY = '$CLONE_DATADIR'/
SELECT EVENT_NAME, TIMER_START > 0, TIMER_END > 0, TIMER_WAIT > 0,
SQL_TEXT, CURRENT_SCHEMA
FROM performance_schema.events_statements_history_long
WHERE event_name LIKE "statement/clone/%"
ORDER BY EVENT_NAME;

SELECT EVENT_NAME, TIMER_START > 0,
TIMER_END > 0, WORK_COMPLETED = WORK_ESTIMATED
FROM performance_schema.events_stages_history_long
WHERE event_name LIKE "%stage/innodb/clone%"
ORDER BY EVENT_NAME;

TRUNCATE TABLE performance_schema.events_stages_history;
TRUNCATE TABLE performance_schema.events_stages_history_long;
TRUNCATE TABLE performance_schema.events_statements_history;
TRUNCATE TABLE performance_schema.events_statements_history_long;

--force-rmdir $CLONE_DATADIR

--echo # Case 2 - Monitoring Clone operation which has more estimated work
--echo # during file and page copy stage than in a default run.

--connection con1

DELIMITER |;
CREATE PROCEDURE prepare_data(IN val INT)
BEGIN
  DECLARE i INT DEFAULT 0;

  WHILE i < val DO
    INSERT INTO t1 (b,c) VALUES (REPEAT(a,500), REPEAT(b,100));
    INSERT INTO t2 (b,c) VALUES (REPEAT(a,500), REPEAT(b,100));
    INSERT INTO t3 (b,c) VALUES (REPEAT(a,500), REPEAT(b,100));
    SET i = i + 1;
  END WHILE;
END|
DELIMITER ;|

CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b LONGBLOB, c LONGBLOB);
CREATE TABLE t2 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b LONGBLOB, c LONGBLOB);
CREATE TABLE t3 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b LONGBLOB, c LONGBLOB);

SET GLOBAL innodb_buf_flush_list_now = 1;

SET DEBUG_SYNC = 'clone_file_copy SIGNAL page_signal WAIT_FOR go_page';
SET DEBUG_SYNC = 'clone_page_copy SIGNAL redo_signal WAIT_FOR go_redo';

--source ../include/clone_command_send.inc

--connection con2
SET DEBUG_SYNC = 'now WAIT_FOR page_signal';

# Insert data in the middle of file copy to add extra pages which will
# need to be copied across during page copy.
CALL prepare_data(50);
SET GLOBAL innodb_buf_flush_list_now = 1;

SET DEBUG_SYNC = 'now SIGNAL go_page';

# Check PFS statement event and insert data in the middle of page copy
# to add extra redo chunks to be copied across during redo copy.

--connection con3
SET DEBUG_SYNC = 'now WAIT_FOR redo_signal';

--replace_regex /FROM '.*'@'.*':[0-9]+ /FROM USER@HOST:PORT / /DATA DIRECTORY = '.*'/DATA DIRECTORY = '$CLONE_DATADIR'/
SELECT EVENT_NAME, TIMER_START > 0, TIMER_END > 0, TIMER_WAIT > 0,
SQL_TEXT, CURRENT_SCHEMA
FROM performance_schema.events_statements_current
WHERE event_name LIKE "statement/clone/%"
ORDER BY EVENT_NAME;

CALL prepare_data(50);

SET DEBUG_SYNC = 'now SIGNAL go_redo';

--connection con1
--reap

# Check PFS stage and statements event in their corresponding
# history_long tables.

SELECT EVENT_NAME, WORK_COMPLETED > 0, TIMER_START > 0,
TIMER_END > 0, WORK_COMPLETED = WORK_ESTIMATED
FROM performance_schema.events_stages_history_long
WHERE event_name LIKE "%stage/innodb/clone%"
ORDER BY EVENT_NAME;

--replace_regex /FROM '.*'@'.*':[0-9]+ /FROM USER@HOST:PORT / /DATA DIRECTORY = '.*'/DATA DIRECTORY = '$CLONE_DATADIR'/
SELECT EVENT_NAME, TIMER_START > 0, TIMER_END > 0, TIMER_WAIT > 0,
SQL_TEXT, CURRENT_SCHEMA
FROM performance_schema.events_statements_history_long
WHERE thread_id = ps_thread_id(CONNECTION_ID())
AND event_name LIKE "statement/clone/%";

SET DEBUG_SYNC='RESET';

TRUNCATE TABLE performance_schema.events_stages_history;
TRUNCATE TABLE performance_schema.events_stages_history_long;
TRUNCATE TABLE performance_schema.events_statements_history;
TRUNCATE TABLE performance_schema.events_statements_history_long;

DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;

--force-rmdir $CLONE_DATADIR

--echo # Case 3 - Monitoring progress in the middle of file copy.

--connection con1
CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b INT);
CREATE TABLE t2 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b INT);
CREATE TABLE t3 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b INT);

SET DEBUG_SYNC = 'clone_file_copy SIGNAL file_signal WAIT_FOR go_file';
--source ../include/clone_command_send.inc

--connection con2
SET DEBUG_SYNC= 'now WAIT_FOR file_signal';

SELECT EVENT_NAME, WORK_COMPLETED <= WORK_ESTIMATED
FROM performance_schema.events_stages_current
WHERE event_name LIKE "%file copy%"
ORDER BY EVENT_NAME;

SET DEBUG_SYNC= 'now SIGNAL go_file';

--connection con1
--reap
SET DEBUG_SYNC = 'RESET';
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;

TRUNCATE TABLE performance_schema.events_stages_history;
TRUNCATE TABLE performance_schema.events_stages_history_long;
TRUNCATE TABLE performance_schema.events_statements_history;
TRUNCATE TABLE performance_schema.events_statements_history_long;

--force-rmdir $CLONE_DATADIR

--echo # Case 4 - Monitoring progress in the middle of page copy.
--connection con1
CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b LONGBLOB, c LONGBLOB);
CREATE TABLE t2 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b LONGBLOB, c LONGBLOB);
CREATE TABLE t3 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b LONGBLOB, c LONGBLOB);
SET GLOBAL innodb_buf_flush_list_now = 1;

SET DEBUG_SYNC = 'clone_file_copy SIGNAL page_signal WAIT_FOR go_page';
SET DEBUG_SYNC = 'clone_page_copy SIGNAL page_middle_signal WAIT_FOR go_page_middle';
--source ../include/clone_command_send.inc

--connection con2
SET DEBUG_SYNC = 'now WAIT_FOR page_signal';
CALL prepare_data(50);
SET GLOBAL innodb_buf_flush_list_now = 1;
SET DEBUG_SYNC = 'now SIGNAL go_page';

--connection con3
SET DEBUG_SYNC = 'now WAIT_FOR page_middle_signal';

SELECT EVENT_NAME, WORK_COMPLETED <= WORK_ESTIMATED
FROM performance_schema.events_stages_current
WHERE event_name LIKE "%page copy%"
ORDER BY EVENT_NAME;

SET DEBUG_SYNC = 'now SIGNAL go_page_middle';

--connection con1
--reap
SET DEBUG_SYNC = 'RESET';
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;

TRUNCATE TABLE performance_schema.events_stages_history;
TRUNCATE TABLE performance_schema.events_stages_history_long;
TRUNCATE TABLE performance_schema.events_statements_history;
TRUNCATE TABLE performance_schema.events_statements_history_long;

--force-rmdir $CLONE_DATADIR

--echo # Case 5 - Monitoring progress in the middle of redo copy.

--connection con1
CREATE TABLE t1 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b LONGBLOB, c LONGBLOB);
CREATE TABLE t2 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b LONGBLOB, c LONGBLOB);
CREATE TABLE t3 (a INT NOT NULL PRIMARY KEY AUTO_INCREMENT, b LONGBLOB, c LONGBLOB);

SET DEBUG_SYNC = 'clone_page_copy SIGNAL redo_signal WAIT_FOR go_redo';
SET DEBUG_SYNC = 'clone_redo_copy SIGNAL redo_middle_signal WAIT_FOR go_redo_middle';
--source ../include/clone_command_send.inc

--connection con2
SET DEBUG_SYNC= 'now WAIT_FOR redo_signal';

CALL prepare_data(50);
SET DEBUG_SYNC= 'now SIGNAL go_redo';

--connection con3
SET DEBUG_SYNC = 'now WAIT_FOR redo_middle_signal';

SELECT EVENT_NAME, WORK_COMPLETED <= WORK_ESTIMATED
FROM performance_schema.events_stages_current
WHERE event_name LIKE "%redo copy%"
ORDER BY EVENT_NAME;

SET DEBUG_SYNC = 'now SIGNAL go_redo_middle';
--connection con1
--reap
SET DEBUG_SYNC = 'RESET';
DROP PROCEDURE prepare_data;

USE test;
DROP TABLE t1;
DROP TABLE t2;
DROP TABLE t3;

--connection default

--force-rmdir $CLONE_DATADIR
UNINSTALL PLUGIN clone;

--disconnect con1
--disconnect con2
--disconnect con3

--source include/wait_until_count_sessions.inc