MySQL  8.0.21
Source Code Documentation
semisync_master_plugin.cc File Reference
#include <stddef.h>
#include <sys/types.h>
#include "my_inttypes.h"
#include "my_macros.h"
#include "my_psi_config.h"
#include "mysql/psi/mysql_memory.h"
#include "mysql/psi/mysql_stage.h"
#include "plugin/semisync/semisync_master.h"
#include "plugin/semisync/semisync_master_ack_receiver.h"
#include "sql/current_thd.h"
#include "sql/protocol_classic.h"
#include "sql/sql_class.h"
#include "typelib.h"

Macros

#define SHOW_FNAME(name)   rpl_semi_sync_master_show_##name
 
#define DEF_SHOW_FUNC(name, show_type)
 

Enumerations

enum  enum_wait_point { WAIT_AFTER_SYNC, WAIT_AFTER_COMMIT }
 

Functions

static bool is_semi_sync_dump ()
 
static int repl_semi_report_binlog_update (Binlog_storage_param *, const char *log_file, my_off_t log_pos)
 
static int repl_semi_report_binlog_sync (Binlog_storage_param *, const char *log_file, my_off_t log_pos)
 
static int repl_semi_report_before_dml (Trans_param *, int &)
 
static int repl_semi_report_before_commit (Trans_param *)
 
static int repl_semi_report_before_rollback (Trans_param *)
 
static int repl_semi_report_commit (Trans_param *param)
 
static int repl_semi_report_rollback (Trans_param *param)
 
static int repl_semi_report_begin (Trans_param *, int &)
 
static int repl_semi_binlog_dump_start (Binlog_transmit_param *param, const char *log_file, my_off_t log_pos)
 
static int repl_semi_binlog_dump_end (Binlog_transmit_param *param)
 
static int repl_semi_reserve_header (Binlog_transmit_param *, unsigned char *header, unsigned long size, unsigned long *len)
 
static int repl_semi_before_send_event (Binlog_transmit_param *param, unsigned char *packet, unsigned long, const char *log_file, my_off_t log_pos)
 
static int repl_semi_after_send_event (Binlog_transmit_param *param, const char *event_buf, unsigned long, const char *skipped_log_file, my_off_t skipped_log_pos)
 
static int repl_semi_reset_master (Binlog_transmit_param *)
 
static void fix_rpl_semi_sync_master_timeout (MYSQL_THD thd, SYS_VAR *var, void *ptr, const void *val)
 
static void fix_rpl_semi_sync_master_trace_level (MYSQL_THD thd, SYS_VAR *var, void *ptr, const void *val)
 
static void fix_rpl_semi_sync_master_wait_no_slave (MYSQL_THD thd, SYS_VAR *var, void *ptr, const void *val)
 
static void fix_rpl_semi_sync_master_enabled (MYSQL_THD thd, SYS_VAR *var, void *ptr, const void *val)
 
static void fix_rpl_semi_sync_master_wait_for_slave_count (MYSQL_THD thd, SYS_VAR *var, void *ptr, const void *val)
 
static MYSQL_SYSVAR_BOOL (enabled, rpl_semi_sync_master_enabled, PLUGIN_VAR_OPCMDARG, "Enable semi-synchronous replication master (disabled by default). ", nullptr, &fix_rpl_semi_sync_master_enabled, 0)
 
static MYSQL_SYSVAR_ULONG (timeout, rpl_semi_sync_master_timeout, PLUGIN_VAR_OPCMDARG, "The timeout value (in ms) for semi-synchronous replication in the master", nullptr, fix_rpl_semi_sync_master_timeout, 10000, 0, ~0UL, 1)
 
static MYSQL_SYSVAR_BOOL (wait_no_slave, rpl_semi_sync_master_wait_no_slave, PLUGIN_VAR_OPCMDARG, "Wait until timeout when no semi-synchronous " "replication slave available (enabled by default). ", nullptr, &fix_rpl_semi_sync_master_wait_no_slave, 1)
 
