MySQL 8.0.40
Source Code Documentation
srv0mon.cc File Reference

Database monitor counter interfaces. More...

#include <time.h>
#include "arch0arch.h"
#include "buf0buf.h"
#include "dict0mem.h"
#include "ibuf0ibuf.h"
#include "lock0lock.h"
#include "log0buf.h"
#include "log0chkp.h"
#include "log0write.h"
#include "mach0data.h"
#include "os0file.h"
#include "srv0mon.h"
#include "srv0srv.h"
#include "trx0purge.h"
#include "trx0rseg.h"
#include "trx0sys.h"

Macros

#define MONITOR_BUF_PAGE(name, description, code, op, op_code)
 
#define MONITOR_BUF_PAGE_READ(name, description, code)    MONITOR_BUF_PAGE(name, description, code, "read", PAGE_READ)
 
#define MONITOR_BUF_PAGE_WRITTEN(name, description, code)    MONITOR_BUF_PAGE(name, description, code, "written", PAGE_WRITTEN)
 
#define MONITOR_WAIT_STATS_EX(name, module, description, code, wrap)
 
#define MONITOR_WAIT_STATS_SIMPLE_WRAP(a1, a2, a3, a4, a5, a6)    { a1, a2, a3, a4, a5, a6 }
 
#define MONITOR_WAIT_STATS(name, module, description, code)
 
#define MONITOR_BUF_PAGE_WRITTEN_WAIT_STATS_WRAP(name, module, description, a, b, code)    MONITOR_BUF_PAGE_WRITTEN(name, description, code)
 
#define MONITOR_BUF_PAGE_WRITTEN_WAIT_STATS(name, description, code)
 

Functions

monitor_info_tsrv_mon_get_info (monitor_id_t monitor_id)
 Get a monitor's "monitor_info" by its monitor id (index into the innodb_counter_info array. More...
 
const char * srv_mon_get_name (monitor_id_t monitor_id)
 Get monitor's name by its monitor id (indexing into the innodb_counter_info array. More...
 
void srv_mon_set_module_control (monitor_id_t module_id, mon_option_t set_option)
 Turn on/off, reset monitor counters in a module. More...
 
static ulint srv_mon_get_rseg_size (void)
 Get transaction system's rollback segment size in pages. More...
 
void srv_mon_process_existing_counter (monitor_id_t monitor_id, mon_option_t set_option)
 This function consolidates some existing server counters used by "system status variables". More...
 
void srv_mon_reset (monitor_id_t monitor)
 Reset a monitor, create a new base line with the current monitor value. More...
 
void srv_mon_default_on (void)
 Turn on monitor counters that are marked as default ON. More...
 

Variables

static monitor_info_t innodb_counter_info []
 This array defines basic static information of monitor counters, including each monitor's name, module it belongs to, a short description and its property/type and corresponding monitor_id. More...
 
monitor_value_t innodb_counter_value [NUM_MONITOR]
 The actual monitor counter array that records each monitor counter value. More...
 
std::bitset< NUM_MONITORmonitor_set_tbl
 This "monitor_set_tbl" is a bitmap records whether a particular monitor counter has been turned on or off. More...
 

Detailed Description

Database monitor counter interfaces.

Created 12/9/2009 Jimmy Yang

Macro Definition Documentation

◆ MONITOR_BUF_PAGE

#define MONITOR_BUF_PAGE (   name,
  description,
  code,
  op,
  op_code 
)
Value:
{ \
"buffer_page_" op "_" name, "buffer_page_io", \
"Number of " description " Pages " op, MONITOR_GROUP_MODULE, \
MONITOR_DEFAULT_START, MONITOR_##code##_##op_code \
}
@ MONITOR_GROUP_MODULE
Monitor can be turned on/off only as a module, but not individually.
Definition: srv0mon.h:104
case opt name
Definition: sslopt-case.h:33
#define _(str)
Definition: win_i18n.h:33

◆ MONITOR_BUF_PAGE_READ

#define MONITOR_BUF_PAGE_READ (   name,
  description,
  code 
)     MONITOR_BUF_PAGE(name, description, code, "read", PAGE_READ)

◆ MONITOR_BUF_PAGE_WRITTEN

#define MONITOR_BUF_PAGE_WRITTEN (   name,
  description,
  code 
)     MONITOR_BUF_PAGE(name, description, code, "written", PAGE_WRITTEN)

◆ MONITOR_BUF_PAGE_WRITTEN_WAIT_STATS

#define MONITOR_BUF_PAGE_WRITTEN_WAIT_STATS (   name,
  description,
  code 
)
Value:
MONITOR_WAIT_STATS_EX(name, "", description, code, \
#define MONITOR_WAIT_STATS_EX(name, module, description, code, wrap)
Definition: srv0mon.cc:68
#define MONITOR_BUF_PAGE_WRITTEN_WAIT_STATS_WRAP(name, module, description, a, b, code)
Definition: srv0mon.cc:83

◆ MONITOR_BUF_PAGE_WRITTEN_WAIT_STATS_WRAP

#define MONITOR_BUF_PAGE_WRITTEN_WAIT_STATS_WRAP (   name,
  module,
  description,
  a,
  b,
  code 
)     MONITOR_BUF_PAGE_WRITTEN(name, description, code)

