MySQL  8.0.19
Source Code Documentation
meb Namespace Reference

Classes

class  Block
 Encapsulates a log block of size QUEUE_BLOCK_SIZE, enqueued by the producer, dequeued by the consumer and written into the redo log archive file. More...
 
class  Guardian
 
class  Queue
 This template class implements a queue that,. More...
 
struct  udf_data_t
 Type and data for tracking registered UDFs. More...
 

Functions

int validate_redo_log_archive_dirs (THD *thd, SYS_VAR *var, void *save, st_mysql_value *value)
 Check whether a valid value is given to innodb_redo_log_archive_dirs. More...
 
void redo_log_archive_init ()
 Initialize redo log archiving. More...
 
void redo_log_archive_deinit ()
 De-initialize redo log archiving. More...
 
void redo_log_archive_session_end (innodb_session_t *session)
 Security function to be called when the current session ends. More...
 
void redo_log_archive_produce (const byte *write_buf, const size_t write_size)
 The producer produces full QUEUE_BLOCK_SIZE redo log blocks. More...
 
const std::string logmsgpfx ("innodb_redo_log_archive: ")
 
static void redo_log_archive_consumer ()
 Dequeue blocks of size QUEUE_BLOCK_SIZE, enqueued by the producer. More...
 
static bool terminate_consumer (bool rapid)
 
static void unregister_udfs ()
 Unregister UDF(s) More...
 
static bool register_udfs ()
 Register UDF(s). More...
 
bool register_privilege (const char *priv_name)
 Register a privilege. More...
 
static bool drop_remnants (bool force)
 Drop potential left-over resources to avoid leaks. More...
 
static bool verify_redo_log_archive_privilege (THD *thd)
 Verify that thd has the INNODB_REDO_LOG_ARCHIVE privilege. More...
 
static bool get_labeled_directory (const char *label, std::string *dir)
 Get the directory behind the label in a semi-colon separated list of labeled directories. More...
 
static bool verify_no_world_permissions (const Fil_path &path)
 Verify that a file system object does not grant permissions to everyone. More...
 
static std::string trim_path_name (const std::string &path_name)
 Trim trailing directory delimiters from a path name. More...
 
static std::string delimit_dir_name (const std::string &path_name)
 Append a trailing directory delimiter to a path name. More...
 
static void append_path (const char *variable_name, const char *path_name, std::vector< std::string > *variables, std::vector< Fil_path > *directories)
 Append a path to a vector of directory paths. More...
 
static bool verify_no_server_directory (const Fil_path &path)
 Verify that a path name is not in, under, or above a server directory. More...
 
static void construct_file_pathname (const Fil_path &path, std::string *file_pathname)
 Construct the file path name as directory/archive.serverUUID.000001.log. More...
 
static bool construct_secure_file_path_name (THD *thd, const char *label, const char *subdir, std::string *file_pathname)
 Execute security checks and construct a file path name. More...
 
static bool redo_log_archive_start (THD *thd, const char *label, const char *subdir)
 
static bool redo_log_archive_stop (THD *thd)
 
static bool redo_log_archive_flush (THD *thd)
 
bool innodb_redo_log_archive_start_init (UDF_INIT *initid, UDF_ARGS *args, char *message)
 Initialize UDF innodb_redo_log_archive_start. More...
 
void innodb_redo_log_archive_start_deinit (UDF_INIT *initid)
 Deinitialize UDF innodb_redo_log_archive_start. More...
 
long long innodb_redo_log_archive_start (UDF_INIT *initid, UDF_ARGS *args, unsigned char *null_value, unsigned char *error)
 UDF innodb_redo_log_archive_start. More...
 
bool innodb_redo_log_archive_stop_init (UDF_INIT *initid, UDF_ARGS *args, char *message)
 Initialize UDF innodb_redo_log_archive_stop. More...
 
void innodb_redo_log_archive_stop_deinit (UDF_INIT *initid)
 Deinitialize UDF innodb_redo_log_archive_stop. More...
 