static MYSQL_SYSVAR_ULONG (trace_level, rpl_semi_sync_master_trace_level, PLUGIN_VAR_OPCMDARG, "The tracing level for semi-sync replication.", nullptr, &fix_rpl_semi_sync_master_trace_level, 32, 0, ~0UL, 1)
 
static MYSQL_SYSVAR_ENUM (wait_point, rpl_semi_sync_master_wait_point, PLUGIN_VAR_OPCMDARG, "Semisync can wait for slave ACKs at one of two points," "AFTER_SYNC or AFTER_COMMIT. AFTER_SYNC is the default value." "AFTER_SYNC means that semisynchronous replication waits just after the " "binary log file is flushed, but before the engine commits, and so " "guarantees that no other sessions can see the data before replicated to " "slave. AFTER_COMMIT means that semisynchronous replication waits just " "after the engine commits. Other sessions may see the data before it is " "replicated, even though the current session is still waiting for the " "commit " "to end successfully.", nullptr, nullptr, WAIT_AFTER_SYNC, &wait_point_typelib)
 
static MYSQL_SYSVAR_UINT (wait_for_slave_count, rpl_semi_sync_master_wait_for_slave_count, PLUGIN_VAR_OPCMDARG, "How many slaves the events should be replicated to. Semisynchronous " "replication master will wait until all events of the transaction are " "replicated to at least rpl_semi_sync_master_wait_for_slave_count slaves", nullptr, &fix_rpl_semi_sync_master_wait_for_slave_count, 1, 1, 65535, 1)
 
static void init_semisync_psi_keys (void)
 
static int semi_sync_master_plugin_init (void *p)
 
static int semi_sync_master_plugin_deinit (void *p)
 
 mysql_declare_plugin (semi_sync_master)
 

Variables

ReplSemiSyncMasterrepl_semisync = nullptr
 
Ack_receiverack_receiver = nullptr
 
static ulong rpl_semi_sync_master_wait_point = WAIT_AFTER_COMMIT
 
thread_local bool THR_RPL_SEMI_SYNC_DUMP = false
 
static const mysql_service_registry_treg_srv = nullptr
 
const mysql_service_log_builtins_tlog_bi = nullptr
 accessor built-ins More...
 
const mysql_service_log_builtins_string_tlog_bs = nullptr
 string built-ins More...
 
static const char * wait_point_names [] = {"AFTER_SYNC", "AFTER_COMMIT", NullS}
 
static TYPELIB wait_point_typelib
 
static SYS_VARsemi_sync_master_system_vars []
 
Trans_observer trans_observer
 
Binlog_storage_observer storage_observer
 
Binlog_transmit_observer transmit_observer
 
static SHOW_VAR semi_sync_master_status_vars []
 
PSI_mutex_key key_ss_mutex_LOCK_binlog_
 
PSI_mutex_key key_ss_mutex_Ack_receiver_mutex
 
static PSI_mutex_info all_semisync_mutexes []
 
PSI_cond_key key_ss_cond_COND_binlog_send_
 
PSI_cond_key key_ss_cond_Ack_receiver_cond
 
static PSI_cond_info all_semisync_conds []
 
PSI_thread_key key_ss_thread_Ack_receiver_thread
 
static PSI_thread_info all_semisync_threads []
 
PSI_stage_info stage_waiting_for_semi_sync_ack_from_slave
 
PSI_stage_info stage_waiting_for_semi_sync_slave
 
PSI_stage_info stage_reading_semi_sync_ack
 
PSI_memory_key key_ss_memory_TranxNodeAllocator_block
 
PSI_stage_infoall_semisync_stages []
 
PSI_memory_info all_semisync_memory []
 
struct Mysql_replication semi_sync_master_plugin
 
 mysql_declare_plugin_end
 

Macro Definition Documentation

◆ DEF_SHOW_FUNC

#define DEF_SHOW_FUNC (   name,
  show_type 
)
Value:
static int SHOW_FNAME(name)(MYSQL_THD, SHOW_VAR * var, char *) { \
repl_semisync->setExportStats(); \
var->type = show_type; \
var->value = (char *)&rpl_semi_sync_master_##name; \
return 0; \
}
#define MYSQL_THD
Definition: backup_page_tracker.h:35
SHOW STATUS Server status variable.
Definition: status_var.h:78
case opt name
Definition: sslopt-case.h:32
#define SHOW_FNAME(name)
Definition: semisync_master_plugin.cc:372

