MySQL 8.3.0
Source Code Documentation
buf0dump.cc File Reference

Implements a buffer pool dump/load. More...

#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
#include <algorithm>
#include "buf0buf.h"
#include "buf0dump.h"
#include "dict0dict.h"
#include "my_io.h"
#include "my_psi_config.h"
#include "my_sys.h"
#include "my_thread.h"
#include "mysql/psi/mysql_stage.h"
#include "os0file.h"
#include "os0thread-create.h"
#include "os0thread.h"
#include "srv0srv.h"
#include "srv0start.h"
#include "sync0rw.h"
#include "univ.i"
#include "ut0byte.h"

Macros

#define SHOULD_QUIT()   (SHUTTING_DOWN() && obey_shutdown)
 

Typedefs

typedef uint64_t buf_dump_t
 

Enumerations

enum  status_severity { STATUS_VERBOSE , STATUS_INFO , STATUS_ERR }
 

Functions

static bool SHUTTING_DOWN ()
 
uint64_t BUF_DUMP_CREATE (space_id_t space, page_no_t page)
 
constexpr space_id_t BUF_DUMP_SPACE (uint64_t a)
 
constexpr page_no_t BUF_DUMP_PAGE (uint64_t a)
 
void buf_dump_start ()
 Wakes up the buffer pool dump/load thread and instructs it to start a dump. More...
 
void buf_load_start ()
 Wakes up the buffer pool dump/load thread and instructs it to start a load. More...
 
static void buf_dump_status (enum status_severity severity, const char *fmt,...)
 Sets the global variable that feeds MySQL's innodb_buffer_pool_dump_status to the specified string. More...
 
static void buf_load_status (enum status_severity severity, const char *fmt,...)
 Sets the global variable that feeds MySQL's innodb_buffer_pool_load_status to the specified string. More...
 
static const char * get_buf_dump_dir ()
 Returns the directory path where the buffer pool dump file will be created. More...
 
void buf_dump_generate_path (char *path, size_t path_size)
 Generate the path to the buffer pool dump/load file. More...
 
static void buf_dump (bool obey_shutdown)
 Perform a buffer pool dump into the file specified by innodb_buffer_pool_filename. More...
 
static void buf_load_throttle_if_needed (std::chrono::steady_clock::time_point *last_check_time, ulint *last_activity_count, ulint n_io)
 Artificially delay the buffer pool loading if necessary. More...
 
static void buf_load ()
 Perform a buffer pool load from the file specified by innodb_buffer_pool_filename. More...
 
void buf_load_abort ()
 Aborts a currently running buffer pool load. More...
 
void buf_dump_thread ()
 This is the main thread for buffer pool dump/load. More...
 

Variables

static bool buf_dump_should_start = false
 
static bool buf_load_should_start = false
 
static bool buf_load_abort_flag = false
 

Detailed Description

Implements a buffer pool dump/load.

Created April 08, 2011 Vasil Dimov

Macro Definition Documentation

◆ SHOULD_QUIT

#define SHOULD_QUIT ( )    (SHUTTING_DOWN() && obey_shutdown)

Typedef Documentation

◆ buf_dump_t

typedef uint64_t buf_dump_t

Enumeration Type Documentation

◆ status_severity

Enumerator
STATUS_VERBOSE 
STATUS_INFO 
STATUS_ERR 

Function Documentation

◆ buf_dump()

static void buf_dump ( bool  obey_shutdown)
static

Perform a buffer pool dump into the file specified by innodb_buffer_pool_filename.

If any errors occur then the value of innodb_buffer_pool_dump_status will be set accordingly, see buf_dump_status(). The dump filename can be specified by (relative to srv_data_home): SET GLOBAL innodb_buffer_pool_filename='filename';

Parameters
[in]obey_shutdownquit if we are in a shutting down state

◆ BUF_DUMP_CREATE()

uint64_t BUF_DUMP_CREATE ( space_id_t  space,
page_no_t  page 
)
inline

◆ buf_dump_generate_path()

void buf_dump_generate_path ( char *  path,
size_t  path_size 
)