long long innodb_redo_log_archive_stop (UDF_INIT *initid, UDF_ARGS *args, unsigned char *null_value, unsigned char *error)
 UDF innodb_redo_log_archive_stop. More...
 
bool innodb_redo_log_archive_flush_init (UDF_INIT *initid, UDF_ARGS *args, char *message)
 Initialize UDF innodb_redo_log_archive_flush. More...
 
void innodb_redo_log_archive_flush_deinit (UDF_INIT *initid)
 Deinitialize UDF innodb_redo_log_archive_flush. More...
 
long long innodb_redo_log_archive_flush (UDF_INIT *initid, UDF_ARGS *args, unsigned char *null_value, unsigned char *error)
 UDF innodb_redo_log_archive_flush. More...
 

Variables

mysql_pfs_key_t redo_log_archive_consumer_thread_key
 Performance schema key for the log consumer thread. More...
 
mysql_pfs_key_t redo_log_archive_file_key
 Performance schema key for the redo log archive file. More...
 
char * redo_log_archive_dirs {}
 
constexpr size_t QUEUE_BLOCK_SIZE = 4096
 
constexpr size_t QUEUE_SIZE_MAX = 16384
 
static std::atomic< boolredo_log_archive_initialized {}
 
static ib_mutex_t redo_log_archive_admin_mutex
 Mutex to synchronize start and stop of the redo log archiving. More...
 
static bool redo_log_archive_active {false}
 Boolean indicating whether the redo log archiving is active. More...
 
static innodb_session_tredo_log_archive_session {}
 Session. More...
 
static THDredo_log_archive_thd {}
 
static bool redo_log_archive_session_ending {false}
 
static std::string redo_log_archive_recorded_error {}
 Error message recorded during redo log archiving. More...
 
static std::string redo_log_archive_file_pathname {}
 String containing the redo log archive filename. More...
 
static pfs_os_file_t redo_log_archive_file_handle {}
 The file handle to the redo log archive file. More...
 
static bool redo_log_archive_consume_running {false}
 Whether the consumer thread is running. More...
 
static bool redo_log_archive_consume_complete {true}
 Whether the consumer has completed. More...
 
static os_event_t redo_log_archive_consume_event {}
 Event to inform that the consumer has exited after purging all the queue elements or that it got a flush block. More...
 
static bool redo_log_archive_consume_flushed {false}
 Whether the consumer has copied a flush block. More...
 
static bool redo_log_archive_produce_blocks {false}
 Boolean indicating whether to produce queue blocks. More...
 
static Block redo_log_archive_tmp_block {}
 Temporary block used to build complete redo log blocks of size QUEUE_BLOCK_SIZE by the producer. More...
 
static Queue< Blockredo_log_archive_queue {}
 Queue into which the producer enqueues redo log blocks of size QUEUE_BLOCK_SIZE, and from which the consumer reads redo log blocks of size QUEUE_BLOCK_SIZE. More...
 
static udf_data_t component_udfs []
 This component's UDFs. More...
 

Function Documentation

◆ append_path()

static void meb::append_path ( const char *  variable_name,
const char *  path_name,
std::vector< std::string > *  variables,
std::vector< Fil_path > *  directories 
)
static

Append a path to a vector of directory paths.

Append a variable name to a vector of variable names. The variable names belong to the server variables, from which the directory paths have been taken. The matching pair shares the same vector index. Only non-NULL, non-empty path names and their corresponding variable names are appended. The appended paths are normalized absolute real path names.

Parameters
[in]variable_namevariable name from which the path comes
[in]path_namepath name, may be NULL or empty
[out]variablesvector of variable names
[out]directoriesvector of directory paths

◆ construct_file_pathname()

static void meb::construct_file_pathname ( const Fil_path path,
std::string *  file_pathname 
)
static

Construct the file path name as directory/archive.serverUUID.000001.log.

Parameters
[in]pathnormalized absolute real path name
[out]file_pathnamefile path name