◆ MONITOR_WAIT_STATS

#define MONITOR_WAIT_STATS (   name,
  module,
  description,
  code 
)
Value:
MONITOR_WAIT_STATS_EX(name, module, description, code, \
#define MONITOR_WAIT_STATS_SIMPLE_WRAP(a1, a2, a3, a4, a5, a6)
Definition: srv0mon.cc:76

◆ MONITOR_WAIT_STATS_EX

#define MONITOR_WAIT_STATS_EX (   name,
  module,
  description,
  code,
  wrap 
)
Value:
wrap(name "no_waits", module, description, MONITOR_NONE, \
MONITOR_DEFAULT_START, code##NO_WAITS), \
wrap(name "waits", module, description, MONITOR_NONE, \
MONITOR_DEFAULT_START, code##WAITS), \
wrap(name "wait_loops", module, description, MONITOR_NONE, \
MONITOR_DEFAULT_START, code##WAIT_LOOPS)
@ MONITOR_NONE
No monitoring.
Definition: srv0mon.h:93
@ MONITOR_DEFAULT_START
Definition: srv0mon.h:136

◆ MONITOR_WAIT_STATS_SIMPLE_WRAP

#define MONITOR_WAIT_STATS_SIMPLE_WRAP (   a1,
  a2,
  a3,
  a4,
  a5,
  a6 
)     { a1, a2, a3, a4, a5, a6 }

Function Documentation

◆ srv_mon_default_on()

void srv_mon_default_on ( void  )

Turn on monitor counters that are marked as default ON.

◆ srv_mon_get_info()

monitor_info_t * srv_mon_get_info ( monitor_id_t  monitor_id)

Get a monitor's "monitor_info" by its monitor id (index into the innodb_counter_info array.

Get monitor's monitor_info_t by its monitor id (index into the innodb_counter_info array.

Returns
Point to corresponding monitor_info_t, or NULL if no such monitor
Parameters
monitor_idid indexing into the innodb_counter_info array

◆ srv_mon_get_name()

const char * srv_mon_get_name ( monitor_id_t  monitor_id)

Get monitor's name by its monitor id (indexing into the innodb_counter_info array.

Get monitor's name by its monitor id (index into the innodb_counter_info array.

Returns
corresponding monitor name, or NULL if no such monitor
Parameters
monitor_idid index into the innodb_counter_info array

◆ srv_mon_get_rseg_size()

static ulint srv_mon_get_rseg_size ( void  )
static

Get transaction system's rollback segment size in pages.

Returns
size in pages

◆ srv_mon_process_existing_counter()

void srv_mon_process_existing_counter ( monitor_id_t  monitor_id,
mon_option_t  set_option 
)

This function consolidates some existing server counters used by "system status variables".

These existing system variables do not have mechanism to start/stop and reset the counters, so we simulate these controls by remembering the corresponding counter values when the corresponding monitors are turned on/off/reset, and do appropriate mathematics to deduct the actual value. Please also refer to srv_export_innodb_status() for related global counters used by the existing status variables.

Parameters
monitor_idin: the monitor's ID as in monitor_counter_id
set_optionin: Turn on/off reset the counter

◆ srv_mon_reset()

void srv_mon_reset ( monitor_id_t  monitor)

Reset a monitor, create a new base line with the current monitor value.

This baseline is recorded by MONITOR_VALUE_RESET(monitor)

Parameters
monitorin: monitor id

◆ srv_mon_set_module_control()

void srv_mon_set_module_control ( monitor_id_t  module_id,
mon_option_t  set_option 
)

Turn on/off, reset monitor counters in a module.

Turn on/off/reset monitor counters in a module.

If module_id is MONITOR_ALL_COUNTER then turn on all monitor counters. turned on because it has already been turned on.

Parameters
module_idin: Module ID as in monitor_counter_id. If it is set to MONITOR_ALL_COUNTER, this means we shall turn on all the counters
set_optionin: Turn on/off reset the counter

Variable Documentation

◆ innodb_counter_info

monitor_info_t innodb_counter_info[]
static

This array defines basic static information of monitor counters, including each monitor's name, module it belongs to, a short description and its property/type and corresponding monitor_id.

Please note: If you add a monitor here, please add its corresponding monitor_id to "enum monitor_id_value" structure in srv0mon.h file.

◆ innodb_counter_value

monitor_value_t innodb_counter_value[NUM_MONITOR]

The actual monitor counter array that records each monitor counter value.

◆ monitor_set_tbl

std::bitset<NUM_MONITOR> monitor_set_tbl

This "monitor_set_tbl" is a bitmap records whether a particular monitor counter has been turned on or off.