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