Generate the path to the buffer pool dump/load file.

Parameters
[out]pathgenerated path
[in]path_sizesize of 'path', used as in snprintf(3).

◆ BUF_DUMP_PAGE()

constexpr page_no_t BUF_DUMP_PAGE ( uint64_t  a)
constexpr

◆ BUF_DUMP_SPACE()

constexpr space_id_t BUF_DUMP_SPACE ( uint64_t  a)
constexpr

◆ buf_dump_start()

void buf_dump_start ( )

Wakes up the buffer pool dump/load thread and instructs it to start a dump.

This function is called by MySQL code via buffer_pool_dump_now() and it should return immediately because the whole MySQL is frozen during its execution.

◆ buf_dump_status()

static void buf_dump_status ( enum status_severity  severity,
const char *  fmt,
  ... 
)
static

Sets the global variable that feeds MySQL's innodb_buffer_pool_dump_status to the specified string.

The format and the following parameters are the same as the ones used for printf(3). The value of this variable can be retrieved by: SELECT variable_value FROM performance_schema.global_status WHERE variable_name = 'INNODB_BUFFER_POOL_DUMP_STATUS'; or by: SHOW STATUS LIKE 'innodb_buffer_pool_dump_status';

Parameters
severityin: status severity
fmtin: format
...in: extra parameters according to fmt

◆ buf_dump_thread()

void buf_dump_thread ( )

This is the main thread for buffer pool dump/load.

It waits for an event and when waked up either performs a dump or load and sleeps again.

◆ buf_load()

static void buf_load ( )
static

Perform a buffer pool load from the file specified by innodb_buffer_pool_filename.

If any errors occur then the value of innodb_buffer_pool_load_status will be set accordingly, see buf_load_status(). The dump filename can be specified by (relative to srv_data_home): SET GLOBAL innodb_buffer_pool_filename='filename';

◆ buf_load_abort()

void buf_load_abort ( )

Aborts a currently running buffer pool load.

This function is called by MySQL code via buffer_pool_load_abort() and it should return immediately because the whole MySQL is frozen during its execution.

◆ buf_load_start()

void buf_load_start ( )

Wakes up the buffer pool dump/load thread and instructs it to start a load.

This function is called by MySQL code via buffer_pool_load_now() and it should return immediately because the whole MySQL is frozen during its execution.

◆ buf_load_status()

static void buf_load_status ( enum status_severity  severity,
const char *  fmt,
  ... 
)
static

Sets the global variable that feeds MySQL's innodb_buffer_pool_load_status to the specified string.

The format and the following parameters are the same as the ones used for printf(3). The value of this variable can be retrieved by: SELECT variable_value FROM performance_schema.global_status WHERE variable_name = 'INNODB_BUFFER_POOL_LOAD_STATUS'; or by: SHOW STATUS LIKE 'innodb_buffer_pool_load_status';

Parameters
severityin: status severity
fmtin: format
...in: extra parameters according to fmt

◆ buf_load_throttle_if_needed()

static void buf_load_throttle_if_needed ( std::chrono::steady_clock::time_point *  last_check_time,
ulint last_activity_count,
ulint  n_io 
)
inlinestatic

Artificially delay the buffer pool loading if necessary.

The idea of this function is to prevent hogging the server with IO and slowing down too much normal client queries.

Parameters
[in,out]last_check_timemilliseconds since epoch of the last time we did check if throttling is needed, we do the check every srv_io_capacity IO ops.
[in]last_activity_countactivity count
[in]n_ionumber of IO ops done since buffer pool load has started

◆ get_buf_dump_dir()

static const char * get_buf_dump_dir ( )
static

Returns the directory path where the buffer pool dump file will be created.

Returns
directory path

◆ SHUTTING_DOWN()

static bool SHUTTING_DOWN ( )
inlinestatic

Variable Documentation

◆ buf_dump_should_start

bool buf_dump_should_start = false
static

◆ buf_load_abort_flag

bool buf_load_abort_flag = false
static

◆ buf_load_should_start

bool buf_load_should_start = false
static