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