◆ construct_secure_file_path_name()

static bool meb::construct_secure_file_path_name ( THD thd,
const char *  label,
const char *  subdir,
std::string *  file_pathname 
)
static

Execute security checks and construct a file path name.

Parameters
[in,out]thdcurrent THD instance, current session
[in]labela label from innodb_redo_log_archive_dirs
[in]subdira plain directory name, on Unix/Linux/Mac no slash ('/') is allowed, on Windows no slash ('/'), backslash ('\'), nor colon (':') is allowed in the argument. Can be NULL or empty
[out]file_pathnamethe secure file path name
Returns
status
Return values
falsesuccess
truefailure

◆ delimit_dir_name()

static std::string meb::delimit_dir_name ( const std::string &  path_name)
static

Append a trailing directory delimiter to a path name.

This is done to support regression tests, which may want to replace path names based on server variable values, that could contain a trailing directory delimiter.

Parameters
[in]path_namepath name
Returns
trimmed path name

◆ drop_remnants()

static bool meb::drop_remnants ( bool  force)
static

Drop potential left-over resources to avoid leaks.

NOTE: This function must be called under the redo_log_archive_admin_mutex!

Parameters
[in]forcewhether to drop resorces even if consumer cannot be stopped
Returns
status
Return values
falsesuccess
truefailure

◆ get_labeled_directory()

static bool meb::get_labeled_directory ( const char *  label,
std::string *  dir 
)
static

Get the directory behind the label in a semi-colon separated list of labeled directories.

Parameters
[in]labellabel for the selected directory; can be empty
[out]dirdirectory path name
Returns
status
Return values
falsesuccess
truefailure

◆ innodb_redo_log_archive_flush()

long long meb::innodb_redo_log_archive_flush ( UDF_INIT initid,
UDF_ARGS args,
unsigned char *  null_value,
unsigned char *  error 
)

UDF innodb_redo_log_archive_flush.

The UDF is of type Udf_func_longlong returning INT_RESULT

See include/mysql/udf_registration_types.h

The UDF expects one argument:

  • A thread context pointer, maybe NULL

Returns zero on success, one otherwise.

◆ innodb_redo_log_archive_flush_deinit()

void meb::innodb_redo_log_archive_flush_deinit ( UDF_INIT initid)

Deinitialize UDF innodb_redo_log_archive_flush.

See include/mysql/udf_registration_types.h

◆ innodb_redo_log_archive_flush_init()

bool meb::innodb_redo_log_archive_flush_init ( UDF_INIT initid,
UDF_ARGS args,
char *  message 
)

Initialize UDF innodb_redo_log_archive_flush.

See include/mysql/udf_registration_types.h

◆ innodb_redo_log_archive_start()

long long meb::innodb_redo_log_archive_start ( UDF_INIT initid,
UDF_ARGS args,
unsigned char *  null_value,
unsigned char *  error 
)

UDF innodb_redo_log_archive_start.

The UDF is of type Udf_func_longlong returning INT_RESULT

See include/mysql/udf_registration_types.h

The UDF expects two or three arguments:

  • A thread context pointer, maybe NULL
  • A label from the server system variable innodb_redo_log_archive_dirs
  • An optional subdirectory inside the corresponding directory path from innodb_redo_log_archive_dirs. This must be a plain directory name. On Unix/Linux/Mac no slash ('/') is allowed in the argument. On Windows, no slash ('/'), backslash ('\'), nor colon (':') is allowed in the argument. Can be NULL or empty.

Returns zero on success, one otherwise.

◆ innodb_redo_log_archive_start_deinit()

void meb::innodb_redo_log_archive_start_deinit ( UDF_INIT initid)

Deinitialize UDF innodb_redo_log_archive_start.

See include/mysql/udf_registration_types.h

◆ innodb_redo_log_archive_start_init()

bool meb::innodb_redo_log_archive_start_init ( UDF_INIT initid,
UDF_ARGS args,
char *  message 
)

Initialize UDF innodb_redo_log_archive_start.

See include/mysql/udf_registration_types.h

◆ innodb_redo_log_archive_stop()

long long meb::innodb_redo_log_archive_stop ( UDF_INIT initid,
UDF_ARGS args,
unsigned char *  null_value,
unsigned char *  error 
)

UDF innodb_redo_log_archive_stop.

The UDF is of type Udf_func_longlong returning INT_RESULT

See include/mysql/udf_registration_types.h

The UDF expects one argument:

  • A thread context pointer, maybe NULL

Returns zero on success, one otherwise.

◆ innodb_redo_log_archive_stop_deinit()

void meb::innodb_redo_log_archive_stop_deinit ( UDF_INIT initid)

Deinitialize UDF innodb_redo_log_archive_stop.

See include/mysql/udf_registration_types.h

◆ innodb_redo_log_archive_stop_init()

bool meb::innodb_redo_log_archive_stop_init ( UDF_INIT initid,
UDF_ARGS args,
char *  message 
)

Initialize UDF innodb_redo_log_archive_stop.

See include/mysql/udf_registration_types.h

◆ logmsgpfx()

const std::string meb::logmsgpfx ( "innodb_redo_log_archive: "  )

◆ redo_log_archive_consumer()

static void meb::redo_log_archive_consumer ( )
static

Dequeue blocks of size QUEUE_BLOCK_SIZE, enqueued by the producer.

Write the blocks to the redo log archive file sequentially.

◆ redo_log_archive_deinit()

void meb::redo_log_archive_deinit ( )

De-initialize redo log archiving.

To be called when the InnoDB handlerton is de-initialized.

◆ redo_log_archive_flush()

static bool meb::redo_log_archive_flush ( THD thd)
static

◆ redo_log_archive_init()

void meb::redo_log_archive_init ( )

Initialize redo log archiving.

To be called when the InnoDB handlerton is initialized.

◆ redo_log_archive_produce()

void meb::redo_log_archive_produce ( const byte write_buf,
const size_t  write_size 
)

The producer produces full QUEUE_BLOCK_SIZE redo log blocks.

Produce redo log blocks for the queue.

These log blocks are enqueued, and are later fetched by the consumer thread.

This function does nothing, if redo log archiving is not active.

In order to produce full QUEUE_BLOCK_SIZE redo log blocks, the producer scans each OS_FILE_LOG_BLOCK_SIZE log block (written by the server) to check if they are,

  1. empty
  2. incomplete

The producer skips empty and incomplete log blocks, unless they belong to the last flush, when the contents of its buffer are completely enqueued for flushing.

Parameters
[in]write_bufThe write buffer that is being written to the redo log archive file.
[in]write_sizeThe size of the data being written.

This function is called for every log write. So it must be as efficient as possible.

NOTE: This function must be called under the 'log_sys.writer_mutex'!

◆ redo_log_archive_session_end()

void meb::redo_log_archive_session_end ( innodb_session_t session)

Security function to be called when the current session ends.

This function invokes the stop implementation if this session has started the redo log archiving. It is a safe-guard against an infinitely active redo log archiving if the client goes away without deactivating the logging explicitly.

Parameters
[in]sessionthe current ending session

◆ redo_log_archive_start()

static bool meb::redo_log_archive_start ( THD thd,
const char *  label,
const char *  subdir 
)
static

◆ redo_log_archive_stop()

static bool meb::redo_log_archive_stop ( THD thd)
static

◆ register_privilege()

bool meb::register_privilege ( const char *  priv_name)

Register a privilege.

Parameters
[in]priv_nameprivilege name
Returns
status
Return values
falsesuccess
truefailure

◆ register_udfs()

static bool meb::register_udfs ( )
static

Register UDF(s).

This does first try to unregister any functions, that might be left over from an earlier use of the component.

Returns
status
Return values
falsesuccess
truefailure

◆ terminate_consumer()

static bool meb::terminate_consumer ( bool  rapid)
static

◆ trim_path_name()

static std::string meb::trim_path_name ( const std::string &  path_name)
static

Trim trailing directory delimiters from a path name.

Parameters
[in]path_namepath name
Returns
trimmed path name

◆ unregister_udfs()

static void meb::unregister_udfs ( )
static

Unregister UDF(s)

◆ validate_redo_log_archive_dirs()

int meb::validate_redo_log_archive_dirs ( THD thd,
SYS_VAR var,
void *  save,
st_mysql_value value 
)

Check whether a valid value is given to innodb_redo_log_archive_dirs.

This function is registered as a callback with MySQL.

Parameters
[in]thdthread handle
[in]varpointer to system variable
[out]saveimmediate result for update function
[in]valueincoming string
Returns
0 for valid contents

◆ verify_no_server_directory()

static bool meb::verify_no_server_directory ( const Fil_path path)
static

Verify that a path name is not in, under, or above a server directory.

Parameters
[in]pathnormalized absolute real path name
Returns
status
Return values
falsesuccess
truefailure

◆ verify_no_world_permissions()

static bool meb::verify_no_world_permissions ( const Fil_path path)
static

Verify that a file system object does not grant permissions to everyone.

Parameters
[in]pathpath name of the file system object
Returns
status
Return values
falsesuccess
truefailure

◆ verify_redo_log_archive_privilege()

static bool meb::verify_redo_log_archive_privilege ( THD thd)
static

Verify that thd has the INNODB_REDO_LOG_ARCHIVE privilege.

Parameters
[in,out]thdcurrent THD instance, current session
Returns
status
Return values
falsesuccess
truefailure

Variable Documentation

◆ component_udfs

udf_data_t meb::component_udfs[]
static
Initial value:
= {
{"innodb_redo_log_archive_start", INT_RESULT,
{"innodb_redo_log_archive_stop", INT_RESULT,
{"innodb_redo_log_archive_flush", INT_RESULT,

This component's UDFs.

◆ QUEUE_BLOCK_SIZE

constexpr size_t meb::QUEUE_BLOCK_SIZE = 4096
constexpr

◆ QUEUE_SIZE_MAX

constexpr size_t meb::QUEUE_SIZE_MAX = 16384
constexpr

◆ redo_log_archive_active

bool meb::redo_log_archive_active {false}
static

Boolean indicating whether the redo log archiving is active.

◆ redo_log_archive_admin_mutex

ib_mutex_t meb::redo_log_archive_admin_mutex
static

Mutex to synchronize start and stop of the redo log archiving.

◆ redo_log_archive_consume_complete

bool meb::redo_log_archive_consume_complete {true}
static

Whether the consumer has completed.

◆ redo_log_archive_consume_event

os_event_t meb::redo_log_archive_consume_event {}
static

Event to inform that the consumer has exited after purging all the queue elements or that it got a flush block.

◆ redo_log_archive_consume_flushed

bool meb::redo_log_archive_consume_flushed {false}
static

Whether the consumer has copied a flush block.

◆ redo_log_archive_consume_running

bool meb::redo_log_archive_consume_running {false}
static

Whether the consumer thread is running.

◆ redo_log_archive_consumer_thread_key

mysql_pfs_key_t meb::redo_log_archive_consumer_thread_key

Performance schema key for the log consumer thread.

◆ redo_log_archive_dirs

char * meb::redo_log_archive_dirs {}

◆ redo_log_archive_file_handle

pfs_os_file_t meb::redo_log_archive_file_handle {}
static

The file handle to the redo log archive file.

◆ redo_log_archive_file_key

mysql_pfs_key_t meb::redo_log_archive_file_key

Performance schema key for the redo log archive file.

◆ redo_log_archive_file_pathname

std::string meb::redo_log_archive_file_pathname {}
static

String containing the redo log archive filename.

◆ redo_log_archive_initialized

std::atomic<bool> meb::redo_log_archive_initialized {}
static

◆ redo_log_archive_produce_blocks

bool meb::redo_log_archive_produce_blocks {false}
static

Boolean indicating whether to produce queue blocks.

WARNING: To avoid races, this variable must be read/written under the 'log_sys.writer_mutex' only.

◆ redo_log_archive_queue

Queue<Block> meb::redo_log_archive_queue {}
static

Queue into which the producer enqueues redo log blocks of size QUEUE_BLOCK_SIZE, and from which the consumer reads redo log blocks of size QUEUE_BLOCK_SIZE.

◆ redo_log_archive_recorded_error

std::string meb::redo_log_archive_recorded_error {}
static

Error message recorded during redo log archiving.

◆ redo_log_archive_session

innodb_session_t* meb::redo_log_archive_session {}
static

Session.

◆ redo_log_archive_session_ending

bool meb::redo_log_archive_session_ending {false}
static

◆ redo_log_archive_thd

THD* meb::redo_log_archive_thd {}
static

◆ redo_log_archive_tmp_block

Block meb::redo_log_archive_tmp_block {}
static

Temporary block used to build complete redo log blocks of size QUEUE_BLOCK_SIZE by the producer.

WARNING: To avoid races, this variable must be read/written under the 'log_sys.writer_mutex' only.

Udf_func_deinit
void(* Udf_func_deinit)(UDF_INIT *)
Definition: udf_registration_types.h:79
meb::innodb_redo_log_archive_start_init
bool innodb_redo_log_archive_start_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
Initialize UDF innodb_redo_log_archive_start.
Definition: log0meb.cc:1856
meb::innodb_redo_log_archive_flush
long long innodb_redo_log_archive_flush(UDF_INIT *initid, UDF_ARGS *args, unsigned char *null_value, unsigned char *error)
UDF innodb_redo_log_archive_flush.
Definition: log0meb.cc:1994
meb::innodb_redo_log_archive_flush_deinit
void innodb_redo_log_archive_flush_deinit(UDF_INIT *initid)
Deinitialize UDF innodb_redo_log_archive_flush.
Definition: log0meb.cc:1977
meb::innodb_redo_log_archive_flush_init
bool innodb_redo_log_archive_flush_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
Initialize UDF innodb_redo_log_archive_flush.
Definition: log0meb.cc:1963
meb::innodb_redo_log_archive_start
long long innodb_redo_log_archive_start(UDF_INIT *initid, UDF_ARGS *args, unsigned char *null_value, unsigned char *error)
UDF innodb_redo_log_archive_start.
Definition: log0meb.cc:1905
meb::innodb_redo_log_archive_start_deinit
void innodb_redo_log_archive_start_deinit(UDF_INIT *initid)
Deinitialize UDF innodb_redo_log_archive_start.
Definition: log0meb.cc:1882
meb::innodb_redo_log_archive_stop_init
bool innodb_redo_log_archive_stop_init(UDF_INIT *initid, UDF_ARGS *args, char *message)
Initialize UDF innodb_redo_log_archive_stop.
Definition: log0meb.cc:1919
Udf_func_any
void(* Udf_func_any)(void)
Definition: udf_registration_types.h:81
meb::innodb_redo_log_archive_stop
long long innodb_redo_log_archive_stop(UDF_INIT *initid, UDF_ARGS *args, unsigned char *null_value, unsigned char *error)
UDF innodb_redo_log_archive_stop.
Definition: log0meb.cc:1950
Udf_func_init
bool(* Udf_func_init)(UDF_INIT *, UDF_ARGS *, char *)
Definition: udf_registration_types.h:80
INT_RESULT
@ INT_RESULT
double
Definition: udf_registration_types.h:42
meb::innodb_redo_log_archive_stop_deinit
void innodb_redo_log_archive_stop_deinit(UDF_INIT *initid)
Deinitialize UDF innodb_redo_log_archive_stop.
Definition: log0meb.cc:1933