◆ SHOW_FNAME

#define SHOW_FNAME (   name)    rpl_semi_sync_master_show_##name

Enumeration Type Documentation

◆ enum_wait_point

Enumerator
WAIT_AFTER_SYNC 
WAIT_AFTER_COMMIT 

Function Documentation

◆ fix_rpl_semi_sync_master_enabled()

static void fix_rpl_semi_sync_master_enabled ( MYSQL_THD  thd,
SYS_VAR var,
void *  ptr,
const void *  val 
)
static

◆ fix_rpl_semi_sync_master_timeout()

static void fix_rpl_semi_sync_master_timeout ( MYSQL_THD  thd,
SYS_VAR var,
void *  ptr,
const void *  val 
)
static

◆ fix_rpl_semi_sync_master_trace_level()

static void fix_rpl_semi_sync_master_trace_level ( MYSQL_THD  thd,
SYS_VAR var,
void *  ptr,
const void *  val 
)
static

◆ fix_rpl_semi_sync_master_wait_for_slave_count()

static void fix_rpl_semi_sync_master_wait_for_slave_count ( MYSQL_THD  thd,
SYS_VAR var,
void *  ptr,
const void *  val 
)
static

◆ fix_rpl_semi_sync_master_wait_no_slave()

static void fix_rpl_semi_sync_master_wait_no_slave ( MYSQL_THD  thd,
SYS_VAR var,
void *  ptr,
const void *  val 
)
static

◆ init_semisync_psi_keys()

static void init_semisync_psi_keys ( void  )
static

◆ is_semi_sync_dump()

static bool is_semi_sync_dump ( )
inlinestatic

◆ mysql_declare_plugin()

mysql_declare_plugin ( semi_sync_master  )

◆ MYSQL_SYSVAR_BOOL() [1/2]

static MYSQL_SYSVAR_BOOL ( enabled  ,
rpl_semi_sync_master_enabled  ,
PLUGIN_VAR_OPCMDARG  ,
"Enable semi-synchronous replication master (disabled by default). "  ,
nullptr  ,
fix_rpl_semi_sync_master_enabled,
 
)
static

◆ MYSQL_SYSVAR_BOOL() [2/2]

static MYSQL_SYSVAR_BOOL ( wait_no_slave  ,
rpl_semi_sync_master_wait_no_slave  ,
PLUGIN_VAR_OPCMDARG  ,
"Wait until timeout when no semi-synchronous " "replication slave available (enabled by default). "  ,
nullptr  ,
fix_rpl_semi_sync_master_wait_no_slave,
 
)
static

◆ MYSQL_SYSVAR_ENUM()

static MYSQL_SYSVAR_ENUM ( wait_point  ,
rpl_semi_sync_master_wait_point  ,
PLUGIN_VAR_OPCMDARG  ,
"Semisync can wait for slave ACKs at one of two  points,
" "AFTER_SYNC or AFTER_COMMIT. AFTER_SYNC is the default value." "AFTER_SYNC means that semisynchronous replication waits just after the " "binary log file is  flushed,
but before the engine  commits,
and so " "guarantees that no other sessions can see the data before replicated to " "slave. AFTER_COMMIT means that semisynchronous replication waits just " "after the engine commits. Other sessions may see the data before it is " "  replicated,
even though the current session is still waiting for the " "commit " "to end successfully."  ,
nullptr  ,
nullptr  ,
WAIT_AFTER_SYNC  ,
wait_point_typelib 
)
static

◆ MYSQL_SYSVAR_UINT()

static MYSQL_SYSVAR_UINT ( wait_for_slave_count  ,
rpl_semi_sync_master_wait_for_slave_count  ,
PLUGIN_VAR_OPCMDARG  ,
"How many slaves the events should be replicated to. Semisynchronous " "replication master will wait until all events of the transaction are " "replicated to at least rpl_semi_sync_master_wait_for_slave_count slaves"  ,
nullptr  ,
fix_rpl_semi_sync_master_wait_for_slave_count,
,
,
65535  ,
 
)
static

