MySQL 9.0.0
Source Code Documentation
rpl_handler.h File Reference
#include <sys/types.h>
#include <atomic>
#include <map>
#include "my_alloc.h"
#include "my_dbug.h"
#include "my_inttypes.h"
#include "my_psi_config.h"
#include "my_sys.h"
#include "mysql/components/services/bits/mysql_rwlock_bits.h"
#include "mysql/components/services/bits/psi_rwlock_bits.h"
#include "mysql/psi/mysql_rwlock.h"
#include "sql/locks/shared_spin_lock.h"
#include "sql/psi_memory_key.h"
#include "sql/sql_list.h"
#include "sql/sql_plugin.h"
#include "sql/sql_plugin_ref.h"

Go to the source code of this file.

Classes

class  Observer_info
 
class  Delegate
 Base class for adding replication event observer infra-structure. More...
 
class  Trans_delegate
 
class  Server_state_delegate
 
class  Binlog_storage_delegate
 
class  Binlog_transmit_delegate
 
class  Binlog_relay_IO_delegate
 

Macros

#define RUN_HOOK(group, hook, args)    (group##_delegate->is_empty() ? 0 : group##_delegate->hook args)
 
#define NO_HOOK(group)   (group##_delegate->is_empty())
 

Functions

int delegates_init ()
 
void delegates_shutdown ()
 Verify that the replication plugins are ready and OK to be unloaded. More...
 
void delegates_destroy ()
 
void delegates_acquire_locks ()
 Invokes write_lock() for all the observer delegate objects. More...
 
void delegates_release_locks ()
 Releases locks for all the observer delegate objects. More...
 
void delegates_update_lock_type ()
 Toggles the type of lock between a classical read-write lock and a shared-exclusive spin-lock. More...
 
int launch_hook_trans_begin (THD *thd, Table_ref *table)
 

Variables

bool opt_replication_optimize_for_static_plugin_config
 Variable to keep the value set for the replication_optimize_for_static_plugin_config global. More...
 
std::atomic< bool > opt_replication_sender_observe_commit_only
 Variable to keep the value set for the replication_sender_observe_commit_only global. More...
 
PSI_rwlock_key key_rwlock_Trans_delegate_lock
 
PSI_rwlock_key key_rwlock_Server_state_delegate_lock
 
PSI_rwlock_key key_rwlock_Binlog_storage_delegate_lock
 
PSI_rwlock_key key_rwlock_Binlog_transmit_delegate_lock
 
PSI_rwlock_key key_rwlock_Binlog_relay_IO_delegate_lock
 
Trans_delegatetransaction_delegate
 
Binlog_storage_delegatebinlog_storage_delegate
 
Server_state_delegateserver_state_delegate
 
Binlog_transmit_delegatebinlog_transmit_delegate
 
Binlog_relay_IO_delegatebinlog_relay_io_delegate
 

Macro Definition Documentation

◆ NO_HOOK

#define NO_HOOK (   group)    (group##_delegate->is_empty())

◆ RUN_HOOK

#define RUN_HOOK (   group,
  hook,
  args 
)     (group##_delegate->is_empty() ? 0 : group##_delegate->hook args)

Function Documentation

◆ delegates_acquire_locks()

void delegates_acquire_locks ( )

Invokes write_lock() for all the observer delegate objects.

◆ delegates_destroy()

void delegates_destroy ( )

◆ delegates_init()

int delegates_init ( )

◆ delegates_release_locks()

void delegates_release_locks ( )

Releases locks for all the observer delegate objects.

◆ delegates_shutdown()

void delegates_shutdown ( )

Verify that the replication plugins are ready and OK to be unloaded.

◆ delegates_update_lock_type()

void delegates_update_lock_type ( )

Toggles the type of lock between a classical read-write lock and a shared-exclusive spin-lock.

◆ launch_hook_trans_begin()

int launch_hook_trans_begin ( THD thd,
Table_ref table 
)

Variable Documentation

◆ binlog_relay_io_delegate

Binlog_relay_IO_delegate* binlog_relay_io_delegate
extern

◆ binlog_storage_delegate

Binlog_storage_delegate* binlog_storage_delegate
extern

◆ binlog_transmit_delegate

Binlog_transmit_delegate* binlog_transmit_delegate
extern

◆ key_rwlock_Binlog_relay_IO_delegate_lock

PSI_rwlock_key key_rwlock_Binlog_relay_IO_delegate_lock
extern

◆ key_rwlock_Binlog_storage_delegate_lock

PSI_rwlock_key key_rwlock_Binlog_storage_delegate_lock
extern

◆ key_rwlock_Binlog_transmit_delegate_lock

PSI_rwlock_key key_rwlock_Binlog_transmit_delegate_lock
extern

◆ key_rwlock_Server_state_delegate_lock

PSI_rwlock_key key_rwlock_Server_state_delegate_lock
extern

◆ key_rwlock_Trans_delegate_lock

PSI_rwlock_key key_rwlock_Trans_delegate_lock
extern

◆ opt_replication_optimize_for_static_plugin_config

bool opt_replication_optimize_for_static_plugin_config
extern

Variable to keep the value set for the replication_optimize_for_static_plugin_config global.

When this global variable value is set to 1, we prevent all plugins that register replication observers to be unloaded until the variable is set to 0, again. While the value of the variable is 1, we are also exchanging the Delegate class read-write lock by an atomic-based shared spin-lock.

This behaviour is useful for increasing the throughtput of the master when a large number of slaves is connected, by preventing the acquisition of the LOCK_plugin mutex and using a more read-friendly lock in the Delegate class, when invoking the observer's hooks.

Note that a large number of slaves means a large number of dump threads, which means a large number of threads calling the registered observers hooks.

If UNINSTALL is executed on a replication observer plugin while the variable is set to 1, the unload of the plugin will be deferred until the variable's value is set to 0.

◆ opt_replication_sender_observe_commit_only

std::atomic<bool> opt_replication_sender_observe_commit_only
extern

Variable to keep the value set for the replication_sender_observe_commit_only global.

When this global variable is set to 1, only the replication observer's commit hook will be called, every other registered hook invocation is skipped.

◆ server_state_delegate

Server_state_delegate* server_state_delegate
extern

◆ transaction_delegate

Trans_delegate* transaction_delegate
extern