Debian Codegraph @

storage/innobase/srv/srv0mon.cc

raw
1 /*****************************************************************************
2
3 Copyright (c) 2010, 2026, Oracle and/or its affiliates.
4 Copyright (c) 2012, Facebook Inc.
5
6 This program is free software; you can redistribute it and/or modify it under
7 the terms of the GNU General Public License, version 2.0, as published by the
8 Free Software Foundation.
9
10 This program is designed to work with certain software (including
11 but not limited to OpenSSL) that is licensed under separate terms,
12 as designated in a particular file or component or in included license
13 documentation. The authors of MySQL hereby grant you an additional
14 permission to link the program and your derivative works with the
15 separately licensed software that they have either included with
16 the program or referenced in the documentation.
17
18 This program is distributed in the hope that it will be useful, but WITHOUT
19 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
20 FOR A PARTICULAR PURPOSE. See the GNU General Public License, version 2.0,
21 for more details.
22
23 You should have received a copy of the GNU General Public License along with
24 this program; if not, write to the Free Software Foundation, Inc.,
25 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
26
27 *****************************************************************************/
28
29 /** @file srv/srv0mon.cc
30 Database monitor counter interfaces
31
32 Created 12/9/2009 Jimmy Yang
33 *******************************************************/
34
35 #include <time.h>
36
37 #include "arch0arch.h"
38 #include "buf0buf.h"
39 #include "dict0mem.h"
40 #include "ibuf0ibuf.h"
41 #include "lock0lock.h"
42 #include "log0buf.h"
43 #include "log0chkp.h"
44 #include "log0write.h"
45 #include "mach0data.h"
46 #include "os0file.h"
47 #include "srv0mon.h"
48 #include "srv0srv.h"
49 #include "trx0purge.h"
50 #include "trx0rseg.h"
51 #include "trx0sys.h"
52
53 /* Macro to standardize the counter names for counters in the
54 "monitor_buf_page" module as they have very structured defines */
55 #define MONITOR_BUF_PAGE(name, description, code, op, op_code) \
56 { \
57 "buffer_page_" op "_" name, "buffer_page_io", \
58 "Number of " description " Pages " op, MONITOR_GROUP_MODULE, \
59 MONITOR_DEFAULT_START, MONITOR_##code##_##op_code \
60 }
61
62 #define MONITOR_BUF_PAGE_READ(name, description, code) \
63 MONITOR_BUF_PAGE(name, description, code, "read", PAGE_READ)
64
65 #define MONITOR_BUF_PAGE_WRITTEN(name, description, code) \
66 MONITOR_BUF_PAGE(name, description, code, "written", PAGE_WRITTEN)
67
68 #define MONITOR_WAIT_STATS_EX(name, module, description, code, wrap) \
69 wrap(name "no_waits", module, description, MONITOR_NONE, \
70 MONITOR_DEFAULT_START, code##NO_WAITS), \
71 wrap(name "waits", module, description, MONITOR_NONE, \
72 MONITOR_DEFAULT_START, code##WAITS), \
73 wrap(name "wait_loops", module, description, MONITOR_NONE, \
74 MONITOR_DEFAULT_START, code##WAIT_LOOPS)
75
76 #define MONITOR_WAIT_STATS_SIMPLE_WRAP(a1, a2, a3, a4, a5, a6) \
77 { a1, a2, a3, a4, a5, a6 }
78
79 #define MONITOR_WAIT_STATS(name, module, description, code) \
80 MONITOR_WAIT_STATS_EX(name, module, description, code, \
81 MONITOR_WAIT_STATS_SIMPLE_WRAP)
82
83 #define MONITOR_BUF_PAGE_WRITTEN_WAIT_STATS_WRAP(name, module, description, a, \
84 b, code) \
85 MONITOR_BUF_PAGE_WRITTEN(name, description, code)
86
87 #define MONITOR_BUF_PAGE_WRITTEN_WAIT_STATS(name, description, code) \
88 MONITOR_WAIT_STATS_EX(name, "", description, code, \
89 MONITOR_BUF_PAGE_WRITTEN_WAIT_STATS_WRAP)
90
91 /** This array defines basic static information of monitor counters,
92 including each monitor's name, module it belongs to, a short
93 description and its property/type and corresponding monitor_id.
94 Please note: If you add a monitor here, please add its corresponding
95 monitor_id to "enum monitor_id_value" structure in srv0mon.h file. */
96
97 static monitor_info_t innodb_counter_info[] = {
98 /* A dummy item to mark the module start, this is
99 to accommodate the default value (0) set for the
100 global variables with the control system. */
101 {"module_start", "module_start", "module_start", MONITOR_MODULE,
102 MONITOR_DEFAULT_START, MONITOR_DEFAULT_START},
103
104 /* ========== Counters for Server Metadata ========== */
105 {"module_metadata", "metadata", "Server Metadata", MONITOR_MODULE,
106 MONITOR_DEFAULT_START, MONITOR_MODULE_METADATA},
107
108 {"metadata_table_handles_opened", "metadata",
109 "Number of table handles opened", MONITOR_NONE, MONITOR_DEFAULT_START,
110 MONITOR_TABLE_OPEN},
111
112 {"metadata_table_handles_closed", "metadata",
113 "Number of table handles closed", MONITOR_NONE, MONITOR_DEFAULT_START,
114 MONITOR_TABLE_CLOSE},
115
116 {"metadata_table_reference_count", "metadata", "Table reference counter",
117 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_TABLE_REFERENCE},
118
119 /* ========== Counters for Lock Module ========== */
120 {"module_lock", "lock", "Lock Module", MONITOR_MODULE,
121 MONITOR_DEFAULT_START, MONITOR_MODULE_LOCK},
122
123 {"lock_deadlocks", "lock", "Number of deadlocks", MONITOR_DEFAULT_ON,
124 MONITOR_DEFAULT_START, MONITOR_DEADLOCK},
125
126 {"lock_deadlock_false_positives", "lock",
127 "Number of times a heuristic found a spurious candidate deadlock cycle in "
128 "the wait-for graph",
129 MONITOR_DEFAULT_ON, MONITOR_DEFAULT_START,
130 MONITOR_DEADLOCK_FALSE_POSITIVES},
131
132 {"lock_deadlock_rounds", "lock",
133 "Number of times a wait-for graph was scanned in search for deadlocks",
134 MONITOR_DEFAULT_ON, MONITOR_DEFAULT_START, MONITOR_DEADLOCK_ROUNDS},
135
136 {"lock_threads_waiting", "lock",
137 "Number of query threads sleeping waiting for a lock",
138 static_cast<monitor_type_t>(MONITOR_DEFAULT_ON | MONITOR_DISPLAY_CURRENT),
139 MONITOR_DEFAULT_START, MONITOR_LOCK_THREADS_WAITING},
140
141 {"lock_timeouts", "lock", "Number of lock timeouts", MONITOR_DEFAULT_ON,
142 MONITOR_DEFAULT_START, MONITOR_TIMEOUT},
143
144 {"lock_rec_lock_waits", "lock",
145 "Number of times enqueued into record lock wait queue", MONITOR_NONE,
146 MONITOR_DEFAULT_START, MONITOR_LOCKREC_WAIT},
147
148 {"lock_table_lock_waits", "lock",
149 "Number of times enqueued into table lock wait queue", MONITOR_NONE,
150 MONITOR_DEFAULT_START, MONITOR_TABLELOCK_WAIT},
151
152 {"lock_rec_lock_requests", "lock", "Number of record locks requested",
153 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_NUM_RECLOCK_REQ},
154
155 {"lock_rec_release_attempts", "lock",
156 "Number of times we attempted to release record locks", MONITOR_DEFAULT_ON,
157 MONITOR_DEFAULT_START, MONITOR_RECLOCK_RELEASE_ATTEMPTS},
158
159 {"lock_rec_grant_attempts", "lock",
160 "Number of times we attempted to grant locks for a record",
161 MONITOR_DEFAULT_ON, MONITOR_DEFAULT_START, MONITOR_RECLOCK_GRANT_ATTEMPTS},
162
163 {"lock_rec_lock_created", "lock", "Number of record locks created",
164 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_RECLOCK_CREATED},
165
166 {"lock_rec_lock_removed", "lock",
167 "Number of record locks removed from the lock queue", MONITOR_NONE,
168 MONITOR_DEFAULT_START, MONITOR_RECLOCK_REMOVED},
169
170 {"lock_rec_locks", "lock", "Current number of record locks on tables",
171 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_NUM_RECLOCK},
172
173 {"lock_table_lock_created", "lock", "Number of table locks created",
174 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_TABLELOCK_CREATED},
175
176 {"lock_table_lock_removed", "lock",
177 "Number of table locks removed from the lock queue", MONITOR_NONE,
178 MONITOR_DEFAULT_START, MONITOR_TABLELOCK_REMOVED},
179
180 {"lock_table_locks", "lock", "Current number of table locks on tables",
181 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_NUM_TABLELOCK},
182
183 {"lock_row_lock_current_waits", "lock",
184 "Number of row locks currently being waited for"
185 " (innodb_row_lock_current_waits)",
186 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
187 MONITOR_DEFAULT_START, MONITOR_OVLD_ROW_LOCK_CURRENT_WAIT},
188
189 {"lock_row_lock_time", "lock",
190 "Time spent in acquiring row locks, in milliseconds"
191 " (innodb_row_lock_time)",
192 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
193 MONITOR_DEFAULT_START, MONITOR_OVLD_LOCK_WAIT_TIME},
194
195 {"lock_row_lock_time_max", "lock",
196 "The maximum time to acquire a row lock, in milliseconds"
197 " (innodb_row_lock_time_max)",
198 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DISPLAY_CURRENT |
199 MONITOR_DEFAULT_ON),
200 MONITOR_DEFAULT_START, MONITOR_OVLD_LOCK_MAX_WAIT_TIME},
201
202 {"lock_row_lock_waits", "lock",
203 "Number of times a row lock had to be waited for"
204 " (innodb_row_lock_waits)",
205 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
206 MONITOR_DEFAULT_START, MONITOR_OVLD_ROW_LOCK_WAIT},
207
208 {"lock_row_lock_time_avg", "lock",
209 "The average time to acquire a row lock, in milliseconds"
210 " (innodb_row_lock_time_avg)",
211 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DISPLAY_CURRENT |
212 MONITOR_DEFAULT_ON),
213 MONITOR_DEFAULT_START, MONITOR_OVLD_LOCK_AVG_WAIT_TIME},
214
215 {"lock_schedule_refreshes", "lock",
216 "Number of times the wait-for graph was analyzed to update schedule "
217 "weights of transactions",
218 MONITOR_DEFAULT_ON, MONITOR_DEFAULT_START, MONITOR_SCHEDULE_REFRESHES},
219
220 /* ========== Counters for Buffer Manager and I/O ========== */
221 {"module_buffer", "buffer", "Buffer Manager Module", MONITOR_MODULE,
222 MONITOR_DEFAULT_START, MONITOR_MODULE_BUFFER},
223
224 {"buffer_pool_size", "server",
225 "Server buffer pool size (all buffer pools) in bytes",
226 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON |
227 MONITOR_DISPLAY_CURRENT),
228 MONITOR_DEFAULT_START, MONITOR_OVLD_BUFFER_POOL_SIZE},
229
230 {"buffer_pool_reads", "buffer",
231 "Number of reads directly from disk (innodb_buffer_pool_reads)",
232 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
233 MONITOR_DEFAULT_START, MONITOR_OVLD_BUF_POOL_READS},
234
235 {"buffer_pool_read_requests", "buffer",
236 "Number of logical read requests (innodb_buffer_pool_read_requests)",
237 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
238 MONITOR_DEFAULT_START, MONITOR_OVLD_BUF_POOL_READ_REQUESTS},
239
240 {"buffer_pool_write_requests", "buffer",
241 "Number of write requests (innodb_buffer_pool_write_requests)",
242 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
243 MONITOR_DEFAULT_START, MONITOR_OVLD_BUF_POOL_WRITE_REQUEST},
244
245 {"buffer_pool_wait_free", "buffer",
246 "Number of times waited for free buffer"
247 " (innodb_buffer_pool_wait_free)",
248 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
249 MONITOR_DEFAULT_START, MONITOR_OVLD_BUF_POOL_WAIT_FREE},
250
251 {"buffer_pool_read_ahead", "buffer",
252 "Number of pages read as read ahead (innodb_buffer_pool_read_ahead)",
253 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
254 MONITOR_DEFAULT_START, MONITOR_OVLD_BUF_POOL_READ_AHEAD},
255
256 {"buffer_pool_read_ahead_evicted", "buffer",
257 "Read-ahead pages evicted without being accessed"
258 " (innodb_buffer_pool_read_ahead_evicted)",
259 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
260 MONITOR_DEFAULT_START, MONITOR_OVLD_BUF_POOL_READ_AHEAD_EVICTED},
261
262 {"buffer_pool_pages_total", "buffer",
263 "Total buffer pool size in pages (innodb_buffer_pool_pages_total)",
264 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DISPLAY_CURRENT |
265 MONITOR_DEFAULT_ON),
266 MONITOR_DEFAULT_START, MONITOR_OVLD_BUF_POOL_PAGE_TOTAL},
267
268 {"buffer_pool_pages_misc", "buffer",
269 "Buffer pages for misc use such as row locks or the adaptive"
270 " hash index (innodb_buffer_pool_pages_misc)",
271 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DISPLAY_CURRENT |
272 MONITOR_DEFAULT_ON),
273 MONITOR_DEFAULT_START, MONITOR_OVLD_BUF_POOL_PAGE_MISC},
274
275 {"buffer_pool_pages_data", "buffer",
276 "Buffer pages containing data (innodb_buffer_pool_pages_data)",
277 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DISPLAY_CURRENT |
278 MONITOR_DEFAULT_ON),
279 MONITOR_DEFAULT_START, MONITOR_OVLD_BUF_POOL_PAGES_DATA},
280
281 {"buffer_pool_bytes_data", "buffer",
282 "Buffer bytes containing data (innodb_buffer_pool_bytes_data)",
283 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DISPLAY_CURRENT |
284 MONITOR_DEFAULT_ON),
285 MONITOR_DEFAULT_START, MONITOR_OVLD_BUF_POOL_BYTES_DATA},
286
287 {"buffer_pool_pages_dirty", "buffer",
288 "Buffer pages currently dirty (innodb_buffer_pool_pages_dirty)",
289 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DISPLAY_CURRENT |
290 MONITOR_DEFAULT_ON),
291 MONITOR_DEFAULT_START, MONITOR_OVLD_BUF_POOL_PAGES_DIRTY},
292
293 {"buffer_pool_bytes_dirty", "buffer",
294 "Buffer bytes currently dirty (innodb_buffer_pool_bytes_dirty)",
295 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DISPLAY_CURRENT |
296 MONITOR_DEFAULT_ON),
297 MONITOR_DEFAULT_START, MONITOR_OVLD_BUF_POOL_BYTES_DIRTY},
298
299 {"buffer_pool_pages_free", "buffer",
300 "Buffer pages currently free (innodb_buffer_pool_pages_free)",
301 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DISPLAY_CURRENT |
302 MONITOR_DEFAULT_ON),
303 MONITOR_DEFAULT_START, MONITOR_OVLD_BUF_POOL_PAGES_FREE},
304
305 {"buffer_pages_created", "buffer",
306 "Number of pages created (innodb_pages_created)",
307 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
308 MONITOR_DEFAULT_START, MONITOR_OVLD_PAGE_CREATED},
309
310 {"buffer_pages_written", "buffer",
311 "Number of pages written (innodb_pages_written)",
312 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
313 MONITOR_DEFAULT_START, MONITOR_OVLD_PAGES_WRITTEN},
314
315 {"buffer_pages_read", "buffer", "Number of pages read (innodb_pages_read)",
316 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
317 MONITOR_DEFAULT_START, MONITOR_OVLD_PAGES_READ},
318
319 {"buffer_data_reads", "buffer",
320 "Amount of data read in bytes (innodb_data_reads)",
321 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
322 MONITOR_DEFAULT_START, MONITOR_OVLD_BYTE_READ},
323
324 {"buffer_data_written", "buffer",
325 "Amount of data written in bytes (innodb_data_written)",
326 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
327 MONITOR_DEFAULT_START, MONITOR_OVLD_BYTE_WRITTEN},
328
329 /* Cumulative counter for scanning in flush batches */
330 {"buffer_flush_batch_scanned", "buffer",
331 "Total pages scanned as part of flush batch", MONITOR_SET_OWNER,
332 MONITOR_FLUSH_BATCH_SCANNED_NUM_CALL, MONITOR_FLUSH_BATCH_SCANNED},
333
334 {"buffer_flush_batch_num_scan", "buffer",
335 "Number of times buffer flush list flush is called", MONITOR_SET_MEMBER,
336 MONITOR_FLUSH_BATCH_SCANNED, MONITOR_FLUSH_BATCH_SCANNED_NUM_CALL},
337
338 {"buffer_flush_batch_scanned_per_call", "buffer",
339 "Pages scanned per flush batch scan", MONITOR_SET_MEMBER,
340 MONITOR_FLUSH_BATCH_SCANNED, MONITOR_FLUSH_BATCH_SCANNED_PER_CALL},
341
342 /* Cumulative counter for pages flushed in flush batches */
343 {"buffer_flush_batch_total_pages", "buffer",
344 "Total pages flushed as part of flush batch", MONITOR_SET_OWNER,
345 MONITOR_FLUSH_BATCH_COUNT, MONITOR_FLUSH_BATCH_TOTAL_PAGE},
346
347 {"buffer_flush_batches", "buffer", "Number of flush batches",
348 MONITOR_SET_MEMBER, MONITOR_FLUSH_BATCH_TOTAL_PAGE,
349 MONITOR_FLUSH_BATCH_COUNT},
350
351 {"buffer_flush_batch_pages", "buffer", "Pages queued as a flush batch",
352 MONITOR_SET_MEMBER, MONITOR_FLUSH_BATCH_TOTAL_PAGE,
353 MONITOR_FLUSH_BATCH_PAGES},
354
355 /* Cumulative counter for flush batches because of neighbor */
356 {"buffer_flush_neighbor_total_pages", "buffer",
357 "Total neighbors flushed as part of neighbor flush", MONITOR_SET_OWNER,
358 MONITOR_FLUSH_NEIGHBOR_COUNT, MONITOR_FLUSH_NEIGHBOR_TOTAL_PAGE},
359
360 {"buffer_flush_neighbor", "buffer",
361 "Number of times neighbors flushing is invoked", MONITOR_SET_MEMBER,
362 MONITOR_FLUSH_NEIGHBOR_TOTAL_PAGE, MONITOR_FLUSH_NEIGHBOR_COUNT},
363
364 {"buffer_flush_neighbor_pages", "buffer",
365 "Pages queued as a neighbor batch", MONITOR_SET_MEMBER,
366 MONITOR_FLUSH_NEIGHBOR_TOTAL_PAGE, MONITOR_FLUSH_NEIGHBOR_PAGES},
367
368 {"buffer_flush_n_to_flush_requested", "buffer",
369 "Number of pages requested for flushing.", MONITOR_NONE,
370 MONITOR_DEFAULT_START, MONITOR_FLUSH_N_TO_FLUSH_REQUESTED},
371
372 {"buffer_flush_n_to_flush_by_dirty_page", "buffer",
373 "Number of pages targeted by dirty page percentage for flushing.",
374 MONITOR_NONE, MONITOR_DEFAULT_START,
375 MONITOR_FLUSH_N_TO_FLUSH_BY_DIRTY_PAGE},
376
377 {"buffer_flush_n_to_flush_by_age", "buffer",
378 "Number of pages targeted by LSN Age for flushing.", MONITOR_NONE,
379 MONITOR_DEFAULT_START, MONITOR_FLUSH_N_TO_FLUSH_BY_AGE},
380
381 {"buffer_flush_adaptive_avg_time_slot", "buffer",
382 "Avg time (ms) spent for adaptive flushing recently per slot.",
383 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_FLUSH_ADAPTIVE_AVG_TIME_SLOT},
384
385 {"buffer_LRU_batch_flush_avg_time_slot", "buffer",
386 "Avg time (ms) spent for LRU batch flushing recently per slot.",
387 MONITOR_NONE, MONITOR_DEFAULT_START,
388 MONITOR_LRU_BATCH_FLUSH_AVG_TIME_SLOT},
389
390 {"buffer_flush_adaptive_avg_time_thread", "buffer",
391 "Avg time (ms) spent for adaptive flushing recently per thread.",
392 MONITOR_NONE, MONITOR_DEFAULT_START,
393 MONITOR_FLUSH_ADAPTIVE_AVG_TIME_THREAD},
394
395 {"buffer_LRU_batch_flush_avg_time_thread", "buffer",
396 "Avg time (ms) spent for LRU batch flushing recently per thread.",
397 MONITOR_NONE, MONITOR_DEFAULT_START,
398 MONITOR_LRU_BATCH_FLUSH_AVG_TIME_THREAD},
399
400 {"buffer_flush_adaptive_avg_time_est", "buffer",
401 "Estimated time (ms) spent for adaptive flushing recently.", MONITOR_NONE,
402 MONITOR_DEFAULT_START, MONITOR_FLUSH_ADAPTIVE_AVG_TIME_EST},
403
404 {"buffer_LRU_batch_flush_avg_time_est", "buffer",
405 "Estimated time (ms) spent for LRU batch flushing recently.", MONITOR_NONE,
406 MONITOR_DEFAULT_START, MONITOR_LRU_BATCH_FLUSH_AVG_TIME_EST},
407
408 {"buffer_flush_avg_time", "buffer",
409 "Avg time (ms) spent for flushing recently.", MONITOR_NONE,
410 MONITOR_DEFAULT_START, MONITOR_FLUSH_AVG_TIME},
411
412 {"buffer_flush_adaptive_avg_pass", "buffer",
413 "Number of adaptive flushes passed during the recent Avg period.",
414 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_FLUSH_ADAPTIVE_AVG_PASS},
415
416 {"buffer_LRU_batch_flush_avg_pass", "buffer",
417 "Number of LRU batch flushes passed during the recent Avg period.",
418 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_LRU_BATCH_FLUSH_AVG_PASS},
419
420 {"buffer_flush_avg_pass", "buffer",
421 "Number of flushes passed during the recent Avg period.", MONITOR_NONE,
422 MONITOR_DEFAULT_START, MONITOR_FLUSH_AVG_PASS},
423
424 {"buffer_LRU_get_free_loops", "buffer", "Total loops in LRU get free.",
425 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_LRU_GET_FREE_LOOPS},
426
427 {"buffer_LRU_get_free_waits", "buffer",
428 "Total sleep waits in LRU get free.", MONITOR_NONE, MONITOR_DEFAULT_START,
429 MONITOR_LRU_GET_FREE_WAITS},
430
431 {"buffer_flush_avg_page_rate", "buffer",
432 "Average number of pages at which flushing is happening", MONITOR_NONE,
433 MONITOR_DEFAULT_START, MONITOR_FLUSH_AVG_PAGE_RATE},
434
435 {"buffer_flush_lsn_avg_rate", "buffer", "Average redo generation rate",
436 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_FLUSH_LSN_AVG_RATE},
437
438 {"buffer_flush_pct_for_dirty", "buffer",
439 "Percent of IO capacity used to avoid max dirty page limit", MONITOR_NONE,
440 MONITOR_DEFAULT_START, MONITOR_FLUSH_PCT_FOR_DIRTY},
441
442 {"buffer_flush_pct_for_lsn", "buffer",
443 "Percent of IO capacity used to avoid reusable redo space limit",
444 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_FLUSH_PCT_FOR_LSN},
445
446 {"buffer_flush_sync_waits", "buffer",
447 "Number of times a wait happens due to sync flushing", MONITOR_NONE,
448 MONITOR_DEFAULT_START, MONITOR_FLUSH_SYNC_WAITS},
449
450 /* Cumulative counter for flush batches for adaptive flushing */
451 {"buffer_flush_adaptive_total_pages", "buffer",
452 "Total pages flushed as part of adaptive flushing", MONITOR_SET_OWNER,
453 MONITOR_FLUSH_ADAPTIVE_COUNT, MONITOR_FLUSH_ADAPTIVE_TOTAL_PAGE},
454
455 {"buffer_flush_adaptive", "buffer", "Number of adaptive batches",
456 MONITOR_SET_MEMBER, MONITOR_FLUSH_ADAPTIVE_TOTAL_PAGE,
457 MONITOR_FLUSH_ADAPTIVE_COUNT},
458
459 {"buffer_flush_adaptive_pages", "buffer",
460 "Pages queued as an adaptive batch", MONITOR_SET_MEMBER,
461 MONITOR_FLUSH_ADAPTIVE_TOTAL_PAGE, MONITOR_FLUSH_ADAPTIVE_PAGES},
462
463 /* Cumulative counter for flush batches because of sync */
464 {"buffer_flush_sync_total_pages", "buffer",
465 "Total pages flushed as part of sync batches", MONITOR_SET_OWNER,
466 MONITOR_FLUSH_SYNC_COUNT, MONITOR_FLUSH_SYNC_TOTAL_PAGE},
467
468 {"buffer_flush_sync", "buffer", "Number of sync batches",
469 MONITOR_SET_MEMBER, MONITOR_FLUSH_SYNC_TOTAL_PAGE,
470 MONITOR_FLUSH_SYNC_COUNT},
471
472 {"buffer_flush_sync_pages", "buffer", "Pages queued as a sync batch",
473 MONITOR_SET_MEMBER, MONITOR_FLUSH_SYNC_TOTAL_PAGE,
474 MONITOR_FLUSH_SYNC_PAGES},
475
476 /* Cumulative counter for flush batches because of background */
477 {"buffer_flush_background_total_pages", "buffer",
478 "Total pages flushed as part of background batches", MONITOR_SET_OWNER,
479 MONITOR_FLUSH_BACKGROUND_COUNT, MONITOR_FLUSH_BACKGROUND_TOTAL_PAGE},
480
481 {"buffer_flush_background", "buffer", "Number of background batches",
482 MONITOR_SET_MEMBER, MONITOR_FLUSH_BACKGROUND_TOTAL_PAGE,
483 MONITOR_FLUSH_BACKGROUND_COUNT},
484
485 {"buffer_flush_background_pages", "buffer",
486 "Pages queued as a background batch", MONITOR_SET_MEMBER,
487 MONITOR_FLUSH_BACKGROUND_TOTAL_PAGE, MONITOR_FLUSH_BACKGROUND_PAGES},
488
489 /* Cumulative counter for LRU batch scan */
490 {"buffer_LRU_batch_scanned", "buffer",
491 "Total pages scanned as part of LRU batch", MONITOR_SET_OWNER,
492 MONITOR_LRU_BATCH_SCANNED_NUM_CALL, MONITOR_LRU_BATCH_SCANNED},
493
494 {"buffer_LRU_batch_num_scan", "buffer",
495 "Number of times LRU batch is called", MONITOR_SET_MEMBER,
496 MONITOR_LRU_BATCH_SCANNED, MONITOR_LRU_BATCH_SCANNED_NUM_CALL},
497
498 {"buffer_LRU_batch_scanned_per_call", "buffer",
499 "Pages scanned per LRU batch call", MONITOR_SET_MEMBER,
500 MONITOR_LRU_BATCH_SCANNED, MONITOR_LRU_BATCH_SCANNED_PER_CALL},
501
502 /* Cumulative counter for LRU batch pages flushed */
503 {"buffer_LRU_batch_flush_total_pages", "buffer",
504 "Total pages flushed as part of LRU batches", MONITOR_SET_OWNER,
505 MONITOR_LRU_BATCH_FLUSH_COUNT, MONITOR_LRU_BATCH_FLUSH_TOTAL_PAGE},
506
507 {"buffer_LRU_batches_flush", "buffer", "Number of LRU batches",
508 MONITOR_SET_MEMBER, MONITOR_LRU_BATCH_FLUSH_TOTAL_PAGE,
509 MONITOR_LRU_BATCH_FLUSH_COUNT},
510
511 {"buffer_LRU_batch_flush_pages", "buffer", "Pages queued as an LRU batch",
512 MONITOR_SET_MEMBER, MONITOR_LRU_BATCH_FLUSH_TOTAL_PAGE,
513 MONITOR_LRU_BATCH_FLUSH_PAGES},
514
515 /* Cumulative counter for LRU batch pages flushed */
516 {"buffer_LRU_batch_evict_total_pages", "buffer",
517 "Total pages evicted as part of LRU batches", MONITOR_SET_OWNER,
518 MONITOR_LRU_BATCH_EVICT_COUNT, MONITOR_LRU_BATCH_EVICT_TOTAL_PAGE},
519
520 {"buffer_LRU_batches_evict", "buffer", "Number of LRU batches",
521 MONITOR_SET_MEMBER, MONITOR_LRU_BATCH_EVICT_TOTAL_PAGE,
522 MONITOR_LRU_BATCH_EVICT_COUNT},
523
524 {"buffer_LRU_batch_evict_pages", "buffer", "Pages queued as an LRU batch",
525 MONITOR_SET_MEMBER, MONITOR_LRU_BATCH_EVICT_TOTAL_PAGE,
526 MONITOR_LRU_BATCH_EVICT_PAGES},
527
528 /* Cumulative counter for single page LRU scans */
529 {"buffer_LRU_single_flush_scanned", "buffer",
530 "Total pages scanned as part of single page LRU flush", MONITOR_SET_OWNER,
531 MONITOR_LRU_SINGLE_FLUSH_SCANNED_NUM_CALL,
532 MONITOR_LRU_SINGLE_FLUSH_SCANNED},
533
534 {"buffer_LRU_single_flush_num_scan", "buffer",
535 "Number of times single page LRU flush is called", MONITOR_SET_MEMBER,
536 MONITOR_LRU_SINGLE_FLUSH_SCANNED,
537 MONITOR_LRU_SINGLE_FLUSH_SCANNED_NUM_CALL},
538
539 {"buffer_LRU_single_flush_scanned_per_call", "buffer",
540 "Page scanned per single LRU flush", MONITOR_SET_MEMBER,
541 MONITOR_LRU_SINGLE_FLUSH_SCANNED,
542 MONITOR_LRU_SINGLE_FLUSH_SCANNED_PER_CALL},
543
544 {"buffer_LRU_single_flush_failure_count", "Buffer",
545 "Number of times attempt to flush a single page from LRU failed",
546 MONITOR_NONE, MONITOR_DEFAULT_START,
547 MONITOR_LRU_SINGLE_FLUSH_FAILURE_COUNT},
548
549 {"buffer_LRU_get_free_search", "Buffer",
550 "Number of searches performed for a clean page", MONITOR_NONE,
551 MONITOR_DEFAULT_START, MONITOR_LRU_GET_FREE_SEARCH},
552
553 /* Cumulative counter for LRU search scans */
554 {"buffer_LRU_search_scanned", "buffer",
555 "Total pages scanned as part of LRU search", MONITOR_SET_OWNER,
556 MONITOR_LRU_SEARCH_SCANNED_NUM_CALL, MONITOR_LRU_SEARCH_SCANNED},
557
558 {"buffer_LRU_search_num_scan", "buffer",
559 "Number of times LRU search is performed", MONITOR_SET_MEMBER,
560 MONITOR_LRU_SEARCH_SCANNED, MONITOR_LRU_SEARCH_SCANNED_NUM_CALL},
561
562 {"buffer_LRU_search_scanned_per_call", "buffer",
563 "Page scanned per single LRU search", MONITOR_SET_MEMBER,
564 MONITOR_LRU_SEARCH_SCANNED, MONITOR_LRU_SEARCH_SCANNED_PER_CALL},
565
566 /* Cumulative counter for LRU unzip search scans */
567 {"buffer_LRU_unzip_search_scanned", "buffer",
568 "Total pages scanned as part of LRU unzip search", MONITOR_SET_OWNER,
569 MONITOR_LRU_UNZIP_SEARCH_SCANNED_NUM_CALL,
570 MONITOR_LRU_UNZIP_SEARCH_SCANNED},
571
572 {"buffer_LRU_unzip_search_num_scan", "buffer",
573 "Number of times LRU unzip search is performed", MONITOR_SET_MEMBER,
574 MONITOR_LRU_UNZIP_SEARCH_SCANNED,
575 MONITOR_LRU_UNZIP_SEARCH_SCANNED_NUM_CALL},
576
577 {"buffer_LRU_unzip_search_scanned_per_call", "buffer",
578 "Page scanned per single LRU unzip search", MONITOR_SET_MEMBER,
579 MONITOR_LRU_UNZIP_SEARCH_SCANNED,
580 MONITOR_LRU_UNZIP_SEARCH_SCANNED_PER_CALL},
581
582 /* ========== Counters for Buffer Page I/O ========== */
583 {"module_buffer_page", "buffer_page_io", "Buffer Page I/O Module",
584 static_cast<monitor_type_t>(MONITOR_MODULE | MONITOR_GROUP_MODULE),
585 MONITOR_DEFAULT_START, MONITOR_MODULE_BUF_PAGE},
586
587 /* MONITOR_INDEX_LEAF_PAGE_READ */
588 MONITOR_BUF_PAGE_READ("index_leaf", "Index Leaf", INDEX_LEAF),
589
590 /* MONITOR_INDEX_NON_LEAF_PAGE_READ */
591 MONITOR_BUF_PAGE_READ("index_non_leaf", "Index Non-leaf", INDEX_NON_LEAF),
592
593 /* MONITOR_INDEX_IBUF_LEAF_PAGE_READ */
594 MONITOR_BUF_PAGE_READ("index_ibuf_leaf", "Insert Buffer Index Leaf",
595 INDEX_IBUF_LEAF),
596
597 /* MONITOR_INDEX_IBUF_NON_LEAF_PAGE_READ */
598 MONITOR_BUF_PAGE_READ("index_ibuf_non_leaf", "Insert Buffer Index Non-Leaf",
599 INDEX_IBUF_NON_LEAF),
600
601 /* MONITOR_UNDO_LOG_PAGE_READ */
602 MONITOR_BUF_PAGE_READ("undo_log", "Undo Log", UNDO_LOG),
603
604 /* MONITOR_INODE_PAGE_READ */
605 MONITOR_BUF_PAGE_READ("index_inode", "Index Inode", INODE),
606
607 /* MONITOR_IBUF_FREELIST_PAGE_READ */
608 MONITOR_BUF_PAGE_READ("ibuf_free_list", "Insert Buffer Free List",
609 IBUF_FREELIST),
610
611 /* MONITOR_IBUF_BITMAP_PAGE_READ */
612 MONITOR_BUF_PAGE_READ("ibuf_bitmap", "Insert Buffer Bitmap", IBUF_BITMAP),
613
614 /* MONITOR_SYSTEM_PAGE_READ */
615 MONITOR_BUF_PAGE_READ("system_page", "System", SYSTEM),
616
617 /* MONITOR_TRX_SYSTEM_PAGE_READ */
618 MONITOR_BUF_PAGE_READ("trx_system", "Transaction System", TRX_SYSTEM),
619
620 /* MONITOR_FSP_HDR_PAGE_READ */
621 MONITOR_BUF_PAGE_READ("fsp_hdr", "File Space Header", FSP_HDR),
622
623 /* MONITOR_XDES_PAGE_READ */
624 MONITOR_BUF_PAGE_READ("xdes", "Extent Descriptor", XDES),
625
626 /* MONITOR_BLOB_PAGE_READ */
627 MONITOR_BUF_PAGE_READ("blob", "Uncompressed BLOB", BLOB),
628
629 /* MONITOR_ZBLOB_PAGE_READ */
630 MONITOR_BUF_PAGE_READ("zblob", "First Compressed BLOB", ZBLOB),
631
632 /* MONITOR_ZBLOB2_PAGE_READ */
633 MONITOR_BUF_PAGE_READ("zblob2", "Subsequent Compressed BLOB", ZBLOB2),
634
635 /* MONITOR_RSEG_ARRAY_PAGE_READ */
636 MONITOR_BUF_PAGE_READ("rseg_array", "Rollback Segment Array", RSEG_ARRAY),
637
638 /* MONITOR_OTHER_PAGE_READ */
639 MONITOR_BUF_PAGE_READ("other", "other/unknown (old version of InnoDB)",
640 OTHER),
641
642 /* MONITOR_INDEX_LEAF_PAGE_WRITTEN */
643 MONITOR_BUF_PAGE_WRITTEN("index_leaf", "Index Leaf", INDEX_LEAF),
644
645 /* MONITOR_INDEX_NON_LEAF_PAGE_WRITTEN */
646 MONITOR_BUF_PAGE_WRITTEN("index_non_leaf", "Index Non-leaf",
647 INDEX_NON_LEAF),
648
649 /* MONITOR_INDEX_IBUF_LEAF_PAGE_WRITTEN */
650 MONITOR_BUF_PAGE_WRITTEN("index_ibuf_leaf", "Insert Buffer Index Leaf",
651 INDEX_IBUF_LEAF),
652
653 /*MONITOR_INDEX_IBUF_NON_LEAF_PAGE_WRITTEN */
654 MONITOR_BUF_PAGE_WRITTEN("index_ibuf_non_leaf",
655 "Insert Buffer Index Non-Leaf",
656 INDEX_IBUF_NON_LEAF),
657
658 /* MONITOR_UNDO_LOG_PAGE_WRITTEN */
659 MONITOR_BUF_PAGE_WRITTEN("undo_log", "Undo Log", UNDO_LOG),
660
661 /* MONITOR_INODE_PAGE_WRITTEN */
662 MONITOR_BUF_PAGE_WRITTEN("index_inode", "Index Inode", INODE),
663
664 /* MONITOR_IBUF_FREELIST_PAGE_WRITTEN */
665 MONITOR_BUF_PAGE_WRITTEN("ibuf_free_list", "Insert Buffer Free List",
666 IBUF_FREELIST),
667
668 /* MONITOR_IBUF_BITMAP_PAGE_WRITTEN */
669 MONITOR_BUF_PAGE_WRITTEN("ibuf_bitmap", "Insert Buffer Bitmap",
670 IBUF_BITMAP),
671
672 /* MONITOR_SYSTEM_PAGE_WRITTEN */
673 MONITOR_BUF_PAGE_WRITTEN("system_page", "System", SYSTEM),
674
675 /* MONITOR_TRX_SYSTEM_PAGE_WRITTEN */
676 MONITOR_BUF_PAGE_WRITTEN("trx_system", "Transaction System", TRX_SYSTEM),
677
678 /* MONITOR_FSP_HDR_PAGE_WRITTEN */
679 MONITOR_BUF_PAGE_WRITTEN("fsp_hdr", "File Space Header", FSP_HDR),
680
681 /* MONITOR_XDES_PAGE_WRITTEN */
682 MONITOR_BUF_PAGE_WRITTEN("xdes", "Extent Descriptor", XDES),
683
684 /* MONITOR_BLOB_PAGE_WRITTEN */
685 MONITOR_BUF_PAGE_WRITTEN("blob", "Uncompressed BLOB", BLOB),
686
687 /* MONITOR_ZBLOB_PAGE_WRITTEN */
688 MONITOR_BUF_PAGE_WRITTEN("zblob", "First Compressed BLOB", ZBLOB),
689
690 /* MONITOR_ZBLOB2_PAGE_WRITTEN */
691 MONITOR_BUF_PAGE_WRITTEN("zblob2", "Subsequent Compressed BLOB", ZBLOB2),
692
693 /* MONITOR_RSEG_ARRAY_PAGE_WRITTEN */
694 MONITOR_BUF_PAGE_WRITTEN("rseg_array", "Rollback Segment Array",
695 RSEG_ARRAY),
696
697 /* MONITOR_OTHER_PAGE_WRITTEN */
698 MONITOR_BUF_PAGE_WRITTEN("other", "other/unknown (old version InnoDB)",
699 OTHER),
700
701 MONITOR_BUF_PAGE_WRITTEN_WAIT_STATS(
702 "on_log_", "Waits on redo flushed when flushing pages", ON_LOG_),
703
704 /* ========== Counters for OS level operations ========== */
705 {"module_os", "os", "OS Level Operation", MONITOR_MODULE,
706 MONITOR_DEFAULT_START, MONITOR_MODULE_OS},
707
708 {"os_data_reads", "os", "Number of reads initiated (innodb_data_reads)",
709 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
710 MONITOR_DEFAULT_START, MONITOR_OVLD_OS_FILE_READ},
711
712 {"os_data_writes", "os", "Number of writes initiated (innodb_data_writes)",
713 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
714 MONITOR_DEFAULT_START, MONITOR_OVLD_OS_FILE_WRITE},
715
716 {"os_data_fsyncs", "os", "Number of fsync() calls (innodb_data_fsyncs)",
717 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
718 MONITOR_DEFAULT_START, MONITOR_OVLD_OS_FSYNC},
719
720 {"os_pending_reads", "os", "Number of reads pending", MONITOR_NONE,
721 MONITOR_DEFAULT_START, MONITOR_OS_PENDING_READS},
722
723 {"os_pending_writes", "os", "Number of writes pending", MONITOR_NONE,
724 MONITOR_DEFAULT_START, MONITOR_OS_PENDING_WRITES},
725
726 {"os_log_bytes_written", "os",
727 "Bytes of log written (innodb_os_log_written)",
728 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
729 MONITOR_DEFAULT_START, MONITOR_OVLD_OS_LOG_WRITTEN},
730
731 {"os_log_fsyncs", "os", "Number of fsync log writes (innodb_os_log_fsyncs)",
732 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
733 MONITOR_DEFAULT_START, MONITOR_OVLD_OS_LOG_FSYNC},
734
735 {"os_log_pending_fsyncs", "os",
736 "Number of pending fsync write (innodb_os_log_pending_fsyncs)",
737 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
738 MONITOR_DEFAULT_START, MONITOR_OVLD_OS_LOG_PENDING_FSYNC},
739
740 {"os_log_pending_writes", "os",
741 "Number of pending log file writes (innodb_os_log_pending_writes)",
742 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
743 MONITOR_DEFAULT_START, MONITOR_OVLD_OS_LOG_PENDING_WRITES},
744
745 /* ========== Counters for Transaction Module ========== */
746 {"module_trx", "transaction", "Transaction Manager", MONITOR_MODULE,
747 MONITOR_DEFAULT_START, MONITOR_MODULE_TRX},
748
749 {"trx_rw_commits", "transaction",
750 "Number of read-write transactions committed", MONITOR_NONE,
751 MONITOR_DEFAULT_START, MONITOR_TRX_RW_COMMIT},
752
753 {"trx_ro_commits", "transaction",
754 "Number of read-only transactions committed", MONITOR_NONE,
755 MONITOR_DEFAULT_START, MONITOR_TRX_RO_COMMIT},
756
757 {"trx_nl_ro_commits", "transaction",
758 "Number of non-locking auto-commit read-only transactions committed",
759 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_TRX_NL_RO_COMMIT},
760
761 {"trx_commits_insert_update", "transaction",
762 "Number of transactions committed with inserts and updates", MONITOR_NONE,
763 MONITOR_DEFAULT_START, MONITOR_TRX_COMMIT_UNDO},
764
765 {"trx_rollbacks", "transaction", "Number of transactions rolled back",
766 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_TRX_ROLLBACK},
767
768 {"trx_rollbacks_savepoint", "transaction",
769 "Number of transactions rolled back to savepoint", MONITOR_NONE,
770 MONITOR_DEFAULT_START, MONITOR_TRX_ROLLBACK_SAVEPOINT},
771
772 {"trx_rollback_active", "transaction",
773 "Number of resurrected active transactions rolled back", MONITOR_NONE,
774 MONITOR_DEFAULT_START, MONITOR_TRX_ROLLBACK_ACTIVE},
775
776 {"trx_active_transactions", "transaction", "Number of active transactions",
777 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_TRX_ACTIVE},
778
779 {"trx_allocations", "transaction", "Number of trx_t allocations",
780 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_TRX_ALLOCATIONS},
781
782 MONITOR_WAIT_STATS("trx_on_log_", "transaction",
783 "Waits for redo during transaction commits",
784 MONITOR_TRX_ON_LOG_),
785
786 {"trx_rseg_history_len", "transaction",
787 "Length of the TRX_RSEG_HISTORY list",
788 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DISPLAY_CURRENT |
789 MONITOR_DEFAULT_ON),
790 MONITOR_DEFAULT_START, MONITOR_RSEG_HISTORY_LEN},
791
792 {"trx_undo_slots_used", "transaction", "Number of undo slots used",
793 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_NUM_UNDO_SLOT_USED},
794
795 {"trx_undo_slots_cached", "transaction", "Number of undo slots cached",
796 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_NUM_UNDO_SLOT_CACHED},
797
798 {"trx_rseg_current_size", "transaction",
799 "Current rollback segment size in pages",
800 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DISPLAY_CURRENT),
801 MONITOR_DEFAULT_START, MONITOR_RSEG_CUR_SIZE},
802
803 /* ========== Counters for Purge Module ========== */
804 {"module_purge", "purge", "Purge Module", MONITOR_MODULE,
805 MONITOR_DEFAULT_START, MONITOR_MODULE_PURGE},
806
807 {"purge_del_mark_records", "purge", "Number of delete-marked rows purged",
808 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_N_DEL_ROW_PURGE},
809
810 {"purge_upd_exist_or_extern_records", "purge",
811 "Number of purges on updates of existing records and"
812 " updates on delete marked record with externally stored field",
813 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_N_UPD_EXIST_EXTERN},
814
815 {"purge_invoked", "purge", "Number of times purge was invoked",
816 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_PURGE_INVOKED},
817
818 {"purge_undo_log_pages", "purge",
819 "Number of undo log pages handled by the purge", MONITOR_NONE,
820 MONITOR_DEFAULT_START, MONITOR_PURGE_N_PAGE_HANDLED},
821
822 {"purge_dml_delay_usec", "purge",
823 "Microseconds DML to be delayed due to purge lagging",
824 MONITOR_DISPLAY_CURRENT, MONITOR_DEFAULT_START, MONITOR_DML_PURGE_DELAY},
825
826 {"purge_stop_count", "purge", "Number of times purge was stopped",
827 MONITOR_DISPLAY_CURRENT, MONITOR_DEFAULT_START, MONITOR_PURGE_STOP_COUNT},
828
829 {"purge_resume_count", "purge", "Number of times purge was resumed",
830 MONITOR_DISPLAY_CURRENT, MONITOR_DEFAULT_START,
831 MONITOR_PURGE_RESUME_COUNT},
832
833 {"purge_truncate_history_count", "purge",
834 "Number of times the purge thread attempted to truncate undo history",
835 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_PURGE_TRUNCATE_HISTORY_COUNT},
836
837 {"purge_truncate_history_usec", "purge",
838 "Time (in microseconds) the purge thread spent truncating undo history.",
839 MONITOR_NONE, MONITOR_DEFAULT_START,
840 MONITOR_PURGE_TRUNCATE_HISTORY_MICROSECOND},
841
842 /* ========== Counters for Undo Tablespace Truncation ========== */
843 {"module_undo", "undo", "Undo Truncation", MONITOR_MODULE,
844 MONITOR_DEFAULT_START, MONITOR_UNDO_TRUNCATE},
845
846 {"undo_truncate_count", "undo",
847 "Number of times undo truncation was initiated", MONITOR_NONE,
848 MONITOR_DEFAULT_START, MONITOR_UNDO_TRUNCATE_COUNT},
849
850 {"undo_truncate_start_logging_count", "undo",
851 "Number of times during undo truncation a log file was started",
852 MONITOR_NONE, MONITOR_DEFAULT_START,
853 MONITOR_UNDO_TRUNCATE_START_LOGGING_COUNT},
854
855 {"undo_truncate_done_logging_count", "undo",
856 "Number of times during undo truncation a log file was deleted",
857 MONITOR_NONE, MONITOR_DEFAULT_START,
858 MONITOR_UNDO_TRUNCATE_DONE_LOGGING_COUNT},
859
860 {"undo_truncate_usec", "undo",
861 "Time (in microseconds) spent to process undo truncation", MONITOR_NONE,
862 MONITOR_DEFAULT_START, MONITOR_UNDO_TRUNCATE_MICROSECOND},
863
864 /* ========== Counters for Redo log Module ========== */
865 {"module_log", "log", "Redo log Module", MONITOR_MODULE,
866 MONITOR_DEFAULT_START, MONITOR_MODULE_REDO_LOG},
867
868 {"log_lsn_last_flush", "log", "LSN of last flush",
869 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DISPLAY_CURRENT),
870 MONITOR_DEFAULT_START, MONITOR_OVLD_LSN_FLUSHDISK},
871
872 {"log_lsn_last_checkpoint", "log", "LSN at last checkpoint",
873 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DISPLAY_CURRENT),
874 MONITOR_DEFAULT_START, MONITOR_OVLD_LSN_CHECKPOINT},
875
876 {"log_lsn_current", "log", "Current LSN value",
877 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DISPLAY_CURRENT),
878 MONITOR_DEFAULT_START, MONITOR_OVLD_LSN_CURRENT},
879
880 {"log_lsn_archived", "log", "Archived LSN value",
881 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DISPLAY_CURRENT),
882 MONITOR_DEFAULT_START, MONITOR_OVLD_LSN_ARCHIVED},
883
884 {"log_lsn_checkpoint_age", "log",
885 "Current LSN value minus LSN at last checkpoint",
886 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DISPLAY_CURRENT),
887 MONITOR_DEFAULT_START, MONITOR_OVLD_LSN_CHECKPOINT_AGE},
888
889 {"log_lsn_buf_dirty_pages_added", "log",
890 "The LSN value up to which all dirty pages have been added",
891 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DISPLAY_CURRENT),
892 MONITOR_DEFAULT_START, MONITOR_OVLD_LSN_BUF_DIRTY_PAGES_ADDED},
893
894 {"log_lsn_buf_pool_oldest_approx", "log",
895 "Approximation for the oldest modified block LSN in the buffer pool",
896 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DISPLAY_CURRENT),
897 MONITOR_DEFAULT_START, MONITOR_OVLD_BUF_OLDEST_LSN_APPROX},
898
899 {"log_lsn_buf_pool_oldest_lwm", "log",
900 "Low watermark for the oldest modified block LSN in the buffer pool",
901 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DISPLAY_CURRENT),
902 MONITOR_DEFAULT_START, MONITOR_OVLD_BUF_OLDEST_LSN_LWM},
903
904 {"log_max_modified_age_async", "log",
905 "Maximum LSN difference; when exceeded, start asynchronous preflush",
906 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DISPLAY_CURRENT),
907 MONITOR_DEFAULT_START, MONITOR_OVLD_MAX_AGE_ASYNC},
908
909 {"log_max_modified_age_sync", "log",
910 "Maximum LSN difference; when exceeded, start synchronous preflush",
911 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DISPLAY_CURRENT),
912 MONITOR_DEFAULT_START, MONITOR_OVLD_MAX_AGE_SYNC},
913
914 {"log_waits", "log",
915 "Number of log waits due to small log buffer (innodb_log_waits)",
916 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
917 MONITOR_DEFAULT_START, MONITOR_OVLD_LOG_WAITS},
918
919 {"log_write_requests", "log", "Number of log write requests",
920 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
921 MONITOR_DEFAULT_START, MONITOR_OVLD_LOG_WRITE_REQUEST},
922
923 {"log_writes", "log", "Number of log writes",
924 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
925 MONITOR_DEFAULT_START, MONITOR_OVLD_LOG_WRITES},
926
927 {"log_flush_total_time", "log", "Total time spent on fsync for log files",
928 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_LOG_FLUSH_TOTAL_TIME},
929
930 {"log_flush_max_time", "log",
931 "Maximum time spent on fsync for log files (during last "
932 "innodb_flushing_avg_loops)",
933 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_LOG_FLUSH_MAX_TIME},
934
935 {"log_flush_avg_time", "log",
936 "Average time spent on fsync for log files (during last "
937 "innodb_flushing_avg_loops)",
938 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_LOG_FLUSH_AVG_TIME},
939
940 {"log_flush_lsn_avg_rate", "log",
941 "Average redo flushing rate (during last innodb_flushing_avg_loops)",
942 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_LOG_FLUSH_LSN_AVG_RATE},
943
944 {"log_full_block_writes", "log",
945 "Number of log writes for full (completed) log blocks", MONITOR_NONE,
946 MONITOR_DEFAULT_START, MONITOR_LOG_FULL_BLOCK_WRITES},
947
948 {"log_partial_block_writes", "log",
949 "Number of log writes for partial (incomplete) log blocks", MONITOR_NONE,
950 MONITOR_DEFAULT_START, MONITOR_LOG_PARTIAL_BLOCK_WRITES},
951
952 {"log_padded", "log", "Bytes of log padded for log write ahead",
953 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_LOG_PADDED},
954
955 {"log_next_file", "log", "Number of new log files created.", MONITOR_NONE,
956 MONITOR_DEFAULT_START, MONITOR_LOG_NEXT_FILE},
957
958 {"log_checkpoints", "log", "Number of checkpoints", MONITOR_NONE,
959 MONITOR_DEFAULT_START, MONITOR_LOG_CHECKPOINTS},
960
961 {"log_free_space", "log", "Free space in redo (emergency when negative).",
962 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_LOG_FREE_SPACE},
963
964 {"log_concurrency_margin", "log",
965 "Current concurrency margin used (may increase).", MONITOR_NONE,
966 MONITOR_DEFAULT_START, MONITOR_LOG_CONCURRENCY_MARGIN},
967
968 MONITOR_WAIT_STATS("log_writer_", "log",
969 "Waits on task in log_writer thread",
970 MONITOR_LOG_WRITER_),
971
972 {"log_writer_on_file_space_waits", "log",
973 "Waits on free space in log writer", MONITOR_NONE, MONITOR_DEFAULT_START,
974 MONITOR_LOG_WRITER_ON_FREE_SPACE_WAITS},
975
976 {"log_writer_on_archiver_waits", "log",
977 "Waits on redo archiver in log writer", MONITOR_NONE,
978 MONITOR_DEFAULT_START, MONITOR_LOG_WRITER_ON_ARCHIVER_WAITS},
979
980 MONITOR_WAIT_STATS("log_flusher_", "log",
981 "Waits on task in log_flusher thread",
982 MONITOR_LOG_FLUSHER_),
983
984 MONITOR_WAIT_STATS("log_write_notifier_", "log",
985 "Waits on task in log_write_notifier thread",
986 MONITOR_LOG_WRITE_NOTIFIER_),
987
988 MONITOR_WAIT_STATS("log_flush_notifier_", "log",
989 "Waits on task in log_flush_notifier_thread",
990 MONITOR_LOG_FLUSH_NOTIFIER_),
991
992 {"log_write_to_file_requests_interval", "log",
993 "Average time between consecutive requests to write/flush redo."
994 " Measured only for requests signaled during commit of transactions.",
995 MONITOR_NONE, MONITOR_DEFAULT_START,
996 MONITOR_LOG_WRITE_TO_FILE_REQUESTS_INTERVAL},
997
998 MONITOR_WAIT_STATS("log_on_write_", "log",
999 "Waits in user threads on log_writer+log_write_notifier",
1000 /* Note: requests to flush log up to lsn are not counted
1001 here! This counter is used only, when fsync is not
1002 required afterwards (when we rely on FS cache). */
1003 MONITOR_LOG_ON_WRITE_),
1004
1005 MONITOR_WAIT_STATS(
1006 "log_on_flush_", "log",
1007 "Waits in user threads on log_flusher+log_flush_notifier",
1008 /* Note: requests, for which it is sufficient to do write without
1009 fsync, are not counted here! This counter is used only, when we
1010 need data fsynced. */
1011 MONITOR_LOG_ON_FLUSH_),
1012
1013 {"log_on_recent_written_wait_loops", "log",
1014 "Loops of waits in user threads on space in log.recent_written",
1015 /* Non-zero values of the counter => writes to log buffer are delayed.
1016 Then innodb_log_recent_written_slots should be increased. */
1017 MONITOR_NONE, MONITOR_DEFAULT_START,
1018 MONITOR_LOG_ON_RECENT_WRITTEN_WAIT_LOOPS},
1019
1020 {"log_on_recent_closed_wait_loops", "log",
1021 "Loops of waits in user threads on space in log.recent_closed",
1022 /* Non-zero values of the counter => writes to log buffer are delayed.
1023 Then innodb_log_recent_closed_slots should be increased. */
1024 MONITOR_NONE, MONITOR_DEFAULT_START,
1025 MONITOR_LOG_ON_RECENT_CLOSED_WAIT_LOOPS},
1026
1027 MONITOR_WAIT_STATS("log_on_buffer_space_", "log",
1028 "Waits in user threads on space in log buffer",
1029 MONITOR_LOG_ON_BUFFER_SPACE_),
1030
1031 MONITOR_WAIT_STATS("log_on_file_space_", "log",
1032 "Waits in user threads on space in log files",
1033 MONITOR_LOG_ON_FILE_SPACE_),
1034
1035 /* ========== Counters for Page Compression ========== */
1036 {"module_compress", "compression", "Page Compression Info", MONITOR_MODULE,
1037 MONITOR_DEFAULT_START, MONITOR_MODULE_PAGE},
1038
1039 {"compress_pages_compressed", "compression", "Number of pages compressed",
1040 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_PAGE_COMPRESS},
1041
1042 {"compress_pages_decompressed", "compression",
1043 "Number of pages decompressed", MONITOR_NONE, MONITOR_DEFAULT_START,
1044 MONITOR_PAGE_DECOMPRESS},
1045
1046 {"compression_pad_increments", "compression",
1047 "Number of times padding is incremented to avoid compression failures",
1048 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_PAD_INCREMENTS},
1049
1050 {"compression_pad_decrements", "compression",
1051 "Number of times padding is decremented due to good compressibility",
1052 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_PAD_DECREMENTS},
1053
1054 /* ========== Counters for Index ========== */
1055 {"module_index", "index", "Index Manager", MONITOR_MODULE,
1056 MONITOR_DEFAULT_START, MONITOR_MODULE_INDEX},
1057
1058 {"index_page_splits", "index", "Number of index page splits", MONITOR_NONE,
1059 MONITOR_DEFAULT_START, MONITOR_INDEX_SPLIT},
1060
1061 {"index_page_merge_attempts", "index",
1062 "Number of index page merge attempts", MONITOR_NONE, MONITOR_DEFAULT_START,
1063 MONITOR_INDEX_MERGE_ATTEMPTS},
1064
1065 {"index_page_merge_successful", "index",
1066 "Number of successful index page merges", MONITOR_NONE,
1067 MONITOR_DEFAULT_START, MONITOR_INDEX_MERGE_SUCCESSFUL},
1068
1069 {"index_page_reorg_attempts", "index",
1070 "Number of index page reorganization attempts", MONITOR_NONE,
1071 MONITOR_DEFAULT_START, MONITOR_INDEX_REORG_ATTEMPTS},
1072
1073 {"index_page_reorg_successful", "index",
1074 "Number of successful index page reorganizations", MONITOR_NONE,
1075 MONITOR_DEFAULT_START, MONITOR_INDEX_REORG_SUCCESSFUL},
1076
1077 {"index_page_discards", "index", "Number of index pages discarded",
1078 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_INDEX_DISCARD},
1079
1080 /* ========== Counters for Adaptive Hash Index ========== */
1081 {"module_adaptive_hash", "adaptive_hash_index", "Adaptive Hash Index",
1082 MONITOR_MODULE, MONITOR_DEFAULT_START, MONITOR_MODULE_ADAPTIVE_HASH},
1083
1084 {"adaptive_hash_searches", "adaptive_hash_index",
1085 "Number of successful searches using Adaptive Hash Index",
1086 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
1087 MONITOR_DEFAULT_START, MONITOR_OVLD_ADAPTIVE_HASH_SEARCH},
1088
1089 {"adaptive_hash_searches_btree", "adaptive_hash_index",
1090 "Number of searches using B-tree on an index search",
1091 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
1092 MONITOR_DEFAULT_START, MONITOR_OVLD_ADAPTIVE_HASH_SEARCH_BTREE},
1093
1094 {"adaptive_hash_pages_added", "adaptive_hash_index",
1095 "Number of index pages on which the Adaptive Hash Index is built",
1096 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_ADAPTIVE_HASH_PAGE_ADDED},
1097
1098 {"adaptive_hash_pages_removed", "adaptive_hash_index",
1099 "Number of index pages whose corresponding Adaptive Hash Index"
1100 " entries were removed",
1101 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_ADAPTIVE_HASH_PAGE_REMOVED},
1102
1103 {"adaptive_hash_rows_added", "adaptive_hash_index",
1104 "Number of Adaptive Hash Index rows added", MONITOR_NONE,
1105 MONITOR_DEFAULT_START, MONITOR_ADAPTIVE_HASH_ROW_ADDED},
1106
1107 {"adaptive_hash_rows_removed", "adaptive_hash_index",
1108 "Number of Adaptive Hash Index rows removed", MONITOR_NONE,
1109 MONITOR_DEFAULT_START, MONITOR_ADAPTIVE_HASH_ROW_REMOVED},
1110
1111 {"adaptive_hash_rows_deleted_no_hash_entry", "adaptive_hash_index",
1112 "Number of rows deleted that did not have corresponding Adaptive Hash"
1113 " Index entries",
1114 MONITOR_NONE, MONITOR_DEFAULT_START,
1115 MONITOR_ADAPTIVE_HASH_ROW_REMOVE_NOT_FOUND},
1116
1117 {"adaptive_hash_rows_updated", "adaptive_hash_index",
1118 "Number of Adaptive Hash Index rows updated", MONITOR_NONE,
1119 MONITOR_DEFAULT_START, MONITOR_ADAPTIVE_HASH_ROW_UPDATED},
1120
1121 /* ========== Counters for tablespace ========== */
1122 {"module_file", "file_system", "Tablespace and File System Manager",
1123 MONITOR_MODULE, MONITOR_DEFAULT_START, MONITOR_MODULE_FIL_SYSTEM},
1124
1125 {"file_num_open_files", "file_system",
1126 "Number of files currently open (innodb_num_open_files)",
1127 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DISPLAY_CURRENT |
1128 MONITOR_DEFAULT_ON),
1129 MONITOR_DEFAULT_START, MONITOR_OVLD_N_FILE_OPENED},
1130
1131 /* ========== Counters for Change Buffer ========== */
1132 {"module_ibuf_system", "change_buffer", "InnoDB Change Buffer",
1133 MONITOR_MODULE, MONITOR_DEFAULT_START, MONITOR_MODULE_IBUF_SYSTEM},
1134
1135 {"ibuf_merges_insert", "change_buffer",
1136 "Number of inserted records merged by change buffering",
1137 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
1138 MONITOR_DEFAULT_START, MONITOR_OVLD_IBUF_MERGE_INSERT},
1139
1140 {"ibuf_merges_delete_mark", "change_buffer",
1141 "Number of deleted records merged by change buffering",
1142 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
1143 MONITOR_DEFAULT_START, MONITOR_OVLD_IBUF_MERGE_DELETE},
1144
1145 {"ibuf_merges_delete", "change_buffer",
1146 "Number of purge records merged by change buffering",
1147 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
1148 MONITOR_DEFAULT_START, MONITOR_OVLD_IBUF_MERGE_PURGE},
1149
1150 {"ibuf_merges_discard_insert", "change_buffer",
1151 "Number of insert merged operations discarded",
1152 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
1153 MONITOR_DEFAULT_START, MONITOR_OVLD_IBUF_MERGE_DISCARD_INSERT},
1154
1155 {"ibuf_merges_discard_delete_mark", "change_buffer",
1156 "Number of deleted merged operations discarded",
1157 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
1158 MONITOR_DEFAULT_START, MONITOR_OVLD_IBUF_MERGE_DISCARD_DELETE},
1159
1160 {"ibuf_merges_discard_delete", "change_buffer",
1161 "Number of purge merged operations discarded",
1162 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
1163 MONITOR_DEFAULT_START, MONITOR_OVLD_IBUF_MERGE_DISCARD_PURGE},
1164
1165 {"ibuf_merges", "change_buffer", "Number of change buffer merges",
1166 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
1167 MONITOR_DEFAULT_START, MONITOR_OVLD_IBUF_MERGES},
1168
1169 {"ibuf_size", "change_buffer", "Change buffer size in pages",
1170 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
1171 MONITOR_DEFAULT_START, MONITOR_OVLD_IBUF_SIZE},
1172
1173 /* ========== Counters for server operations ========== */
1174 {"module_innodb", "innodb",
1175 "Counter for general InnoDB server wide operations and properties",
1176 MONITOR_MODULE, MONITOR_DEFAULT_START, MONITOR_MODULE_SERVER},
1177
1178 {"innodb_master_thread_sleeps", "server",
1179 "Number of times (seconds) master thread sleeps", MONITOR_NONE,
1180 MONITOR_DEFAULT_START, MONITOR_MASTER_THREAD_SLEEP},
1181
1182 {"innodb_activity_count", "server", "Current server activity count",
1183 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
1184 MONITOR_DEFAULT_START, MONITOR_OVLD_SERVER_ACTIVITY},
1185
1186 {"innodb_master_active_loops", "server",
1187 "Number of times master thread performs its tasks when"
1188 " server is active",
1189 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_MASTER_ACTIVE_LOOPS},
1190
1191 {"innodb_master_idle_loops", "server",
1192 "Number of times master thread performs its tasks when server is idle",
1193 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_MASTER_IDLE_LOOPS},
1194
1195 {"innodb_background_drop_table_usec", "server",
1196 "Time (in microseconds) spent to process drop table list", MONITOR_NONE,
1197 MONITOR_DEFAULT_START, MONITOR_SRV_BACKGROUND_DROP_TABLE_MICROSECOND},
1198
1199 {"innodb_ibuf_merge_usec", "server",
1200 "Time (in microseconds) spent to process change buffer merge",
1201 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_SRV_IBUF_MERGE_MICROSECOND},
1202
1203 {"innodb_mem_validate_usec", "server",
1204 "Time (in microseconds) spent to do memory validation", MONITOR_NONE,
1205 MONITOR_DEFAULT_START, MONITOR_SRV_MEM_VALIDATE_MICROSECOND},
1206
1207 {"innodb_master_purge_usec", "server",
1208 "Time (in microseconds) spent by master thread to purge records",
1209 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_SRV_PURGE_MICROSECOND},
1210
1211 {"innodb_dict_lru_usec", "server",
1212 "Time (in microseconds) spent to process DICT LRU list", MONITOR_NONE,
1213 MONITOR_DEFAULT_START, MONITOR_SRV_DICT_LRU_MICROSECOND},
1214
1215 {"innodb_dict_lru_count", "server",
1216 "Number of tables evicted from DICT LRU list", MONITOR_NONE,
1217 MONITOR_DEFAULT_START, MONITOR_SRV_DICT_LRU_EVICT_COUNT},
1218
1219 {"innodb_dblwr_writes", "server",
1220 "Number of doublewrite operations that have been performed"
1221 " (innodb_dblwr_writes)",
1222 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
1223 MONITOR_DEFAULT_START, MONITOR_OVLD_SRV_DBLWR_WRITES},
1224
1225 {"innodb_dblwr_pages_written", "server",
1226 "Number of pages that have been written for doublewrite operations"
1227 " (innodb_dblwr_pages_written)",
1228 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
1229 MONITOR_DEFAULT_START, MONITOR_OVLD_SRV_DBLWR_PAGES_WRITTEN},
1230
1231 {"innodb_page_size", "server",
1232 "InnoDB page size in bytes (innodb_page_size)",
1233 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON |
1234 MONITOR_DISPLAY_CURRENT),
1235 MONITOR_DEFAULT_START, MONITOR_OVLD_SRV_PAGE_SIZE},
1236
1237 {"innodb_rwlock_s_spin_waits", "server", "Deprecated counter, always 0",
1238 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
1239 MONITOR_DEFAULT_START, MONITOR_OVLD_RWLOCK_S_SPIN_WAITS},
1240
1241 {"innodb_rwlock_x_spin_waits", "server", "Deprecated counter, always 0",
1242 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
1243 MONITOR_DEFAULT_START, MONITOR_OVLD_RWLOCK_X_SPIN_WAITS},
1244
1245 {"innodb_rwlock_sx_spin_waits", "server", "Deprecated counter, always 0",
1246 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
1247 MONITOR_DEFAULT_START, MONITOR_OVLD_RWLOCK_SX_SPIN_WAITS},
1248
1249 {"innodb_rwlock_s_spin_rounds", "server", "Deprecated counter, always 0",
1250 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
1251 MONITOR_DEFAULT_START, MONITOR_OVLD_RWLOCK_S_SPIN_ROUNDS},
1252
1253 {"innodb_rwlock_x_spin_rounds", "server", "Deprecated counter, always 0",
1254 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
1255 MONITOR_DEFAULT_START, MONITOR_OVLD_RWLOCK_X_SPIN_ROUNDS},
1256
1257 {"innodb_rwlock_sx_spin_rounds", "server", "Deprecated counter, always 0",
1258 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
1259 MONITOR_DEFAULT_START, MONITOR_OVLD_RWLOCK_SX_SPIN_ROUNDS},
1260
1261 {"innodb_rwlock_s_os_waits", "server", "Deprecated counter, always 0",
1262 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
1263 MONITOR_DEFAULT_START, MONITOR_OVLD_RWLOCK_S_OS_WAITS},
1264
1265 {"innodb_rwlock_x_os_waits", "server", "Deprecated counter, always 0",
1266 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
1267 MONITOR_DEFAULT_START, MONITOR_OVLD_RWLOCK_X_OS_WAITS},
1268
1269 {"innodb_rwlock_sx_os_waits", "server", "Deprecated counter, always 0",
1270 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
1271 MONITOR_DEFAULT_START, MONITOR_OVLD_RWLOCK_SX_OS_WAITS},
1272
1273 /* ========== Counters for DML operations ========== */
1274 {"module_dml", "dml", "Statistics for DMLs", MONITOR_MODULE,
1275 MONITOR_DEFAULT_START, MONITOR_MODULE_DML_STATS},
1276
1277 {"dml_reads", "dml", "Number of rows read",
1278 static_cast<monitor_type_t>(MONITOR_EXISTING), MONITOR_DEFAULT_START,
1279 MONITOR_OLVD_ROW_READ},
1280
1281 {"dml_inserts", "dml", "Number of rows inserted",
1282 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
1283 MONITOR_DEFAULT_START, MONITOR_OLVD_ROW_INSERTED},
1284
1285 {"dml_deletes", "dml", "Number of rows deleted",
1286 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
1287 MONITOR_DEFAULT_START, MONITOR_OLVD_ROW_DELETED},
1288
1289 {"dml_updates", "dml", "Number of rows updated",
1290 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
1291 MONITOR_DEFAULT_START, MONITOR_OLVD_ROW_UPDTATED},
1292
1293 {"dml_system_reads", "dml", "Number of system rows read",
1294 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
1295 MONITOR_DEFAULT_START, MONITOR_OLVD_SYSTEM_ROW_READ},
1296
1297 {"dml_system_inserts", "dml", "Number of system rows inserted",
1298 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
1299 MONITOR_DEFAULT_START, MONITOR_OLVD_SYSTEM_ROW_INSERTED},
1300
1301 {"dml_system_deletes", "dml", "Number of system rows deleted",
1302 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
1303 MONITOR_DEFAULT_START, MONITOR_OLVD_SYSTEM_ROW_DELETED},
1304
1305 {"dml_system_updates", "dml", "Number of system rows updated",
1306 static_cast<monitor_type_t>(MONITOR_EXISTING | MONITOR_DEFAULT_ON),
1307 MONITOR_DEFAULT_START, MONITOR_OLVD_SYSTEM_ROW_UPDATED},
1308
1309 /* ========== Counters for sampling operations ========== */
1310 {"module_sampling", "sampling", "Statistics for sampling", MONITOR_MODULE,
1311 MONITOR_DEFAULT_START, MONITOR_MODULE_SAMPLING_STATS},
1312
1313 {"sampled_pages_read", "sampling", "Number of sampled pages read",
1314 static_cast<monitor_type_t>(MONITOR_EXISTING), MONITOR_DEFAULT_START,
1315 MONITOR_SAMPLED_PAGES_READ},
1316
1317 {"sampled_pages_skipped", "sampling", "Number of sampled pages skipped",
1318 static_cast<monitor_type_t>(MONITOR_EXISTING), MONITOR_DEFAULT_START,
1319 MONITOR_SAMPLED_PAGES_SKIPPED},
1320
1321 /* ========== Counters for DDL operations ========== */
1322 {"module_ddl", "ddl", "Statistics for DDLs", MONITOR_MODULE,
1323 MONITOR_DEFAULT_START, MONITOR_MODULE_DDL_STATS},
1324
1325 {"ddl_background_drop_tables", "ddl",
1326 "Number of tables in background drop table list", MONITOR_NONE,
1327 MONITOR_DEFAULT_START, MONITOR_BACKGROUND_DROP_TABLE},
1328
1329 {"ddl_online_create_index", "ddl", "Number of indexes being created online",
1330 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_ONLINE_CREATE_INDEX},
1331
1332 {"ddl_pending_alter_table", "ddl",
1333 "Number of ALTER TABLE, CREATE INDEX, DROP INDEX in progress",
1334 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_PENDING_ALTER_TABLE},
1335
1336 {"ddl_sort_file_alter_table", "ddl",
1337 "Number of sort files created during alter table", MONITOR_NONE,
1338 MONITOR_DEFAULT_START, MONITOR_ALTER_TABLE_SORT_FILES},
1339
1340 {"ddl_log_file_alter_table", "ddl",
1341 "Number of log files created during alter table", MONITOR_NONE,
1342 MONITOR_DEFAULT_START, MONITOR_ALTER_TABLE_LOG_FILES},
1343
1344 /* ===== Counters for ICP (Index Condition Pushdown) Module ===== */
1345 {"module_icp", "icp", "Index Condition Pushdown", MONITOR_MODULE,
1346 MONITOR_DEFAULT_START, MONITOR_MODULE_ICP},
1347
1348 {"icp_attempts", "icp",
1349 "Number of attempts for index push-down condition checks", MONITOR_NONE,
1350 MONITOR_DEFAULT_START, MONITOR_ICP_ATTEMPTS},
1351
1352 {"icp_no_match", "icp", "Index push-down condition does not match",
1353 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_ICP_NO_MATCH},
1354
1355 {"icp_out_of_range", "icp", "Index push-down condition out of range",
1356 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_ICP_OUT_OF_RANGE},
1357
1358 {"icp_match", "icp", "Index push-down condition matches", MONITOR_NONE,
1359 MONITOR_DEFAULT_START, MONITOR_ICP_MATCH},
1360
1361 /* ========== Mutex monitoring on/off ========== */
1362 {"latch_status", "Latch counters",
1363 "Collect latch counters to display via SHOW ENGINE INNODB MUTEX",
1364 MONITOR_MODULE, MONITOR_DEFAULT_START, MONITOR_MODULE_LATCHES},
1365
1366 {"latch", "sync", "Latch monitoring control", MONITOR_HIDDEN,
1367 MONITOR_DEFAULT_START, MONITOR_LATCHES},
1368
1369 /* ========== CPU usage ========== */
1370 {"module_cpu", "cpu", "CPU counters reflecting current usage of CPU",
1371 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_MODULE_CPU},
1372
1373 {"cpu_utime_abs", "cpu", "Total CPU user time spent", MONITOR_NONE,
1374 MONITOR_DEFAULT_START, MONITOR_CPU_UTIME_ABS},
1375
1376 {"cpu_stime_abs", "cpu", "Total CPU system time spent", MONITOR_NONE,
1377 MONITOR_DEFAULT_START, MONITOR_CPU_STIME_ABS},
1378
1379 {"cpu_utime_pct", "cpu", "Relative CPU user time spent", MONITOR_NONE,
1380 MONITOR_DEFAULT_START, MONITOR_CPU_UTIME_PCT},
1381
1382 {"cpu_stime_pct", "cpu", "Relative CPU system time spent", MONITOR_NONE,
1383 MONITOR_DEFAULT_START, MONITOR_CPU_STIME_PCT},
1384
1385 {"cpu_n", "cpu", "Number of cpus", MONITOR_NONE, MONITOR_DEFAULT_START,
1386 MONITOR_CPU_N},
1387
1388 /* ========== Page track usage ========== */
1389 {"module_page_track", "page_track", "Counters related to page tracking",
1390 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_MODULE_PAGE_TRACK},
1391
1392 {"page_track_resets", "page_track", "Number of resets", MONITOR_NONE,
1393 MONITOR_DEFAULT_START, MONITOR_PAGE_TRACK_RESETS},
1394
1395 {"page_track_partial_block_writes", "page_track",
1396 "Number of partial block writes", MONITOR_NONE, MONITOR_DEFAULT_START,
1397 MONITOR_PAGE_TRACK_PARTIAL_BLOCK_WRITES},
1398
1399 {"page_track_full_block_writes", "page_track",
1400 "Number of full block writes", MONITOR_NONE, MONITOR_DEFAULT_START,
1401 MONITOR_PAGE_TRACK_FULL_BLOCK_WRITES},
1402
1403 {"page_track_checkpoint_partial_flush_request", "page_track",
1404 "Number of partial flush requests made during checkpointing", MONITOR_NONE,
1405 MONITOR_DEFAULT_START,
1406 MONITOR_PAGE_TRACK_CHECKPOINT_PARTIAL_FLUSH_REQUEST},
1407
1408 /* ========== Double write ========== */
1409 {"module_dblwr", "dblwr", "Counters related to double writes", MONITOR_NONE,
1410 MONITOR_DEFAULT_START, MONITOR_MODULE_DBLWR},
1411
1412 {"dblwr_async_requests", "dblwr", "Total async requests", MONITOR_NONE,
1413 MONITOR_DEFAULT_START, MONITOR_DBLWR_ASYNC_REQUESTS},
1414
1415 {"dblwr_sync_requests", "dblwr", "Total sync enqueue requests",
1416 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_DBLWR_SYNC_REQUESTS},
1417
1418 {"dblwr_flush_requests", "dblwr", "Total flush requests", MONITOR_NONE,
1419 MONITOR_DEFAULT_START, MONITOR_DBLWR_FLUSH_REQUESTS},
1420
1421 {"dblwr_flush_wait_events", "dblwr", "Total flush wait events",
1422 MONITOR_NONE, MONITOR_DEFAULT_START, MONITOR_DBLWR_FLUSH_WAIT_EVENTS},
1423
1424 /* ========== To turn on/off reset all counters ========== */
1425 {"all", "All Counters", "Turn on/off and reset all counters",
1426 MONITOR_MODULE, MONITOR_DEFAULT_START, MONITOR_ALL_COUNTER},
1427 };
1428
1429 /* The "innodb_counter_value" array stores actual counter values */
1430 monitor_value_t innodb_counter_value[NUM_MONITOR];
1431
1432 /* monitor_set_tbl is used to record and determine whether a monitor
1433 has been turned on/off. */
1434 std::bitset<NUM_MONITOR> monitor_set_tbl;
1435
1436 /** Get a monitor's "monitor_info" by its monitor id (index into the
1437 innodb_counter_info array.
1438 @return Point to corresponding monitor_info_t, or NULL if no such
1439 monitor */
1440 monitor_info_t *srv_mon_get_info(
1441 monitor_id_t monitor_id) /*!< id indexing into the
1442 innodb_counter_info array */
1443 {
1444 ut_a(monitor_id < NUM_MONITOR);
1445
1446 return ((monitor_id < NUM_MONITOR) ? &innodb_counter_info[monitor_id]
1447 : nullptr);
1448 }
1449
1450 /** Get monitor's name by its monitor id (indexing into the
1451 innodb_counter_info array.
1452 @return corresponding monitor name, or NULL if no such
1453 monitor */
1454 const char *srv_mon_get_name(
1455 monitor_id_t monitor_id) /*!< id index into the
1456 innodb_counter_info array */
1457 {
1458 ut_a(monitor_id < NUM_MONITOR);
1459
1460 return ((monitor_id < NUM_MONITOR)
1461 ? innodb_counter_info[monitor_id].monitor_name
1462 : nullptr);
1463 }
1464
1465 /** Turn on/off, reset monitor counters in a module. If module_id
1466 is MONITOR_ALL_COUNTER then turn on all monitor counters.
1467 turned on because it has already been turned on. */
1468 void srv_mon_set_module_control(
1469 monitor_id_t module_id, /*!< in: Module ID as in
1470 monitor_counter_id. If it is
1471 set to MONITOR_ALL_COUNTER, this means
1472 we shall turn on all the counters */
1473 mon_option_t set_option) /*!< in: Turn on/off reset the
1474 counter */
1475 {
1476 ulint ix;
1477 ulint start_id;
1478 bool set_current_module = false;
1479
1480 ut_a(module_id <= NUM_MONITOR);
1481 static_assert(UT_ARR_SIZE(innodb_counter_info) == NUM_MONITOR);
1482
1483 /* The module_id must be an ID of MONITOR_MODULE type */
1484 ut_a(innodb_counter_info[module_id].monitor_type & MONITOR_MODULE);
1485
1486 /* start with the first monitor in the module. If module_id
1487 is MONITOR_ALL_COUNTER, this means we need to turn on all
1488 monitor counters. */
1489 if (module_id == MONITOR_ALL_COUNTER) {
1490 start_id = 1;
1491 } else if (innodb_counter_info[module_id].monitor_type &
1492 MONITOR_GROUP_MODULE) {
1493 /* Counters in this module are set as a group together
1494 and cannot be turned on/off individually. Need to set
1495 the on/off bit in the module counter */
1496 start_id = module_id;
1497 set_current_module = true;
1498
1499 } else {
1500 start_id = module_id + 1;
1501 }
1502
1503 for (ix = start_id; ix < NUM_MONITOR; ix++) {
1504 /* if we hit the next module counter, we will
1505 continue if we want to turn on all monitor counters,
1506 and break if just turn on the counters in the
1507 current module. */
1508 if (innodb_counter_info[ix].monitor_type & MONITOR_MODULE) {
1509 if (set_current_module) {
1510 /* Continue to set on/off bit on current
1511 module */
1512 set_current_module = false;
1513 } else if (module_id == MONITOR_ALL_COUNTER) {
1514 if (!(innodb_counter_info[ix].monitor_type & MONITOR_GROUP_MODULE)) {
1515 continue;
1516 }
1517 } else {
1518 /* Hitting the next module, stop */
1519 break;
1520 }
1521 }
1522
1523 /* Cannot turn on a monitor already been turned on. User
1524 should be aware some counters are already on before
1525 turn them on again (which could reset counter value) */
1526 if (MONITOR_IS_ON(ix) && (set_option == MONITOR_TURN_ON)) {
1527 ib::info(ER_IB_MSG_1045)
1528 << "Monitor '" << srv_mon_get_name((monitor_id_t)ix)
1529 << "' is already enabled.";
1530 continue;
1531 }
1532
1533 /* For some existing counters (server status variables),
1534 we will get its counter value at the start/stop time
1535 to calculate the actual value during the time. */
1536 if (innodb_counter_info[ix].monitor_type & MONITOR_EXISTING) {
1537 srv_mon_process_existing_counter(static_cast<monitor_id_t>(ix),
1538 set_option);
1539 }
1540
1541 /* Currently support 4 operations on the monitor counters:
1542 turn on, turn off, reset and reset all operations. */
1543 switch (set_option) {
1544 case MONITOR_TURN_ON:
1545 MONITOR_ON(ix);
1546 MONITOR_INIT(ix);
1547 MONITOR_SET_START(ix);
1548 break;
1549
1550 case MONITOR_TURN_OFF:
1551 MONITOR_OFF(ix);
1552 MONITOR_SET_OFF(ix);
1553 break;
1554
1555 case MONITOR_RESET_VALUE:
1556 srv_mon_reset(static_cast<monitor_id_t>(ix));
1557 break;
1558
1559 case MONITOR_RESET_ALL_VALUE:
1560 srv_mon_reset_all(static_cast<monitor_id_t>(ix));
1561 break;
1562
1563 default:
1564 ut_error;
1565 }
1566 }
1567 }
1568
1569 /** Get transaction system's rollback segment size in pages.
1570 @return size in pages */
1571 static ulint srv_mon_get_rseg_size(void) {
1572 ulint value = 0;
1573 ulong cur_rsegs = srv_rollback_segments;
1574
1575 /* Rollback segments used in the temporary tablespace */
1576 trx_sys->tmp_rsegs.s_lock();
1577 for (const auto tmp_rseg : trx_sys->tmp_rsegs) {
1578 value += tmp_rseg->get_curr_size();
1579 }
1580 trx_sys->tmp_rsegs.s_unlock();
1581
1582 undo::spaces->s_lock();
1583 for (auto undo_space : undo::spaces->m_spaces) {
1584 for (auto rseg : *undo_space->rsegs()) {
1585 if (rseg->id >= cur_rsegs) {
1586 break;
1587 }
1588
1589 value += rseg->get_curr_size();
1590 }
1591 }
1592 undo::spaces->s_unlock();
1593
1594 return (value);
1595 }
1596
1597 /** This function consolidates some existing server counters used
1598 by "system status variables". These existing system variables do not have
1599 mechanism to start/stop and reset the counters, so we simulate these
1600 controls by remembering the corresponding counter values when the
1601 corresponding monitors are turned on/off/reset, and do appropriate
1602 mathematics to deduct the actual value. Please also refer to
1603 srv_export_innodb_status() for related global counters used by
1604 the existing status variables.*/
1605 void srv_mon_process_existing_counter(
1606 monitor_id_t monitor_id, /*!< in: the monitor's ID as in
1607 monitor_counter_id */
1608 mon_option_t set_option) /*!< in: Turn on/off reset the
1609 counter */
1610 {
1611 mon_type_t value;
1612 monitor_info_t *monitor_info;
1613 bool update_min = false;
1614 buf_pool_stat_t stat;
1615 buf_pools_list_size_t buf_pools_list_size;
1616 ulint LRU_len;
1617 ulint free_len;
1618 ulint flush_list_len;
1619
1620 monitor_info = srv_mon_get_info(monitor_id);
1621
1622 ut_a(monitor_info->monitor_type & MONITOR_EXISTING);
1623 ut_a(monitor_id < NUM_MONITOR);
1624
1625 /* Get the value from corresponding global variable */
1626 switch (monitor_id) {
1627 /* export_vars.innodb_buffer_pool_reads. Num Reads from
1628 disk (page not in buffer) */
1629 case MONITOR_OVLD_BUF_POOL_READS:
1630 value = srv_stats.buf_pool_reads;
1631 break;
1632
1633 /* innodb_buffer_pool_read_requests, the number of logical
1634 read requests */
1635 case MONITOR_OVLD_BUF_POOL_READ_REQUESTS:
1636 buf_get_total_stat(&stat);
1637 value = Counter::total(stat.m_n_page_gets);
1638 break;
1639
1640 /* innodb_buffer_pool_write_requests, the number of
1641 write request */
1642 case MONITOR_OVLD_BUF_POOL_WRITE_REQUEST:
1643 value = srv_stats.buf_pool_write_requests;
1644 break;
1645
1646 /* innodb_buffer_pool_wait_free */
1647 case MONITOR_OVLD_BUF_POOL_WAIT_FREE:
1648 value = srv_stats.buf_pool_wait_free;
1649 break;
1650
1651 /* innodb_buffer_pool_read_ahead */
1652 case MONITOR_OVLD_BUF_POOL_READ_AHEAD:
1653 buf_get_total_stat(&stat);
1654 value = stat.n_ra_pages_read;
1655 break;
1656
1657 /* innodb_buffer_pool_read_ahead_evicted */
1658 case MONITOR_OVLD_BUF_POOL_READ_AHEAD_EVICTED:
1659 buf_get_total_stat(&stat);
1660 value = stat.n_ra_pages_evicted;
1661 break;
1662
1663 /* innodb_buffer_pool_pages_total */
1664 case MONITOR_OVLD_BUF_POOL_PAGE_TOTAL:
1665 value = buf_pool_get_n_pages();
1666 break;
1667
1668 /* innodb_buffer_pool_pages_misc */
1669 case MONITOR_OVLD_BUF_POOL_PAGE_MISC:
1670 buf_get_total_list_len(&LRU_len, &free_len, &flush_list_len);
1671 value = buf_pool_get_n_pages() - LRU_len - free_len;
1672 break;
1673
1674 /* innodb_buffer_pool_pages_data */
1675 case MONITOR_OVLD_BUF_POOL_PAGES_DATA:
1676 buf_get_total_list_len(&LRU_len, &free_len, &flush_list_len);
1677 value = LRU_len;
1678 break;
1679
1680 /* innodb_buffer_pool_bytes_data */
1681 case MONITOR_OVLD_BUF_POOL_BYTES_DATA:
1682 buf_get_total_list_size_in_bytes(&buf_pools_list_size);
1683 value =
1684 buf_pools_list_size.LRU_bytes + buf_pools_list_size.unzip_LRU_bytes;
1685 break;
1686
1687 /* innodb_buffer_pool_pages_dirty */
1688 case MONITOR_OVLD_BUF_POOL_PAGES_DIRTY:
1689 buf_get_total_list_len(&LRU_len, &free_len, &flush_list_len);
1690 value = flush_list_len;
1691 break;
1692
1693 /* innodb_buffer_pool_bytes_dirty */
1694 case MONITOR_OVLD_BUF_POOL_BYTES_DIRTY:
1695 buf_get_total_list_size_in_bytes(&buf_pools_list_size);
1696 value = buf_pools_list_size.flush_list_bytes;
1697 break;
1698
1699 /* innodb_buffer_pool_pages_free */
1700 case MONITOR_OVLD_BUF_POOL_PAGES_FREE:
1701 buf_get_total_list_len(&LRU_len, &free_len, &flush_list_len);
1702 value = free_len;
1703 break;
1704
1705 /* innodb_pages_created, the number of pages created */
1706 case MONITOR_OVLD_PAGE_CREATED:
1707 buf_get_total_stat(&stat);
1708 value = stat.n_pages_created;
1709 break;
1710
1711 /* innodb_pages_written, the number of page written */
1712 case MONITOR_OVLD_PAGES_WRITTEN:
1713 buf_get_total_stat(&stat);
1714 value = stat.n_pages_written;
1715 break;
1716
1717 /* innodb_pages_read */
1718 case MONITOR_OVLD_PAGES_READ:
1719 buf_get_total_stat(&stat);
1720 value = stat.n_pages_read;
1721 break;
1722
1723 /* innodb_data_reads, the total number of data reads */
1724 case MONITOR_OVLD_BYTE_READ:
1725 value = srv_stats.data_read;
1726 break;
1727
1728 /* innodb_data_writes, the total number of data writes. */
1729 case MONITOR_OVLD_BYTE_WRITTEN:
1730 value = srv_stats.data_written;
1731 break;
1732
1733 /* innodb_data_reads, the total number of data reads. */
1734 case MONITOR_OVLD_OS_FILE_READ:
1735 value = os_n_file_reads;
1736 break;
1737
1738 /* innodb_data_writes, the total number of data writes*/
1739 case MONITOR_OVLD_OS_FILE_WRITE:
1740 value = os_n_file_writes;
1741 break;
1742
1743 /* innodb_data_fsyncs, number of fsync() operations so far. */
1744 case MONITOR_OVLD_OS_FSYNC:
1745 value = os_n_fsyncs;
1746 break;
1747
1748 /* innodb_os_log_written */
1749 case MONITOR_OVLD_OS_LOG_WRITTEN:
1750 value = (mon_type_t)srv_stats.os_log_written;
1751 break;
1752
1753 /* innodb_os_log_fsyncs */
1754 case MONITOR_OVLD_OS_LOG_FSYNC:
1755 value = log_total_flushes();
1756 break;
1757
1758 /* innodb_os_log_pending_fsyncs */
1759 case MONITOR_OVLD_OS_LOG_PENDING_FSYNC:
1760 value = log_pending_flushes();
1761 update_min = true;
1762 break;
1763
1764 /* innodb_os_log_pending_writes */
1765 case MONITOR_OVLD_OS_LOG_PENDING_WRITES:
1766 value = srv_stats.os_log_pending_writes;
1767 update_min = true;
1768 break;
1769
1770 /* innodb_log_waits */
1771 case MONITOR_OVLD_LOG_WAITS:
1772 value = srv_stats.log_waits;
1773 break;
1774
1775 /* innodb_log_write_requests */
1776 case MONITOR_OVLD_LOG_WRITE_REQUEST:
1777 value = srv_stats.log_write_requests;
1778 break;
1779
1780 /* innodb_log_writes */
1781 case MONITOR_OVLD_LOG_WRITES:
1782 value = srv_stats.log_writes;
1783 break;
1784
1785 /* innodb_dblwr_writes */
1786 case MONITOR_OVLD_SRV_DBLWR_WRITES:
1787 value = srv_stats.dblwr_writes;
1788 break;
1789
1790 /* innodb_dblwr_pages_written */
1791 case MONITOR_OVLD_SRV_DBLWR_PAGES_WRITTEN:
1792 value = srv_stats.dblwr_pages_written;
1793 break;
1794
1795 /* innodb_page_size */
1796 case MONITOR_OVLD_SRV_PAGE_SIZE:
1797 value = UNIV_PAGE_SIZE;
1798 break;
1799
1800 case MONITOR_OVLD_RWLOCK_S_SPIN_WAITS:
1801 case MONITOR_OVLD_RWLOCK_X_SPIN_WAITS:
1802 case MONITOR_OVLD_RWLOCK_SX_SPIN_WAITS:
1803 case MONITOR_OVLD_RWLOCK_S_SPIN_ROUNDS:
1804 case MONITOR_OVLD_RWLOCK_X_SPIN_ROUNDS:
1805 case MONITOR_OVLD_RWLOCK_SX_SPIN_ROUNDS:
1806 case MONITOR_OVLD_RWLOCK_S_OS_WAITS:
1807 case MONITOR_OVLD_RWLOCK_X_OS_WAITS:
1808 case MONITOR_OVLD_RWLOCK_SX_OS_WAITS:
1809 /* Deprecated counter. remained for compatibility. */
1810 value = 0;
1811 break;
1812
1813 case MONITOR_OVLD_BUFFER_POOL_SIZE:
1814 value = srv_buf_pool_size;
1815 break;
1816
1817 /* innodb_rows_read */
1818 case MONITOR_OLVD_ROW_READ:
1819 value = srv_stats.n_rows_read;
1820 break;
1821
1822 /* innodb_rows_inserted */
1823 case MONITOR_OLVD_ROW_INSERTED:
1824 value = srv_stats.n_rows_inserted;
1825 break;
1826
1827 /* innodb_rows_deleted */
1828 case MONITOR_OLVD_ROW_DELETED:
1829 value = srv_stats.n_rows_deleted;
1830 break;
1831
1832 /* innodb_rows_updated */
1833 case MONITOR_OLVD_ROW_UPDTATED:
1834 value = srv_stats.n_rows_updated;
1835 break;
1836
1837 /* innodb_system_rows_read */
1838 case MONITOR_OLVD_SYSTEM_ROW_READ:
1839 value = srv_stats.n_system_rows_read;
1840 break;
1841
1842 /* innodb_system_rows_inserted */
1843 case MONITOR_OLVD_SYSTEM_ROW_INSERTED:
1844 value = srv_stats.n_system_rows_inserted;
1845 break;
1846
1847 /* innodb_system_rows_deleted */
1848 case MONITOR_OLVD_SYSTEM_ROW_DELETED:
1849 value = srv_stats.n_system_rows_deleted;
1850 break;
1851
1852 /* innodb_system_rows_updated */
1853 case MONITOR_OLVD_SYSTEM_ROW_UPDATED:
1854 value = srv_stats.n_system_rows_updated;
1855 break;
1856
1857 case MONITOR_SAMPLED_PAGES_READ:
1858 value = srv_stats.n_sampled_pages_read;
1859 break;
1860
1861 case MONITOR_SAMPLED_PAGES_SKIPPED:
1862 value = srv_stats.n_sampled_pages_skipped;
1863 break;
1864
1865 /* innodb_row_lock_current_waits */
1866 case MONITOR_OVLD_ROW_LOCK_CURRENT_WAIT:
1867 value = srv_stats.n_lock_wait_current_count;
1868 break;
1869
1870 /* innodb_row_lock_time */
1871 case MONITOR_OVLD_LOCK_WAIT_TIME:
1872 value = srv_stats.n_lock_wait_time / 1000;
1873 break;
1874
1875 /* innodb_row_lock_time_max */
1876 case MONITOR_OVLD_LOCK_MAX_WAIT_TIME:
1877 value = std::chrono::duration_cast<std::chrono::milliseconds>(
1878 lock_sys->n_lock_max_wait_time)
1879 .count();
1880 break;
1881
1882 /* innodb_row_lock_time_avg */
1883 case MONITOR_OVLD_LOCK_AVG_WAIT_TIME:
1884 if (srv_stats.n_lock_wait_count > 0) {
1885 value = srv_stats.n_lock_wait_time / 1000 / srv_stats.n_lock_wait_count;
1886 } else {
1887 value = 0;
1888 }
1889 break;
1890
1891 /* innodb_row_lock_waits */
1892 case MONITOR_OVLD_ROW_LOCK_WAIT:
1893 value = srv_stats.n_lock_wait_count;
1894 break;
1895
1896 case MONITOR_RSEG_HISTORY_LEN:
1897 value = trx_sys->rseg_history_len;
1898 break;
1899
1900 case MONITOR_RSEG_CUR_SIZE:
1901 value = srv_mon_get_rseg_size();
1902 break;
1903
1904 case MONITOR_OVLD_N_FILE_OPENED:
1905 value = fil_n_files_open.load();
1906 break;
1907
1908 case MONITOR_OVLD_IBUF_MERGE_INSERT:
1909 value = ibuf->n_merged_ops[IBUF_OP_INSERT];
1910 break;
1911
1912 case MONITOR_OVLD_IBUF_MERGE_DELETE:
1913 value = ibuf->n_merged_ops[IBUF_OP_DELETE_MARK];
1914 break;
1915
1916 case MONITOR_OVLD_IBUF_MERGE_PURGE:
1917 value = ibuf->n_merged_ops[IBUF_OP_DELETE];
1918 break;
1919
1920 case MONITOR_OVLD_IBUF_MERGE_DISCARD_INSERT:
1921 value = ibuf->n_discarded_ops[IBUF_OP_INSERT];
1922 break;
1923
1924 case MONITOR_OVLD_IBUF_MERGE_DISCARD_DELETE:
1925 value = ibuf->n_discarded_ops[IBUF_OP_DELETE_MARK];
1926 break;
1927
1928 case MONITOR_OVLD_IBUF_MERGE_DISCARD_PURGE:
1929 value = ibuf->n_discarded_ops[IBUF_OP_DELETE];
1930 break;
1931
1932 case MONITOR_OVLD_IBUF_MERGES:
1933 value = ibuf->n_merges;
1934 break;
1935
1936 case MONITOR_OVLD_IBUF_SIZE:
1937 value = ibuf->size;
1938 break;
1939
1940 case MONITOR_OVLD_SERVER_ACTIVITY:
1941 value = srv_get_activity_count();
1942 break;
1943
1944 case MONITOR_OVLD_LSN_FLUSHDISK:
1945 value = static_cast<mon_type_t>(log_sys->flushed_to_disk_lsn.load());
1946 break;
1947
1948 case MONITOR_OVLD_LSN_CURRENT:
1949 value = static_cast<mon_type_t>(log_get_lsn(*log_sys));
1950 break;
1951
1952 case MONITOR_OVLD_LSN_ARCHIVED: {
1953 auto arch_lsn = arch_log_sys->get_archived_lsn();
1954 if (arch_lsn == LSN_MAX) {
1955 value = 0;
1956 } else {
1957 value = static_cast<mon_type_t>(arch_lsn);
1958 }
1959 } break;
1960
1961 case MONITOR_OVLD_LSN_BUF_DIRTY_PAGES_ADDED:
1962 value = (mon_type_t)log_buffer_dirty_pages_added_up_to_lsn(*log_sys);
1963 break;
1964
1965 case MONITOR_OVLD_BUF_OLDEST_LSN_APPROX:
1966 value = (mon_type_t)buf_pool_get_oldest_modification_approx();
1967 break;
1968
1969 case MONITOR_OVLD_BUF_OLDEST_LSN_LWM:
1970 value = (mon_type_t)buf_pool_get_oldest_modification_lwm();
1971 break;
1972
1973 case MONITOR_OVLD_LSN_CHECKPOINT:
1974 value = (mon_type_t)log_sys->last_checkpoint_lsn.load();
1975 break;
1976
1977 case MONITOR_OVLD_LSN_CHECKPOINT_AGE:
1978 value = (mon_type_t)log_get_checkpoint_age(*log_sys);
1979 break;
1980
1981 case MONITOR_OVLD_MAX_AGE_ASYNC:
1982 value = log_sys->m_capacity.adaptive_flush_min_age();
1983 break;
1984
1985 case MONITOR_OVLD_MAX_AGE_SYNC:
1986 value = log_sys->m_capacity.adaptive_flush_max_age();
1987 break;
1988 case MONITOR_OVLD_ADAPTIVE_HASH_SEARCH:
1989 value = btr_cur_n_sea;
1990 break;
1991
1992 case MONITOR_OVLD_ADAPTIVE_HASH_SEARCH_BTREE:
1993 value = btr_cur_n_non_sea;
1994 break;
1995
1996 default:
1997 ut_error;
1998 }
1999
2000 switch (set_option) {
2001 case MONITOR_TURN_ON:
2002 /* Save the initial counter value in mon_start_value
2003 field */
2004 MONITOR_SAVE_START(monitor_id, value);
2005 return;
2006
2007 case MONITOR_TURN_OFF:
2008 /* Save the counter value to mon_last_value when we
2009 turn off the monitor but not yet reset. Note the
2010 counter has not yet been set to off in the bitmap
2011 table for normal turn off. We need to check the
2012 count status (on/off) to avoid reset the value
2013 for an already off counter */
2014 if (MONITOR_IS_ON(monitor_id)) {
2015 srv_mon_process_existing_counter(monitor_id, MONITOR_GET_VALUE);
2016 MONITOR_SAVE_LAST(monitor_id);
2017 }
2018 return;
2019
2020 case MONITOR_GET_VALUE:
2021 if (MONITOR_IS_ON(monitor_id)) {
2022 /* If MONITOR_DISPLAY_CURRENT bit is on, we
2023 only record the current value, rather than
2024 incremental value over a period. Most of
2025 ` this type of counters are resource related
2026 counters such as number of buffer pages etc. */
2027 if (monitor_info->monitor_type & MONITOR_DISPLAY_CURRENT) {
2028 MONITOR_SET(monitor_id, value);
2029 } else {
2030 /* Most status counters are monotonically
2031 increasing, no need to update their
2032 minimum values. Only do so
2033 if "update_min" set to true */
2034 MONITOR_SET_DIFF(monitor_id, value);
2035
2036 if (update_min &&
2037 (MONITOR_VALUE(monitor_id) < MONITOR_MIN_VALUE(monitor_id))) {
2038 MONITOR_MIN_VALUE(monitor_id) = MONITOR_VALUE(monitor_id);
2039 }
2040 }
2041 }
2042 return;
2043
2044 case MONITOR_RESET_VALUE:
2045 if (!MONITOR_IS_ON(monitor_id)) {
2046 MONITOR_LAST_VALUE(monitor_id) = 0;
2047 }
2048 return;
2049
2050 /* Nothing special for reset all operation for these existing
2051 counters */
2052 case MONITOR_RESET_ALL_VALUE:
2053 return;
2054 }
2055 }
2056
2057 /** Reset a monitor, create a new base line with the current monitor
2058 value. This baseline is recorded by MONITOR_VALUE_RESET(monitor) */
2059 void srv_mon_reset(monitor_id_t monitor) /*!< in: monitor id */
2060 {
2061 bool monitor_was_on;
2062
2063 monitor_was_on = MONITOR_IS_ON(monitor);
2064
2065 if (monitor_was_on) {
2066 /* Temporarily turn off the counter for the resetting
2067 operation */
2068 MONITOR_OFF(monitor);
2069 }
2070
2071 /* Before resetting the current monitor value, first
2072 calculate and set the max/min value since monitor
2073 start */
2074 srv_mon_calc_max_since_start(monitor);
2075 srv_mon_calc_min_since_start(monitor);
2076
2077 /* Monitors with MONITOR_DISPLAY_CURRENT bit
2078 are not incremental, no need to remember
2079 the reset value. */
2080 if (innodb_counter_info[monitor].monitor_type & MONITOR_DISPLAY_CURRENT) {
2081 MONITOR_VALUE_RESET(monitor) = 0;
2082 } else {
2083 /* Remember the new baseline */
2084 MONITOR_VALUE_RESET(monitor) =
2085 MONITOR_VALUE_RESET(monitor) + MONITOR_VALUE(monitor);
2086 }
2087
2088 /* Reset the counter value */
2089 MONITOR_VALUE(monitor) = 0;
2090 MONITOR_MAX_VALUE(monitor) = MAX_RESERVED;
2091 MONITOR_MIN_VALUE(monitor) = MIN_RESERVED;
2092
2093 MONITOR_FIELD((monitor), mon_reset_time) = std::chrono::system_clock::now();
2094
2095 if (monitor_was_on) {
2096 MONITOR_ON(monitor);
2097 }
2098 }
2099
2100 /** Turn on monitor counters that are marked as default ON. */
2101 void srv_mon_default_on(void) {
2102 ulint ix;
2103
2104 for (ix = 0; ix < NUM_MONITOR; ix++) {
2105 if (innodb_counter_info[ix].monitor_type & MONITOR_DEFAULT_ON) {
2106 /* Turn on monitor counters that are default on */
2107 MONITOR_ON(ix);
2108 MONITOR_INIT(ix);
2109 MONITOR_SET_START(ix);
2110 }
2111 }
2112 }