◆ MYSQL_SYSVAR_ULONG() [1/2]

static MYSQL_SYSVAR_ULONG ( timeout  ,
rpl_semi_sync_master_timeout  ,
PLUGIN_VAR_OPCMDARG  ,
"The timeout value (in ms) for semi-synchronous replication in the master"  ,
nullptr  ,
fix_rpl_semi_sync_master_timeout  ,
10000  ,
,
0UL,
 
)
static

◆ MYSQL_SYSVAR_ULONG() [2/2]

static MYSQL_SYSVAR_ULONG ( trace_level  ,
rpl_semi_sync_master_trace_level  ,
PLUGIN_VAR_OPCMDARG  ,
"The tracing level for semi-sync replication."  ,
nullptr  ,
fix_rpl_semi_sync_master_trace_level,
32  ,
,
0UL,
 
)
static

◆ repl_semi_after_send_event()

static int repl_semi_after_send_event ( Binlog_transmit_param param,
const char *  event_buf,
unsigned  long,
const char *  skipped_log_file,
my_off_t  skipped_log_pos 
)
static

◆ repl_semi_before_send_event()

static int repl_semi_before_send_event ( Binlog_transmit_param param,
unsigned char *  packet,
unsigned  long,
const char *  log_file,
my_off_t  log_pos 
)
static

◆ repl_semi_binlog_dump_end()

static int repl_semi_binlog_dump_end ( Binlog_transmit_param param)
static

◆ repl_semi_binlog_dump_start()

static int repl_semi_binlog_dump_start ( Binlog_transmit_param param,
const char *  log_file,
my_off_t  log_pos 
)
static

◆ repl_semi_report_before_commit()

static int repl_semi_report_before_commit ( Trans_param )
static

◆ repl_semi_report_before_dml()

static int repl_semi_report_before_dml ( Trans_param ,
int &   
)
static

◆ repl_semi_report_before_rollback()

static int repl_semi_report_before_rollback ( Trans_param )
static

◆ repl_semi_report_begin()

static int repl_semi_report_begin ( Trans_param ,
int &   
)
static

◆ repl_semi_report_binlog_sync()

static int repl_semi_report_binlog_sync ( Binlog_storage_param ,
const char *  log_file,
my_off_t  log_pos 
)
static

◆ repl_semi_report_binlog_update()

static int repl_semi_report_binlog_update ( Binlog_storage_param ,
const char *  log_file,
my_off_t  log_pos 
)
static

◆ repl_semi_report_commit()

static int repl_semi_report_commit ( Trans_param param)
static

◆ repl_semi_report_rollback()

static int repl_semi_report_rollback ( Trans_param param)
static

◆ repl_semi_reserve_header()

static int repl_semi_reserve_header ( Binlog_transmit_param ,
unsigned char *  header,
unsigned long  size,
unsigned long *  len 
)
static

◆ repl_semi_reset_master()

static int repl_semi_reset_master ( Binlog_transmit_param )
static

◆ semi_sync_master_plugin_deinit()

static int semi_sync_master_plugin_deinit ( void *  p)
static

◆ semi_sync_master_plugin_init()

static int semi_sync_master_plugin_init ( void *  p)
static

Variable Documentation

◆ ack_receiver

Ack_receiver* ack_receiver = nullptr

◆ all_semisync_conds

PSI_cond_info all_semisync_conds[]
static
Initial value:
= {
{&key_ss_cond_COND_binlog_send_, "COND_binlog_send_", 0, 0,
{&key_ss_cond_Ack_receiver_cond, "Ack_receiver::m_cond", 0, 0,
PSI_DOCUMENT_ME}}
#define PSI_DOCUMENT_ME
Definition: component_common.h:28
PSI_cond_key key_ss_cond_COND_binlog_send_
Definition: semisync_master_plugin.cc:439
PSI_cond_key key_ss_cond_Ack_receiver_cond
Definition: semisync_master_plugin.cc:440

◆ all_semisync_memory

PSI_memory_info all_semisync_memory[]
Initial value:
= {
{&key_ss_memory_TranxNodeAllocator_block, "TranxNodeAllocator::block", 0, 0,
#define PSI_DOCUMENT_ME
Definition: component_common.h:28
PSI_memory_key key_ss_memory_TranxNodeAllocator_block
Definition: semisync_master_plugin.cc:465

◆ all_semisync_mutexes

PSI_mutex_info all_semisync_mutexes[]
static
Initial value:
= {
{&key_ss_mutex_LOCK_binlog_, "LOCK_binlog_", 0, 0, PSI_DOCUMENT_ME},
{&key_ss_mutex_Ack_receiver_mutex, "Ack_receiver::m_mutex", 0, 0,
PSI_DOCUMENT_ME}}
#define PSI_DOCUMENT_ME
Definition: component_common.h:28
PSI_mutex_key key_ss_mutex_LOCK_binlog_
Definition: semisync_master_plugin.cc:431
PSI_mutex_key key_ss_mutex_Ack_receiver_mutex
Definition: semisync_master_plugin.cc:432

◆ all_semisync_stages

PSI_stage_info* all_semisync_stages[]
Initial value:
= {
PSI_stage_info stage_reading_semi_sync_ack
Definition: semisync_master_plugin.cc:461
PSI_stage_info stage_waiting_for_semi_sync_slave
Definition: semisync_master_plugin.cc:458
PSI_stage_info stage_waiting_for_semi_sync_ack_from_slave
Definition: semisync_master_plugin.cc:455

◆ all_semisync_threads

PSI_thread_info all_semisync_threads[]
static
Initial value:
= {
PSI_thread_key key_ss_thread_Ack_receiver_thread
Definition: semisync_master_plugin.cc:448
#define PSI_FLAG_SINGLETON
Singleton flag.
Definition: component_common.h:34
#define PSI_DOCUMENT_ME
Definition: component_common.h:28

◆ key_ss_cond_Ack_receiver_cond

PSI_cond_key key_ss_cond_Ack_receiver_cond

◆ key_ss_cond_COND_binlog_send_

PSI_cond_key key_ss_cond_COND_binlog_send_

◆ key_ss_memory_TranxNodeAllocator_block

PSI_memory_key key_ss_memory_TranxNodeAllocator_block

◆ key_ss_mutex_Ack_receiver_mutex

PSI_mutex_key key_ss_mutex_Ack_receiver_mutex

◆ key_ss_mutex_LOCK_binlog_

PSI_mutex_key key_ss_mutex_LOCK_binlog_

◆ key_ss_thread_Ack_receiver_thread

PSI_thread_key key_ss_thread_Ack_receiver_thread

◆ log_bi

accessor built-ins

accessor built-ins

◆ log_bs

string built-ins

◆ mysql_declare_plugin_end

mysql_declare_plugin_end

◆ reg_srv

const mysql_service_registry_t* reg_srv = nullptr
static

◆ repl_semisync

ReplSemiSyncMaster* repl_semisync = nullptr

◆ rpl_semi_sync_master_wait_point

ulong rpl_semi_sync_master_wait_point = WAIT_AFTER_COMMIT
static

◆ semi_sync_master_plugin

struct Mysql_replication semi_sync_master_plugin
Initial value:
= {
#define MYSQL_REPLICATION_INTERFACE_VERSION
Definition: plugin.h:747

◆ semi_sync_master_status_vars

SHOW_VAR semi_sync_master_status_vars[]
static

◆ semi_sync_master_system_vars

SYS_VAR* semi_sync_master_system_vars[]
static
Initial value:
= {
MYSQL_SYSVAR(timeout),
MYSQL_SYSVAR(wait_no_slave),
MYSQL_SYSVAR(trace_level),
MYSQL_SYSVAR(wait_point),
MYSQL_SYSVAR(wait_for_slave_count),
nullptr,
}
bool enabled
true if enabled.
Definition: buf0dblwr.cc:81
#define MYSQL_SYSVAR(name)
Definition: plugin.h:281

◆ stage_reading_semi_sync_ack

PSI_stage_info stage_reading_semi_sync_ack
Initial value:
= {
0, "Reading semi-sync ACK from slave", 0, PSI_DOCUMENT_ME}
#define PSI_DOCUMENT_ME
Definition: component_common.h:28

◆ stage_waiting_for_semi_sync_ack_from_slave

PSI_stage_info stage_waiting_for_semi_sync_ack_from_slave
Initial value:
= {
0, "Waiting for semi-sync ACK from slave", 0, PSI_DOCUMENT_ME}
#define PSI_DOCUMENT_ME
Definition: component_common.h:28

◆ stage_waiting_for_semi_sync_slave

PSI_stage_info stage_waiting_for_semi_sync_slave
Initial value:
= {
0, "Waiting for semi-sync slave connection", 0, PSI_DOCUMENT_ME}
#define PSI_DOCUMENT_ME
Definition: component_common.h:28

◆ storage_observer

Binlog_storage_observer storage_observer
Initial value:
= {
}
static int repl_semi_report_binlog_sync(Binlog_storage_param *, const char *log_file, my_off_t log_pos)
Definition: semisync_master_plugin.cc:72
static int repl_semi_report_binlog_update(Binlog_storage_param *, const char *log_file, my_off_t log_pos)
Definition: semisync_master_plugin.cc:55
struct Binlog_storage_observer Binlog_storage_observer
Observe binlog logging storage.

◆ THR_RPL_SEMI_SYNC_DUMP

thread_local bool THR_RPL_SEMI_SYNC_DUMP = false

◆ trans_observer

Trans_observer trans_observer
Initial value:
= {
sizeof(Trans_observer),
}
static int repl_semi_report_before_commit(Trans_param *)
Definition: semisync_master_plugin.cc:82
static int repl_semi_report_begin(Trans_param *, int &)
Definition: semisync_master_plugin.cc:101
static int repl_semi_report_before_dml(Trans_param *, int &)
Definition: semisync_master_plugin.cc:80
struct Trans_observer Trans_observer
Observes and extends transaction execution.
static int repl_semi_report_before_rollback(Trans_param *)
Definition: semisync_master_plugin.cc:84
static int repl_semi_report_commit(Trans_param *param)
Definition: semisync_master_plugin.cc:86
static int repl_semi_report_rollback(Trans_param *param)
Definition: semisync_master_plugin.cc:97

◆ transmit_observer

Binlog_transmit_observer transmit_observer
Initial value:
= {
}
static int repl_semi_binlog_dump_end(Binlog_transmit_param *param)
Definition: semisync_master_plugin.cc:142
static int repl_semi_binlog_dump_start(Binlog_transmit_param *param, const char *log_file, my_off_t log_pos)
Definition: semisync_master_plugin.cc:103
static int repl_semi_before_send_event(Binlog_transmit_param *param, unsigned char *packet, unsigned long, const char *log_file, my_off_t log_pos)
Definition: semisync_master_plugin.cc:165
static int repl_semi_reset_master(Binlog_transmit_param *)
Definition: semisync_master_plugin.cc:197
struct Binlog_transmit_observer Binlog_transmit_observer
Observe and extends the binlog dumping thread.
static int repl_semi_reserve_header(Binlog_transmit_param *, unsigned char *header, unsigned long size, unsigned long *len)
Definition: semisync_master_plugin.cc:157
static int repl_semi_after_send_event(Binlog_transmit_param *param, const char *event_buf, unsigned long, const char *skipped_log_file, my_off_t skipped_log_pos)
Definition: semisync_master_plugin.cc:174

◆ wait_point_names

const char* wait_point_names[] = {"AFTER_SYNC", "AFTER_COMMIT", NullS}
static

◆ wait_point_typelib

TYPELIB wait_point_typelib
static
Initial value:
wait_point_names, nullptr}
static const char * wait_point_names[]
Definition: semisync_master_plugin.cc:251
#define array_elements(A)
Definition: validate_password_imp.cc:45