MySQL  8.0.15
Source Code Documentation
Relay_log_info Class Reference

#include <rpl_rli.h>

Inheritance diagram for Relay_log_info:
Rpl_info Slave_reporting_capability Slave_worker

Public Types

enum  enum_state_flag { IN_STMT, STATE_FLAGS_COUNT }
 Flags for the state of the replication. More...
 
enum  { COMMIT_TS_UNKNOWN, COMMIT_TS_NOT_FOUND, COMMIT_TS_FOUND }
 the status of the commit timestamps for the relay log More...
 
enum  {
  UNTIL_NONE = 0, UNTIL_MASTER_POS, UNTIL_RELAY_POS, UNTIL_SQL_BEFORE_GTIDS,
  UNTIL_SQL_AFTER_GTIDS, UNTIL_SQL_AFTER_MTS_GAPS, UNTIL_SQL_VIEW_ID, UNTIL_DONE
}
 
enum  { MTS_NOT_IN_GROUP, MTS_IN_GROUP, MTS_END_GROUP, MTS_KILLED_GROUP }
 

Public Member Functions

bool belongs_to_client ()
 
Gtid_monitoring_infoget_gtid_monitoring_info ()
 
void started_processing (Gtid gtid_arg, ulonglong original_ts_arg, ulonglong immediate_ts_arg, bool skipped=false)
 Stores the details of the transaction which has just started processing. More...
 
void started_processing (Gtid_log_event *gtid_log_ev_arg)
 Stores the details of the transaction which has just started processing. More...
 
void finished_processing ()
 When the processing of a transaction is completed, that timestamp is recorded, the information is copied to last_processed_trx and the information in processing_trx is cleared. More...
 
bool is_processing_trx ()
 
void clear_processing_trx ()
 Clears the processing_trx structure fields. More...
 
void clear_gtid_monitoring_info ()
 Clears the Gtid_monitoring_info fields. More...
 
void retried_processing (uint transient_errno_arg, const char *transient_err_message_arg, ulong trans_retries_arg)
 When a transaction is retried, the error number and message, and total number of retries are stored. More...
 
bool is_relay_log_truncated ()
 
Sid_mapget_sid_map ()
 
Checkable_rwlockget_sid_lock ()
 
void add_logged_gtid (rpl_sidno sidno, rpl_gno gno)
 
enum_return_status add_gtid_set (const Gtid_set *gtid_set)
 Adds a GTID set to received GTID set. More...
 
const Gtid_setget_gtid_set () const
 
bool reinit_sql_thread_io_cache (const char *log, bool need_data_lock)
 
bool is_group_relay_log_name_invalid (const char **errmsg)
 Check if group_relay_log_name is in index file. More...
 
bool reset_group_relay_log_pos (const char **errmsg)
 Reset group_relay_log_name and group_relay_log_pos to the start of the first relay log file. More...
 
void fill_coord_err_buf (loglevel level, int err_code, const char *buff_coord) const
 Update the error number, message and timestamp fields. More...
 
void clear_sql_delay ()
 Reset the delay. More...
 
void notify_relay_log_change ()
 Invalidates cached until_log_name and event_relay_log_name comparison result. More...
 
void notify_relay_log_truncated ()
 Receiver thread notifies that it truncated some data from relay log. More...
 
void clear_relay_log_truncated ()
 Applier clears the flag after it handled the situation. More...
 
void notify_group_master_log_name_update ()
 The same as notify_group_relay_log_name_update but for group_master_log_name. More...
 
void inc_event_relay_log_pos ()
 
int inc_group_relay_log_pos (ulonglong log_pos, bool need_data_lock, bool force=false)
 Last executed event group coordinates are updated and optionally forcibly flushed to a repository. More...
 
int wait_for_pos (THD *thd, String *log_name, longlong log_pos, double timeout)
 Waits until the SQL thread reaches (has executed up to) the log/position or timed out. More...
 
int wait_for_gtid_set (THD *thd, const char *gtid, double timeout, bool update_THD_status=true)
 Wait for a GTID set to be executed. More...
 
int wait_for_gtid_set (THD *thd, String *gtid, double timeout, bool update_THD_status=true)
 Wait for a GTID set to be executed. More...
 
int wait_for_gtid_set (THD *thd, const Gtid_set *wait_gtid_set, double timeout, bool update_THD_status=true)
 Wait for a GTID set to be executed. More...
 
void close_temporary_tables ()
 
bool get_table_data (TABLE *table_arg, table_def **tabledef_var, TABLE **conv_table_var) const
 
void cached_charset_invalidate ()
 Last charset (6 bytes) seen by slave SQL thread is cached here; it helps the thread save 3 get_charset() per Query_log_event if the charset is not changing from event to event (common situation). More...
 
bool cached_charset_compare (char *charset) const
 
void cleanup_context (THD *, bool)
 
void slave_close_thread_tables (THD *)
 
void clear_tables_to_lock ()
 
int purge_relay_logs (THD *thd, const char **errmsg, bool delete_only=false)
 Purges relay logs. More...
 
size_t get_worker_count ()
 
Slave_workerget_worker (size_t n)
 
virtual bool commit_positions ()
 The method implements updating a slave info table. More...
 
void init_workers (ulong)
 The method to invoke at slave threads start. More...
 
void deinit_workers ()
 The method to invoke at slave threads stop. More...
 
bool is_mts_recovery () const
 returns true if there is any gap-group of events to execute at slave starting phase. More...
 
void clear_mts_recovery_groups ()
 
bool is_parallel_exec () const
 returns true if events are to be executed in parallel More...
 
bool is_mts_in_group ()
 returns true if Coordinator is scheduling events belonging to the same group and has not reached yet its terminal event. More...
 
bool is_time_for_mts_checkpoint ()
 Check if it is time to compute MTS checkpoint. More...
 
void reset_notified_relay_log_change ()
 While a group is executed by a Worker the relay log can change. More...
 
void reset_notified_checkpoint (ulong count, time_t new_ts, bool update_timestamp=false)
 While a group is executed by a Worker the relay log can change. More...
 
bool mts_finalize_recovery ()
 Called when gaps execution is ended so it is crash-safe to reset the last session Workers info. More...
 
void cleanup_after_query ()
 
void cleanup_after_session ()
 
int stmt_done (my_off_t event_log_pos)
 Helper function to do after statement completion. More...
 
void set_flag (enum_state_flag flag)
 Set the value of a replication state flag. More...
 
bool get_flag (enum_state_flag flag)
 Get the value of a replication state flag. More...
 
void clear_flag (enum_state_flag flag)
 Clear the value of a replication state flag. More...
 
bool is_in_group () const
 A group is defined as the entire range of events that constitute a transaction or auto-committed statement. More...
 
int count_relay_log_space ()
 
int rli_init_info (bool skip_received_gtid_set_recovery=false)
 Initialize the relay log info. More...
 
void end_info ()
 
int flush_info (bool force=false)
 Stores the file and position where the execute-slave thread are in the relay log: More...
 
int flush_current_log ()
 
void set_master_info (Master_info *info)
 
ulonglong get_future_event_relay_log_pos ()
 
void set_future_event_relay_log_pos (ulonglong log_pos)
 
const char * get_group_master_log_name ()
 
ulonglong get_group_master_log_pos ()
 
void set_group_master_log_name (const char *log_file_name)
 
void set_group_master_log_pos (ulonglong log_pos)
 
const char * get_group_relay_log_name ()
 
ulonglong get_group_relay_log_pos ()
 
void set_group_relay_log_name (const char *log_file_name)
 
void set_group_relay_log_name (const char *log_file_name, size_t len)
 
void set_group_relay_log_pos (ulonglong log_pos)
 
const char * get_event_relay_log_name ()
 
ulonglong get_event_relay_log_pos ()
 
void set_event_relay_log_name (const char *log_file_name)
 
uint get_event_relay_log_number ()
 
void set_event_relay_log_number (uint number)
 
void relay_log_number_to_name (uint number, char name[FN_REFLEN+1])
 Given the extension number of the relay log, gets the full relay log path. More...
 
uint relay_log_name_to_number (const char *name)
 
void set_event_start_pos (my_off_t pos)
 
my_off_t get_event_start_pos ()
 
void set_event_relay_log_pos (ulonglong log_pos)
 
const char * get_rpl_log_name ()
 
void start_sql_delay (time_t delay_end)
 Indicate that a delay starts. More...
 
time_t get_sql_delay ()
 
void set_sql_delay (time_t _sql_delay)
 
time_t get_sql_delay_end ()
 
 Relay_log_info (bool is_slave_recovery, PSI_mutex_key *param_key_info_run_lock, PSI_mutex_key *param_key_info_data_lock, PSI_mutex_key *param_key_info_sleep_lock, PSI_mutex_key *param_key_info_thd_lock, PSI_mutex_key *param_key_info_data_cond, PSI_mutex_key *param_key_info_start_cond, PSI_mutex_key *param_key_info_stop_cond, PSI_mutex_key *param_key_info_sleep_cond, uint param_id, const char *param_channel, bool is_rli_fake)
 
virtual ~Relay_log_info ()
 
time_t get_row_stmt_start_timestamp ()
 
time_t set_row_stmt_start_timestamp ()
 
void reset_row_stmt_start_timestamp ()
 
void set_long_find_row_note_printed ()
 
void unset_long_find_row_note_printed ()
 
bool is_long_find_row_note_printed ()
 
virtual int set_rli_description_event (Format_description_log_event *fdle)
 Delete the existing event and set a new one. More...
 
Format_description_log_eventget_rli_description_event () const
 Return the current Format_description_log_event. More...
 
ulong adapt_to_master_version (Format_description_log_event *fdle)
 adaptation for the slave applier to specific master versions. More...
 
ulong adapt_to_master_version_updown (ulong master_version, ulong current_version)
 The method compares two supplied versions and carries out down- or up- grade customization of execution context of the slave applier (thd). More...
 
Commit_order_managerget_commit_order_manager ()
 
void set_commit_order_manager (Commit_order_manager *mngr)
 
void set_until_option (Until_option *option)
 
void clear_until_option ()
 
bool set_info_search_keys (Rpl_info_handler *to)
 To search in the slave repositories, each slave info object (mi, rli or worker) should use a primary key. More...
 
virtual Relay_log_infoget_c_rli ()
 Get coordinator's RLI. More...
 
virtual const char * get_for_channel_str (bool upper_case=false) const
 
void set_filter (Rpl_filter *channel_filter)
 Set replication filter for the channel. More...
 
void set_thd_tx_priority (int priority)
 
int get_thd_tx_priority ()
 
const char * get_until_log_name ()
 
my_off_t get_until_log_pos ()
 
bool is_until_satisfied_at_start_slave ()
 
bool is_until_satisfied_before_dispatching_event (const Log_event *ev)
 
bool is_until_satisfied_after_dispatching_event ()
 
int init_until_option (THD *thd, const LEX_MASTER_INFO *master_param)
 Intialize until option object when starting slave. More...
 
void detach_engine_ha_data (THD *thd)
 Detaches the engine ha_data from THD. More...
 
void reattach_engine_ha_data (THD *thd)
 Reattaches the engine ha_data to THD. More...
 
bool unflag_detached_engine_ha_data ()
 Drops the engine ha_data flag when it is up. More...
 
void post_rollback ()
 Execute actions at replicated atomic DLL post rollback time. More...
 
bool pre_commit ()
 The method implements a pre-commit hook to add up a new statement typically to a DDL transaction to update the slave info table. More...
 
virtual void post_commit (bool on_rollback)
 Cleanup of any side effect that pre_commit() inflicts, including restore of the last executed group coordinates in case the current group has been destined to rollback, and signaling to possible waiters in the positive case. More...
 
- Public Member Functions inherited from Rpl_info
virtual ~Rpl_info ()
 
void set_rpl_info_handler (Rpl_info_handler *param_handler)
 Sets the persistency component/handler. More...
 
Rpl_info_handlerget_rpl_info_handler ()
 Gets the persistency component/handler. More...
 
enum_return_check check_info ()
 
int remove_info ()
 
int clean_info ()
 
bool is_transactional ()
 
bool update_is_transactional ()
 
char * get_description_info ()
 
bool copy_info (Rpl_info_handler *from, Rpl_info_handler *to)
 
uint get_internal_id ()
 
char * get_channel ()
 
- Public Member Functions inherited from Slave_reporting_capability
 Slave_reporting_capability (char const *thread_name)
 Constructor. More...
 
virtual void report (loglevel level, int err_code, const char *msg,...) const
 Writes a message and, if it's an error message, to Last_Error (which will be displayed by SHOW SLAVE STATUS). More...
 
void va_report (loglevel level, int err_code, const char *prefix_msg, const char *msg, va_list v_args) const
 
void clear_error ()
 Clear errors. More...
 
int has_temporary_error (THD *thd, uint error_arg=0, bool *silent=0) const
 Check if the current error is of temporary nature or not. More...
 
Error const & last_error () const
 
bool is_error () const
 
virtual ~Slave_reporting_capability ()=0
 

Static Public Member Functions

static size_t get_number_info_rli_fields ()
 

Public Attributes

Rpl_filterrpl_filter
 
PSI_mutex_key m_key_mts_temp_table_LOCK
 
mysql_mutex_t mts_temp_table_LOCK
 
mysql_mutex_t mts_gaq_LOCK
 
mysql_cond_t logical_clock_cond
 
bool replicate_same_server_id
 
MYSQL_BIN_LOG relay_log
 
bool is_relay_log_recovery
 
TABLEsave_temporary_tables
 
Master_infomi
 
std::atomic< int32 > atomic_channel_open_temp_tables {0}
 
enum Relay_log_info:: { ... }  commit_timestamps_status
 the status of the commit timestamps for the relay log More...
 
bool error_on_rli_init_info
 
bool gtid_timestamps_warning_logged
 Variable is set to true as long as original_commit_timestamp > immediate_commit_timestamp so that the corresponding warning is only logged once. More...
 
bool is_group_master_log_pos_invalid
 
ulonglong log_space_limit
 
ulonglong log_space_total
 
bool ignore_log_space_limit
 
bool sql_force_rotate_relay
 
time_t last_master_timestamp
 
volatile uint32 slave_skip_counter
 
volatile ulong abort_pos_wait
 
mysql_mutex_t log_space_lock
 
mysql_cond_t log_space_cond
 
enum Relay_log_info:: { ... }  until_condition
 
char cached_charset [6]
 
ulong trans_retries
 
ulong retried_trans
 
char ign_master_log_name_end [FN_REFLEN]
 
ulonglong ign_master_log_pos_end
 
char slave_patternload_file [FN_REFLEN]
 
size_t slave_patternload_file_size
 
struct timespec last_clock
 Identifies the last time a checkpoint routine has been executed. More...
 
RPL_TABLE_LISTtables_to_lock
 
uint tables_to_lock_count
 
table_mapping m_table_map
 
Rows_query_log_eventrows_query_ev
 
time_t last_event_start_time
 
uint64 original_commit_timestamp
 
Deferred_log_eventsdeferred_events
 
bool deferred_events_collecting
 
Slave_worker_array workers
 
malloc_unordered_map< std::string, unique_ptr_with_deleter< db_worker_hash_entry > > mapping_db_to_worker {key_memory_db_worker_hash_entry}
 
bool inited_hash_workers
 
mysql_mutex_t slave_worker_hash_lock
 
mysql_cond_t slave_worker_hash_cond
 
std::vector< Slave_worker * > workers_copy_pfs
 
bool workers_array_initialized
 
volatile ulong pending_jobs
 
mysql_mutex_t pending_jobs_lock
 
mysql_cond_t pending_jobs_cond
 
mysql_mutex_t exit_count_lock
 
ulong mts_slave_worker_queue_len_max
 
ulonglong mts_pending_jobs_size
 
ulonglong mts_pending_jobs_size_max
 
bool mts_wq_oversize
 
Slave_workerlast_assigned_worker
 
Slave_committed_queuegaq
 
Prealloced_array< db_worker_hash_entry *, 4 > curr_group_assigned_parts
 
Prealloced_array< Slave_job_item, 8 > curr_group_da
 
bool curr_group_seen_gtid
 
bool curr_group_seen_begin
 
bool curr_group_isolated
 
bool mts_end_group_sets_max_dbs
 
volatile ulong mts_wq_underrun_w_id
 
volatile long mts_wq_excess_cnt
 
long mts_worker_underrun_level
 
ulong mts_coordinator_basic_nap
 
ulong opt_slave_parallel_workers
 
ulong slave_parallel_workers
 
ulong exit_counter
 
ulonglong max_updated_index
 
ulong recovery_parallel_workers
 
uint rli_checkpoint_seqno
 
uint checkpoint_group
 
MY_BITMAP recovery_groups
 
bool recovery_groups_inited
 
ulong mts_recovery_group_cnt
 
ulong mts_recovery_index
 
bool mts_recovery_group_seen_begin
 
enum Relay_log_info:: { ... }  mts_group_status
 
ulonglong mts_events_assigned
 
ulonglong mts_groups_assigned
 
volatile ulong mts_wq_overrun_cnt
 
ulong wq_size_waits_cnt
 
ulong mts_wq_no_underrun_cnt
 
std::atomic< longlongmts_total_wait_overlap
 
ulonglong mts_total_wait_worker_avail
 
ulong mts_wq_overfill_cnt
 
ulonglong stats_exec_time
 
ulonglong stats_read_time
 
struct timespec ts_exec [2]
 
struct timespec stats_begin
 
Prealloced_array< ulong, 16 > least_occupied_workers
 
time_t mts_last_online_stat
 
char new_group_master_log_name [FN_REFLEN]
 Storage for holding newly computed values for the last executed event group coordinates while the current group of events is being committed, see pre_commit, post_commit. More...
 
my_off_t new_group_master_log_pos
 
char new_group_relay_log_name [FN_REFLEN]
 
my_off_t new_group_relay_log_pos
 
enum_mts_parallel_type channel_mts_submode
 
Mts_submodecurrent_mts_submode
 
bool reported_unsafe_warning
 
bool sql_thread_kill_accepted
 
uchar slave_version_split [3]
 
bool force_flush_postponed_due_to_split_trans
 
bool is_engine_ha_data_detached
 
Log_eventcurrent_event
 Reference to being applied event. More...
 
bool ddl_not_atomic
 Raised when slave applies and writes to its binary log statement which is not atomic DDL and has no XID assigned. More...
 
- Public Attributes inherited from Rpl_info
mysql_mutex_t data_lock
 
mysql_mutex_t run_lock
 
mysql_mutex_t sleep_lock
 
mysql_mutex_t info_thd_lock
 
mysql_cond_t data_cond
 
mysql_cond_t start_cond
 
mysql_cond_t stop_cond
 
mysql_cond_t sleep_cond
 
PSI_mutex_keykey_info_run_lock
 
PSI_mutex_keykey_info_data_lock
 
PSI_mutex_keykey_info_sleep_lock
 
PSI_mutex_keykey_info_thd_lock
 
PSI_mutex_keykey_info_data_cond
 
PSI_mutex_keykey_info_start_cond
 
PSI_mutex_keykey_info_stop_cond
 
PSI_mutex_keykey_info_sleep_cond
 
THDinfo_thd
 
bool inited
 
std::atomic< boolabort_slave
 
std::atomic< uintslave_running
 
std::atomic< ulongslave_run_id
 
int events_until_exit
 
std::atomic< boolatomic_is_stopping {false}
 
- Public Attributes inherited from Slave_reporting_capability
mysql_mutex_t err_lock
 lock used to synchronize m_last_error on 'SHOW SLAVE STATUS' More...
 

Protected Attributes

char group_relay_log_name [FN_REFLEN]
 Event group means a group of events of a transaction. More...
 
ulonglong group_relay_log_pos
 
char event_relay_log_name [FN_REFLEN]
 
uint event_relay_log_number
 
ulonglong event_relay_log_pos
 
ulonglong future_event_relay_log_pos
 
my_off_t event_start_pos
 
char group_master_log_name [FN_REFLEN]
 
volatile my_off_t group_master_log_pos
 
Format_description_log_eventrli_description_event
 
- Protected Attributes inherited from Rpl_info
Rpl_info_handlerhandler
 Pointer to the repository's handler. More...
 
uint internal_id
 Uniquely and internaly identifies an info entry (.e.g. More...
 
char channel [CHANNEL_NAME_LENGTH+1]
 Every slave info object acts on a particular channel in Multisource Replication. More...
 
- Protected Attributes inherited from Slave_reporting_capability
Error m_last_error
 Last error produced by the I/O or SQL thread respectively. More...
 

Private Member Functions

bool is_in_stmt () const
 Auxiliary function used by is_in_group. More...
 
bool is_in_trx_or_stmt () const
 Auxiliary function used by is_in_group. More...
 
bool read_info (Rpl_info_handler *from)
 
bool write_info (Rpl_info_handler *to)
 
 Relay_log_info (const Relay_log_info &info)
 
Relay_log_infooperator= (const Relay_log_info &info)
 
const char * add_channel_to_relay_log_name (char *buff, uint buff_size, const char *base_name)
 sets the suffix required for relay log names in multisource replication. More...
 

Private Attributes

Gtid_setgtid_set
 
bool rli_fake
 
bool gtid_retrieved_initialized
 
Gtid_monitoring_infogtid_monitoring_info
 Stores information on the last processed transaction or the transaction that is currently being processed. More...
 
bool m_relay_log_truncated = false
 It will be set to true when receiver truncated relay log for some reason. More...
 
Commit_order_managercommit_order_mngr
 
time_t sql_delay
 Delay slave SQL thread by this amount of seconds. More...
 
time_t sql_delay_end
 During a delay, specifies the point in time when the delay ends. More...
 
uint32 m_flags
 
time_t row_stmt_start_timestamp
 
bool long_find_row_note_printed
 
int thd_tx_priority
 
Until_optionuntil_option
 

Static Private Attributes

static const int LINES_IN_RELAY_LOG_INFO_WITH_DELAY = 5
 
static const int LINES_IN_RELAY_LOG_INFO_WITH_WORKERS = 6
 
static const int LINES_IN_RELAY_LOG_INFO_WITH_ID = 7
 
static const int LINES_IN_RELAY_LOG_INFO_WITH_CHANNEL = 8
 

Friends

class Rpl_info_factory
 

Additional Inherited Members

- Protected Member Functions inherited from Rpl_info
 Rpl_info (const char *type, PSI_mutex_key *param_key_info_run_lock, PSI_mutex_key *param_key_info_data_lock, PSI_mutex_key *param_key_info_sleep_lock, PSI_mutex_key *param_key_info_thd_lock, PSI_mutex_key *param_key_info_data_cond, PSI_mutex_key *param_key_info_start_cond, PSI_mutex_key *param_key_info_stop_cond, PSI_mutex_key *param_key_info_sleep_cond, uint param_id, const char *param_channel)
 
- Protected Member Functions inherited from Slave_reporting_capability
virtual void do_report (loglevel level, int err_code, const char *msg, va_list v_args) const
 

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

the status of the commit timestamps for the relay log

Enumerator
COMMIT_TS_UNKNOWN 
COMMIT_TS_NOT_FOUND 
COMMIT_TS_FOUND 

◆ anonymous enum

anonymous enum
Enumerator
UNTIL_NONE 
UNTIL_MASTER_POS 
UNTIL_RELAY_POS 
UNTIL_SQL_BEFORE_GTIDS 
UNTIL_SQL_AFTER_GTIDS 
UNTIL_SQL_AFTER_MTS_GAPS 
UNTIL_SQL_VIEW_ID 
UNTIL_DONE 

◆ anonymous enum

anonymous enum
Enumerator
MTS_NOT_IN_GROUP 
MTS_IN_GROUP 
MTS_END_GROUP 
MTS_KILLED_GROUP 

◆ enum_state_flag

Flags for the state of the replication.

Enumerator
IN_STMT 

The replication thread is inside a statement.

STATE_FLAGS_COUNT 

Flag counter.

Should always be last

Constructor & Destructor Documentation

◆ Relay_log_info() [1/2]

Relay_log_info::Relay_log_info ( bool  is_slave_recovery,
PSI_mutex_key param_key_info_run_lock,
PSI_mutex_key param_key_info_data_lock,
PSI_mutex_key param_key_info_sleep_lock,
PSI_mutex_key param_key_info_thd_lock,
PSI_mutex_key param_key_info_data_cond,
PSI_mutex_key param_key_info_start_cond,
PSI_mutex_key param_key_info_stop_cond,
PSI_mutex_key param_key_info_sleep_cond,
uint  param_id,
const char *  param_channel,
bool  is_rli_fake 
)

◆ ~Relay_log_info()

Relay_log_info::~Relay_log_info ( )
virtual

◆ Relay_log_info() [2/2]

Relay_log_info::Relay_log_info ( const Relay_log_info info)
private

Member Function Documentation

◆ adapt_to_master_version()

ulong Relay_log_info::adapt_to_master_version ( Format_description_log_event fdle)

adaptation for the slave applier to specific master versions.

The method computes the incoming "master"'s FD server version and that of the currently installed (if ever) rli_description_event, to invoke more specific method to compare the two and adapt slave applier execution context to the new incoming master's version.

This method is specifically for STS applier/MTS Coordinator as well as for a user thread applying binlog events.

Parameters
fdlea pointer to new Format Description event that is being set up a new execution context.
Returns
0 when the versions are equal, master_version otherwise

◆ adapt_to_master_version_updown()

ulong Relay_log_info::adapt_to_master_version_updown ( ulong  master_version,
ulong  current_version 
)

The method compares two supplied versions and carries out down- or up- grade customization of execution context of the slave applier (thd).

The method is invoked in the STS case through Relay_log_info::adapt_to_master_version() right before a new master FD is installed into the applier execution context; in the MTS case it's done by the Worker when it's assigned with a first event after the latest new FD has been installed.

Comparison of the current (old, existing) and the master (new, incoming) versions yields adaptive actions. To explain that, let's denote V_0 as the current, and the master's one as V_1. In the downgrade case (V_1 < V_0) a server feature that is undefined in V_1 but is defined starting from some V_f of [V_1 + 1, V_0] range (+1 to mean V_1 excluded) are invalidated ("removed" from execution context) by running so called here downgrade action. Conversely in the upgrade case a feature defined in [V_0 + 1, V_1] range is validated ("added" to execution context) by running its upgrade action. A typical use case showing how adaptive actions are necessary for the slave applier is when the master version is lesser than the slave's one. In such case events generated on the "older" master may need to be applied in their native server context. And such context can be provided by downgrade actions. Conversely, when the old master events are run out and a newer master's events show up for applying, the execution context will be upgraded through the namesake actions.

Notice that a relay log may have two FD events, one the slave local and the other from the Master. As there's no concern for the FD originator this leads to two adapt_to_master_version() calls. It's not harmful as can be seen from the following example. Say the currently installed FD's version is V_m, then at relay-log rotation the following transition takes place:

V_m -adapt-> V_s -adapt-> V_m.

here and further ‘m’ subscript stands for the master, ‘s’ for the slave. It's clear that in this case an ineffective V_m -> V_m transition occurs.

At composing downgrade/upgrade actions keep in mind that the slave applier version transition goes the following route: The initial version is that of the slave server (V_ss). It changes to a magic 4.0 at the slave relay log initialization. In the following course versions are extracted from each FD read out, regardless of what server generated it. Here is a typical version transition sequence underscored with annotation:

V_ss -> 4.0 -> V(FD_s^1) -> V(FD_m^2) —> V(FD_s^3) -> V(FD_m^4) ...


bootstrap 1st relay log rotation 2nd log etc

The upper (^) subscipt enumerates Format Description events, V(FD^i) stands for a function extrating the version data from the i:th FD.

There won't be any action to execute when info_thd is undefined, e.g at bootstrap.

Parameters
master_versionan upcoming new version
current_versionthe current version
Returns
0 when the new version is equal to the current one, master_version otherwise

◆ add_channel_to_relay_log_name()

const char * Relay_log_info::add_channel_to_relay_log_name ( char *  buff,
uint  buff_size,
const char *  base_name 
)
private

sets the suffix required for relay log names in multisource replication.

When –relay-log option is not provided, the names of the relay log files are relaylog.0000x or relaylog-CHANNEL.00000x in the case of MSR. However, if that option is provided, then the names of the relay log files are <relay-log-option>.0000x or <relay-log-option>-CHANNEL.00000x in the case of MSR.

The function adds a channel suffix (according to the channel to file name conventions and conversions) to the relay log file.

Parameters
[in,out]buffbuffer to store the complete relay log file name
[in]buff_sizesize of buffer buff
[in]base_namethe base name of the relay log file

◆ add_gtid_set()

enum_return_status Relay_log_info::add_gtid_set ( const Gtid_set gtid_set)

Adds a GTID set to received GTID set.

Parameters
gtid_setthe gtid_set to add
Returns
RETURN_STATUS_OK or RETURN_STATUS_REPORTED_ERROR.

◆ add_logged_gtid()

void Relay_log_info::add_logged_gtid ( rpl_sidno  sidno,
rpl_gno  gno 
)
inline

◆ belongs_to_client()

bool Relay_log_info::belongs_to_client ( )
inline

◆ cached_charset_compare()

bool Relay_log_info::cached_charset_compare ( char *  charset) const

◆ cached_charset_invalidate()

void Relay_log_info::cached_charset_invalidate ( )

Last charset (6 bytes) seen by slave SQL thread is cached here; it helps the thread save 3 get_charset() per Query_log_event if the charset is not changing from event to event (common situation).

When the 6 bytes are equal to 0 is used to mean "cache is invalidated".

◆ cleanup_after_query()

void Relay_log_info::cleanup_after_query ( )
inline

◆ cleanup_after_session()

void Relay_log_info::cleanup_after_session ( )
inline

◆ cleanup_context()

void Relay_log_info::cleanup_context ( THD thd,
bool  error 
)

◆ clear_flag()

void Relay_log_info::clear_flag ( enum_state_flag  flag)
inline

Clear the value of a replication state flag.

Parameters
flagFlag to clear

◆ clear_gtid_monitoring_info()

void Relay_log_info::clear_gtid_monitoring_info ( )
inline

Clears the Gtid_monitoring_info fields.

◆ clear_mts_recovery_groups()

void Relay_log_info::clear_mts_recovery_groups ( )
inline

◆ clear_processing_trx()

void Relay_log_info::clear_processing_trx ( )
inline

Clears the processing_trx structure fields.

Normally called when there is an error while processing the transaction.

◆ clear_relay_log_truncated()

void Relay_log_info::clear_relay_log_truncated ( )

Applier clears the flag after it handled the situation.

The caller must hold data_lock.

◆ clear_sql_delay()

void Relay_log_info::clear_sql_delay ( )
inline

Reset the delay.

This is used by RESET SLAVE to clear the delay.

◆ clear_tables_to_lock()

void Relay_log_info::clear_tables_to_lock ( )

When replicating in RBR and MyISAM Merge tables are involved open_and_lock_tables (called in do_apply_event) appends the base tables to the list of tables_to_lock. Then these are removed from the list in close_thread_tables (which is called before we reach this point).

This assertion just confirms that we get no surprises at this point.

◆ clear_until_option()

void Relay_log_info::clear_until_option ( )
inline

◆ close_temporary_tables()

void Relay_log_info::close_temporary_tables ( )

◆ commit_positions()

bool Relay_log_info::commit_positions ( )
virtual

The method implements updating a slave info table.

It's specialized differently for STS and MTS.

Reimplemented in Slave_worker.

◆ count_relay_log_space()

int Relay_log_info::count_relay_log_space ( )

◆ deinit_workers()

void Relay_log_info::deinit_workers ( )

The method to invoke at slave threads stop.

◆ detach_engine_ha_data()

void Relay_log_info::detach_engine_ha_data ( THD thd)

Detaches the engine ha_data from THD.

The fact is memorized in is_engine_ha_detached flag.

Parameters
thda reference to THD

◆ end_info()

void Relay_log_info::end_info ( )

◆ fill_coord_err_buf()

void Relay_log_info::fill_coord_err_buf ( loglevel  level,
int  err_code,
const char *  buff_coord 
) const

Update the error number, message and timestamp fields.

This function is different from va_report() as va_report() also logs the error message in the log apart from updating the error fields.

SYNOPSIS

Parameters
[in]levelspecifies the level- error, warning or information,
[in]err_codeerror number,
[in]buff_coorderror message to be used.

◆ finished_processing()

void Relay_log_info::finished_processing ( )
inline

When the processing of a transaction is completed, that timestamp is recorded, the information is copied to last_processed_trx and the information in processing_trx is cleared.

If the transaction was "applied" but GTID-skipped, the copy will not happen and the last_processed_trx will keep its current value.

◆ flush_current_log()

int Relay_log_info::flush_current_log ( )

◆ flush_info()

int Relay_log_info::flush_info ( bool  force = false)

Stores the file and position where the execute-slave thread are in the relay log:

  • As this is only called by the slave thread or on STOP SLAVE, with the log_lock grabbed and the slave thread stopped, we don't need to have a lock here.
  • If there is an active transaction, then we don't update the position in the relay log. This is to ensure that we re-execute statements if we die in the middle of an transaction that was rolled back.
  • As a transaction never spans binary logs, we don't have to handle the case where we do a relay-log-rotation in the middle of the transaction. If this would not be the case, we would have to ensure that we don't delete the relay log file where the transaction started when we switch to a new relay log file.
Return values
0ok,
1write error, otherwise.Store the file and position where the slave's SQL thread are in the relay log.

Notes:

  • This function should be called either from the slave SQL thread, or when the slave thread is not running. (It reads the group_{relay|master}_log_{pos|name} and delay fields in the rli object. These may only be modified by the slave SQL thread or by a client thread when the slave SQL thread is not running.)
  • If there is an active transaction, then we do not update the position in the relay log. This is to ensure that we re-execute statements if we die in the middle of an transaction that was rolled back.
  • As a transaction never spans binary logs, we don't have to handle the case where we do a relay-log-rotation in the middle of the transaction. If transactions could span several binlogs, we would have to ensure that we do not delete the relay log file where the transaction started before switching to a new relay log file.
  • Error can happen if writing to file fails or if flushing the file fails.
Returns
0 on success, 1 on error.

◆ get_c_rli()

virtual Relay_log_info* Relay_log_info::get_c_rli ( )
inlinevirtual

Get coordinator's RLI.

Especially used get the rli from a slave thread, like this: thd->rli_slave->get_c_rli(); thd could be a SQL thread or a worker thread

Reimplemented in Slave_worker.

◆ get_commit_order_manager()

Commit_order_manager* Relay_log_info::get_commit_order_manager ( )
inline

◆ get_event_relay_log_name()

const char* Relay_log_info::get_event_relay_log_name ( )
inline

◆ get_event_relay_log_number()

uint Relay_log_info::get_event_relay_log_number ( )
inline

◆ get_event_relay_log_pos()

ulonglong Relay_log_info::get_event_relay_log_pos ( )
inline

◆ get_event_start_pos()

my_off_t Relay_log_info::get_event_start_pos ( )
inline

◆ get_flag()

bool Relay_log_info::get_flag ( enum_state_flag  flag)
inline

Get the value of a replication state flag.

Parameters
flagFlag to get value of
Returns
true if the flag was set, false otherwise.

◆ get_for_channel_str()

const char * Relay_log_info::get_for_channel_str ( bool  upper_case = false) const
virtual

Implements Slave_reporting_capability.

Reimplemented in Slave_worker.

◆ get_future_event_relay_log_pos()

ulonglong Relay_log_info::get_future_event_relay_log_pos ( )
inline

◆ get_group_master_log_name()

const char* Relay_log_info::get_group_master_log_name ( )
inline

◆ get_group_master_log_pos()

ulonglong Relay_log_info::get_group_master_log_pos ( )
inline

◆ get_group_relay_log_name()

const char* Relay_log_info::get_group_relay_log_name ( )
inline

◆ get_group_relay_log_pos()

ulonglong Relay_log_info::get_group_relay_log_pos ( )
inline

◆ get_gtid_monitoring_info()

Gtid_monitoring_info* Relay_log_info::get_gtid_monitoring_info ( )
inline
Returns
the pointer to the Gtid_monitoring_info.

◆ get_gtid_set()

const Gtid_set* Relay_log_info::get_gtid_set ( ) const
inline

◆ get_number_info_rli_fields()

size_t Relay_log_info::get_number_info_rli_fields ( )
static

◆ get_rli_description_event()

Format_description_log_event* Relay_log_info::get_rli_description_event ( ) const
inline

Return the current Format_description_log_event.

◆ get_row_stmt_start_timestamp()

time_t Relay_log_info::get_row_stmt_start_timestamp ( )
inline

◆ get_rpl_log_name()

const char* Relay_log_info::get_rpl_log_name ( )
inline

◆ get_sid_lock()

Checkable_rwlock* Relay_log_info::get_sid_lock ( )
inline

◆ get_sid_map()

Sid_map* Relay_log_info::get_sid_map ( )
inline

◆ get_sql_delay()

time_t Relay_log_info::get_sql_delay ( )
inline

◆ get_sql_delay_end()

time_t Relay_log_info::get_sql_delay_end ( )
inline

◆ get_table_data()

bool Relay_log_info::get_table_data ( TABLE table_arg,
table_def **  tabledef_var,
TABLE **  conv_table_var 
) const
inline

◆ get_thd_tx_priority()

int Relay_log_info::get_thd_tx_priority ( )
inline

◆ get_until_log_name()

const char * Relay_log_info::get_until_log_name ( )

◆ get_until_log_pos()

my_off_t Relay_log_info::get_until_log_pos ( )

◆ get_worker()

Slave_worker* Relay_log_info::get_worker ( size_t  n)
inline

◆ get_worker_count()

size_t Relay_log_info::get_worker_count ( )
inline

◆ inc_event_relay_log_pos()

void Relay_log_info::inc_event_relay_log_pos ( )
inline

◆ inc_group_relay_log_pos()

int Relay_log_info::inc_group_relay_log_pos ( ulonglong  log_pos,
bool  need_data_lock,
bool  force = false 
)

Last executed event group coordinates are updated and optionally forcibly flushed to a repository.

Parameters
log_posa value of the executed position to update to
need_data_lockwhether data_lock should be acquired
forcethe value is passed to eventual flush_info()

◆ init_until_option()

int Relay_log_info::init_until_option ( THD thd,
const LEX_MASTER_INFO master_param 
)

Intialize until option object when starting slave.

Parameters
[in]thdThe thread object of current session.
[in]master_paramthe parameters of START SLAVE.
Returns
int
Return values
0Succeeds to initialize until option object.
<>0 A defined error number is return if any error happens.

◆ init_workers()

void Relay_log_info::init_workers ( ulong  n_workers)

The method to invoke at slave threads start.

◆ is_group_relay_log_name_invalid()

bool Relay_log_info::is_group_relay_log_name_invalid ( const char **  errmsg)

Check if group_relay_log_name is in index file.

Parameters
[out]errmsgAn error message is returned if error happens.
Return values
falseIt is valid.
trueIt is invalid. In this case, *errmsg is set to point to the error message.

◆ is_in_group()

bool Relay_log_info::is_in_group ( ) const
inline

A group is defined as the entire range of events that constitute a transaction or auto-committed statement.

It has one of the following forms:

(Gtid)? Query(BEGIN) ... (Query(COMMIT) | Query(ROLLBACK) | Xid) (Gtid)? (Rand | User_var | Int_var)* Query(DDL)

Thus, to check if the execute thread is in a group, there are two cases:

  • If the master generates Gtid events (5.7.5 or later, or 5.6 or later with GTID_MODE=ON), then is_in_group is the same as info_thd->owned_gtid.sidno != 0, since owned_gtid.sidno is set to non-zero by the Gtid_log_event and cleared to zero at commit or rollback.
  • If the master does not generate Gtid events (i.e., master is pre-5.6, or pre-5.7.5 with GTID_MODE=OFF), then is_in_group is the same as is_in_trx_or_stmt().
Return values
trueReplication thread is inside a group.
falseReplication thread is not inside a group.

◆ is_in_stmt()

bool Relay_log_info::is_in_stmt ( ) const
inlineprivate

Auxiliary function used by is_in_group.

The execute thread is in the middle of a statement in the following cases:

  • User_var/Intvar/Rand events have been processed, but the corresponding Query_log_event has not been processed.
  • Table_map or Row events have been processed, and the last Row event did not have the STMT_END_F set.
Return values
trueReplication thread is inside a statement.
falseReplication thread is not inside a statement.

◆ is_in_trx_or_stmt()

bool Relay_log_info::is_in_trx_or_stmt ( ) const
inlineprivate

Auxiliary function used by is_in_group.

Return values
trueThe execute thread is inside a statement or a transaction, i.e., either a BEGIN has been executed or we are in the middle of a statement.
falseThe execute thread thread is not inside a statement or a transaction.

◆ is_long_find_row_note_printed()

bool Relay_log_info::is_long_find_row_note_printed ( )
inline

◆ is_mts_in_group()

bool Relay_log_info::is_mts_in_group ( )
inline

returns true if Coordinator is scheduling events belonging to the same group and has not reached yet its terminal event.

◆ is_mts_recovery()

bool Relay_log_info::is_mts_recovery ( ) const
inline

returns true if there is any gap-group of events to execute at slave starting phase.

◆ is_parallel_exec()

bool Relay_log_info::is_parallel_exec ( ) const
inline

returns true if events are to be executed in parallel

◆ is_processing_trx()

bool Relay_log_info::is_processing_trx ( )
inline
Returns
True if there is a transaction being currently processed

◆ is_relay_log_truncated()

bool Relay_log_info::is_relay_log_truncated ( )
inline

◆ is_time_for_mts_checkpoint()

bool Relay_log_info::is_time_for_mts_checkpoint ( )

Check if it is time to compute MTS checkpoint.

Return values
trueIt is time to compute MTS checkpoint.
falseIt is not MTS or it is not time for computing checkpoint.

◆ is_until_satisfied_after_dispatching_event()

bool Relay_log_info::is_until_satisfied_after_dispatching_event ( )
inline

◆ is_until_satisfied_at_start_slave()

bool Relay_log_info::is_until_satisfied_at_start_slave ( )
inline

◆ is_until_satisfied_before_dispatching_event()

bool Relay_log_info::is_until_satisfied_before_dispatching_event ( const Log_event ev)
inline

◆ mts_finalize_recovery()

bool Relay_log_info::mts_finalize_recovery ( )

Called when gaps execution is ended so it is crash-safe to reset the last session Workers info.

Reset recovery info from Worker info table and mark MTS recovery is completed.

Returns
false on success true when reset_notified_checkpoint failed.

◆ notify_group_master_log_name_update()

void Relay_log_info::notify_group_master_log_name_update ( )
inline

The same as notify_group_relay_log_name_update but for group_master_log_name.

◆ notify_relay_log_change()

void Relay_log_info::notify_relay_log_change ( )
inline

Invalidates cached until_log_name and event_relay_log_name comparison result.

Should be called after switch to next relay log if there chances that sql_thread is running.

◆ notify_relay_log_truncated()

void Relay_log_info::notify_relay_log_truncated ( )

Receiver thread notifies that it truncated some data from relay log.

data_lock will be acquired, so the caller should not hold data_lock.

◆ operator=()

Relay_log_info& Relay_log_info::operator= ( const Relay_log_info info)
private

◆ post_commit()

void Relay_log_info::post_commit ( bool  on_rollback)
virtual

Cleanup of any side effect that pre_commit() inflicts, including restore of the last executed group coordinates in case the current group has been destined to rollback, and signaling to possible waiters in the positive case.

Parameters
on_rollbackwhen true the method carries out rollback action

Reimplemented in Slave_worker.

◆ post_rollback()

void Relay_log_info::post_rollback ( )
inline

Execute actions at replicated atomic DLL post rollback time.

This include marking the current atomic DDL query-log-event as having processed. This measure is necessary to avoid slave info table update execution when pre_commit() hook is called as part of DDL's eventual implicit commit.

◆ pre_commit()

bool Relay_log_info::pre_commit ( )
inline

The method implements a pre-commit hook to add up a new statement typically to a DDL transaction to update the slave info table.

Note, in the non-transactional repository case the slave info is updated after successful commit of the main transaction.

Returns
false as success, otherwise true

◆ purge_relay_logs()

int Relay_log_info::purge_relay_logs ( THD thd,
const char **  errmsg,
bool  delete_only = false 
)

Purges relay logs.

It assumes to have a run lock on rli and that no slave thread are running.

Parameters
[in]thdconnection,
[out]errmsgstore pointer to an error message.
[in]delete_onlyIf true, do not start writing to a new log file.
Return values
0successfully executed,
1otherwise error, where errmsg is set to point to the error message.

Clear the retrieved gtid set for this channel.

◆ read_info()

bool Relay_log_info::read_info ( Rpl_info_handler from)
privatevirtual

Implements Rpl_info.

Reimplemented in Slave_worker.

◆ reattach_engine_ha_data()

void Relay_log_info::reattach_engine_ha_data ( THD thd)

Reattaches the engine ha_data to THD.

The fact is memorized in is_engine_ha_detached flag.

Parameters
thda reference to THD

◆ reinit_sql_thread_io_cache()

bool Relay_log_info::reinit_sql_thread_io_cache ( const char *  log,
bool  need_data_lock 
)

◆ relay_log_name_to_number()

uint Relay_log_info::relay_log_name_to_number ( const char *  name)

◆ relay_log_number_to_name()

void Relay_log_info::relay_log_number_to_name ( uint  number,
char  name[FN_REFLEN+1] 
)

Given the extension number of the relay log, gets the full relay log path.

Currently used in Slave_worker::retry_transaction()

Parameters
[in]numberextension number of relay log
[in,out]nameThe full path of the relay log (per-channel) to be read by the slave worker.

◆ reset_group_relay_log_pos()

bool Relay_log_info::reset_group_relay_log_pos ( const char **  errmsg)

Reset group_relay_log_name and group_relay_log_pos to the start of the first relay log file.

The caller must hold data_lock.

Parameters
[out]errmsgAn error message is set into it if error happens.
Return values
falseSuccess
trueError

◆ reset_notified_checkpoint()

void Relay_log_info::reset_notified_checkpoint ( ulong  shift,
time_t  new_ts,
bool  update_timestamp = false 
)

While a group is executed by a Worker the relay log can change.

This method is called in mts_checkpoint_routine() to mark that each worker is required to adapt to a new checkpoint data whose coordinates are passed to it through GAQ index.

Coordinator notifies Workers about this event. Coordinator and Workers maintain a bitmap of executed group that is reset with a new checkpoint.

Worker notices the new checkpoint value at the group commit to reset the current bitmap and starts using the clean bitmap indexed from zero of being reset rli_checkpoint_seqno.

New seconds_behind_master timestamp is installed.

Parameters
shiftnumber of bits to shift by Worker due to the current checkpoint change.
new_tsnew seconds_behind_master timestamp value unless zero. Zero could be due to FD event or fake rotate event.
update_timestampif true, this function will update the rli->last_master_timestamp.

◆ reset_notified_relay_log_change()

void Relay_log_info::reset_notified_relay_log_change ( )

While a group is executed by a Worker the relay log can change.

Method is called when MTS coordinator senses the relay-log name has been changed.

Coordinator notifies Workers about this event. Worker is supposed to commit to the recovery table with the new info.

It marks each Worker member with this fact to make an action at time it will distribute a terminal event of a group to the Worker.

Worker receives the new name at the group commiting phase Slave_worker::slave_worker_ends_group().

◆ reset_row_stmt_start_timestamp()

void Relay_log_info::reset_row_stmt_start_timestamp ( )
inline

◆ retried_processing()

void Relay_log_info::retried_processing ( uint  transient_errno_arg,
const char *  transient_err_message_arg,
ulong  trans_retries_arg 
)
inline

When a transaction is retried, the error number and message, and total number of retries are stored.

The timestamp for this error is also set here.

Parameters
transient_errno_argTransient error number.
transient_err_message_argTransient error message.
trans_retries_argNumber of times this transaction has been retried so far.

◆ rli_init_info()

int Relay_log_info::rli_init_info ( bool  skip_received_gtid_set_recovery = false)

Initialize the relay log info.

This function does a set of operations on the rli object like initializing variables, loading information from repository, setting up name for relay log files and index, MTS recovery (if necessary), calculating the received GTID set for the channel and storing the updated rli object configuration into the repository.

When this function is called in a change master process and the change master procedure will purge all the relay log files later, there is no reason to try to calculate the received GTID set of the channel based on existing relay log files (they will be purged). Allowing reads to existing relay log files at this point may lead to put the server in a state where it will be no possible to configure it if it was reset when encryption of replication log files was ON and the keyring plugin is not available anymore.

Parameters
skip_received_gtid_set_recoveryWhen true, skips the received GTID set recovery.
Return values
0Success.
1Error.

◆ set_commit_order_manager()

void Relay_log_info::set_commit_order_manager ( Commit_order_manager mngr)
inline

◆ set_event_relay_log_name()

void Relay_log_info::set_event_relay_log_name ( const char *  log_file_name)
inline

◆ set_event_relay_log_number()

void Relay_log_info::set_event_relay_log_number ( uint  number)
inline

◆ set_event_relay_log_pos()

void Relay_log_info::set_event_relay_log_pos ( ulonglong  log_pos)
inline

◆ set_event_start_pos()

void Relay_log_info::set_event_start_pos ( my_off_t  pos)
inline

◆ set_filter()

void Relay_log_info::set_filter ( Rpl_filter channel_filter)
inline

Set replication filter for the channel.

◆ set_flag()

void Relay_log_info::set_flag ( enum_state_flag  flag)
inline

Set the value of a replication state flag.

Parameters
flagFlag to set

◆ set_future_event_relay_log_pos()

void Relay_log_info::set_future_event_relay_log_pos ( ulonglong  log_pos)
inline

◆ set_group_master_log_name()

void Relay_log_info::set_group_master_log_name ( const char *  log_file_name)
inline

◆ set_group_master_log_pos()

void Relay_log_info::set_group_master_log_pos ( ulonglong  log_pos)
inline

◆ set_group_relay_log_name() [1/2]

void Relay_log_info::set_group_relay_log_name ( const char *  log_file_name)
inline

◆ set_group_relay_log_name() [2/2]

void Relay_log_info::set_group_relay_log_name ( const char *  log_file_name,
size_t  len 
)
inline

◆ set_group_relay_log_pos()

void Relay_log_info::set_group_relay_log_pos ( ulonglong  log_pos)
inline

◆ set_info_search_keys()

bool Relay_log_info::set_info_search_keys ( Rpl_info_handler to)
virtual

To search in the slave repositories, each slave info object (mi, rli or worker) should use a primary key.

This function sets the field values of the slave info objects with the search information, which is nothing but PK in mysql slave info tables. Ex: field_value[23]="channel_name" in the master info object.

Currently, used only for TABLE repository.

Implements Rpl_info.

Reimplemented in Slave_worker.

◆ set_long_find_row_note_printed()

void Relay_log_info::set_long_find_row_note_printed ( )
inline

◆ set_master_info()

void Relay_log_info::set_master_info ( Master_info info)

◆ set_rli_description_event()

int Relay_log_info::set_rli_description_event ( Format_description_log_event fe)
virtual

Delete the existing event and set a new one.

The method is run by SQL thread/MTS Coordinator.

This class is responsible for freeing the event, the caller should not do that.

Returns
1 if an error was encountered, 0 otherwise.

It replaces the current FD event with a new one. A version adaptation routine is invoked for the new FD to align the slave applier execution context with the master version.

Since FD are shared by Coordinator and Workers in the MTS mode, deletion of the old FD is done through decrementing its usage counter. The destructor runs when the later drops to zero, also see Slave_worker::set_rli_description_event(). The usage counter of the new FD is incremented.

Although notice that MTS worker runs it, inefficiently (see assert), once at its destruction time.

Parameters
fePointer to be installed into execution context FormatDescriptor event
Returns
1 if an error was encountered, 0 otherwise.

Reimplemented in Slave_worker.

◆ set_row_stmt_start_timestamp()

time_t Relay_log_info::set_row_stmt_start_timestamp ( )
inline

◆ set_sql_delay()

void Relay_log_info::set_sql_delay ( time_t  _sql_delay)
inline

◆ set_thd_tx_priority()

void Relay_log_info::set_thd_tx_priority ( int  priority)
inline

◆ set_until_option()

void Relay_log_info::set_until_option ( Until_option option)
inline

◆ slave_close_thread_tables()

void Relay_log_info::slave_close_thread_tables ( THD thd)

◆ start_sql_delay()

void Relay_log_info::start_sql_delay ( time_t  delay_end)

Indicate that a delay starts.

This does not actually sleep; it only sets the state of this Relay_log_info object to delaying so that the correct state can be reported by SHOW SLAVE STATUS and SHOW PROCESSLIST.

Requires rli->data_lock.

Parameters
delay_endThe time when the delay shall end.

◆ started_processing() [1/2]

void Relay_log_info::started_processing ( Gtid  gtid_arg,
ulonglong  original_ts_arg,
ulonglong  immediate_ts_arg,
bool  skipped = false 
)
inline

Stores the details of the transaction which has just started processing.

This function is called by the STS applier or MTS worker when applying a Gtid.

Parameters
gtid_argthe gtid of the trx
original_ts_argthe original commit timestamp of the transaction
immediate_ts_argthe immediate commit timestamp of the transaction
skippedtrue if the transaction was gtid skipped

◆ started_processing() [2/2]

void Relay_log_info::started_processing ( Gtid_log_event gtid_log_ev_arg)
inline

Stores the details of the transaction which has just started processing.

This function is called by the MTS coordinator when queuing a Gtid to a worker.

Parameters
gtid_log_ev_argthe gtid log event of the trx

◆ stmt_done()

int Relay_log_info::stmt_done ( my_off_t  event_log_pos)

Helper function to do after statement completion.

This function is called from an event to complete the group by either stepping the group position, if the "statement" is not inside a transaction; or increase the event position, if the "statement" is inside a transaction.

Parameters
event_log_posMaster log position of the event. The position is recorded in the relay log info and used to produce information for SHOW SLAVE STATUS.

◆ unflag_detached_engine_ha_data()

bool Relay_log_info::unflag_detached_engine_ha_data ( )
inline

Drops the engine ha_data flag when it is up.

The method is run at execution points of the engine ha_data re-attachment.

Returns
true when THD has detached the engine ha_data, false otherwise

◆ unset_long_find_row_note_printed()

void Relay_log_info::unset_long_find_row_note_printed ( )
inline

◆ wait_for_gtid_set() [1/3]

int Relay_log_info::wait_for_gtid_set ( THD thd,
const char *  gtid,
double  timeout,
bool  update_THD_status = true 
)

Wait for a GTID set to be executed.

Parameters
thdThe thread for status changes and kill status
gtidA char array with a GTID set
timeoutNumber of seconds to wait before timing out
update_THD_statusShall the method update the THD stage
Return values
0The set is already executed
-1There was a timeout waiting for the set
-2There was an issue while waiting.

◆ wait_for_gtid_set() [2/3]

int Relay_log_info::wait_for_gtid_set ( THD thd,
String gtid,
double  timeout,
bool  update_THD_status = true 
)

Wait for a GTID set to be executed.

Parameters
thdThe thread for status changes and kill status
gtidA String with a GTID set
timeoutNumber of seconds to wait before timing out
update_THD_statusShall the method update the THD stage
Return values
0The set is already executed
-1There was a timeout waiting for the set
-2There was an issue while waiting.

◆ wait_for_gtid_set() [3/3]

int Relay_log_info::wait_for_gtid_set ( THD thd,
const Gtid_set wait_gtid_set,
double  timeout,
bool  update_THD_status = true 
)

Wait for a GTID set to be executed.

Parameters
thdThe thread for status changes and kill status
wait_gtid_setA GTID_set object
timeoutNumber of seconds to wait before timing out
update_THD_statusShall the method update the THD stage
Return values
0The set is already executed
-1There was a timeout waiting for the set
-2There was an issue while waiting.

◆ wait_for_pos()

int Relay_log_info::wait_for_pos ( THD thd,
String log_name,
longlong  log_pos,
double  timeout 
)

Waits until the SQL thread reaches (has executed up to) the log/position or timed out.

SYNOPSIS

Parameters
[in]thdclient thread that sent SELECT MASTER_POS_WAIT,
[in]log_namelog name to wait for,
[in]log_posposition to wait for,
[in]timeouttimeout in seconds before giving up waiting. timeout is double whereas it should be ulong; but this is to catch if the user submitted a negative timeout.
Return values
-2improper arguments (log_pos<0) or slave not running, or master info changed during the function's execution, or client thread killed. -2 is translated to NULL by caller,
-1timed out
>=0number of log events the function had to wait before reaching the desired log/position

◆ write_info()

bool Relay_log_info::write_info ( Rpl_info_handler to)
privatevirtual

Implements Rpl_info.

Reimplemented in Slave_worker.

Friends And Related Function Documentation

◆ Rpl_info_factory

friend class Rpl_info_factory
friend

Member Data Documentation

◆ abort_pos_wait

volatile ulong Relay_log_info::abort_pos_wait

◆ atomic_channel_open_temp_tables

std::atomic<int32> Relay_log_info::atomic_channel_open_temp_tables {0}

◆ cached_charset

char Relay_log_info::cached_charset[6]

◆ channel_mts_submode

enum_mts_parallel_type Relay_log_info::channel_mts_submode

◆ checkpoint_group

uint Relay_log_info::checkpoint_group

◆ commit_order_mngr

Commit_order_manager* Relay_log_info::commit_order_mngr
private

◆ commit_timestamps_status

enum { ... } Relay_log_info::commit_timestamps_status

the status of the commit timestamps for the relay log

◆ curr_group_assigned_parts

Prealloced_array<db_worker_hash_entry *, 4> Relay_log_info::curr_group_assigned_parts

◆ curr_group_da

Prealloced_array<Slave_job_item, 8> Relay_log_info::curr_group_da

◆ curr_group_isolated

bool Relay_log_info::curr_group_isolated

◆ curr_group_seen_begin

bool Relay_log_info::curr_group_seen_begin

◆ curr_group_seen_gtid

bool Relay_log_info::curr_group_seen_gtid

◆ current_event

Log_event* Relay_log_info::current_event

Reference to being applied event.

The member is set at event reading and gets reset at the end of the event lifetime. See more in RLI_current_event_raii that provides the main interface to the member.

◆ current_mts_submode

Mts_submode* Relay_log_info::current_mts_submode

◆ ddl_not_atomic

bool Relay_log_info::ddl_not_atomic

Raised when slave applies and writes to its binary log statement which is not atomic DDL and has no XID assigned.

Checked at commit time to decide whether it is safe to update slave info table within the same transaction as the write to binary log or this should be deffered. The deffered scenario applies for not XIDed events in which case such update might be lost on recovery.

◆ deferred_events

Deferred_log_events* Relay_log_info::deferred_events

◆ deferred_events_collecting

bool Relay_log_info::deferred_events_collecting

◆ error_on_rli_init_info

bool Relay_log_info::error_on_rli_init_info

◆ event_relay_log_name

char Relay_log_info::event_relay_log_name[FN_REFLEN]
protected

◆ event_relay_log_number

uint Relay_log_info::event_relay_log_number
protected

◆ event_relay_log_pos

ulonglong Relay_log_info::event_relay_log_pos
protected

◆ event_start_pos

my_off_t Relay_log_info::event_start_pos
protected

◆ exit_count_lock

mysql_mutex_t Relay_log_info::exit_count_lock

◆ exit_counter

ulong Relay_log_info::exit_counter

◆ force_flush_postponed_due_to_split_trans

bool Relay_log_info::force_flush_postponed_due_to_split_trans

◆ future_event_relay_log_pos

ulonglong Relay_log_info::future_event_relay_log_pos
protected

◆ gaq

Slave_committed_queue* Relay_log_info::gaq

◆ group_master_log_name

char Relay_log_info::group_master_log_name[FN_REFLEN]
protected

◆ group_master_log_pos

volatile my_off_t Relay_log_info::group_master_log_pos
protected

◆ group_relay_log_name

char Relay_log_info::group_relay_log_name[FN_REFLEN]
protected

Event group means a group of events of a transaction.

group_relay_log_name and group_relay_log_pos record the place before where all event groups are applied. When slave starts, it resume to apply events from group_relay_log_pos. They will be initialized to the begin of the first relay log file if it is a new slave(including SLAVE RESET). Then, group_relay_log_pos is advanced after each transaction is applied successfully in single thread slave. For MTS, group_relay_log_pos is updated by mts checkpoint mechanism. group_relay_log_pos and group_relay_log_name are stored into relay_log_info file/table periodically. When server startup, they are loaded from relay log info file/table.

◆ group_relay_log_pos

ulonglong Relay_log_info::group_relay_log_pos
protected

◆ gtid_monitoring_info

Gtid_monitoring_info* Relay_log_info::gtid_monitoring_info
private

Stores information on the last processed transaction or the transaction that is currently being processed.

STS:

  • timestamps of the currently applying/last applied transaction

MTS:

  • coordinator thread: timestamps of the currently scheduling/last scheduled transaction in a worker's queue
  • worker thread: timestamps of the currently applying/last applied transaction

◆ gtid_retrieved_initialized

bool Relay_log_info::gtid_retrieved_initialized
private

◆ gtid_set

Gtid_set* Relay_log_info::gtid_set
private

◆ gtid_timestamps_warning_logged

bool Relay_log_info::gtid_timestamps_warning_logged

Variable is set to true as long as original_commit_timestamp > immediate_commit_timestamp so that the corresponding warning is only logged once.

◆ ign_master_log_name_end

char Relay_log_info::ign_master_log_name_end[FN_REFLEN]

◆ ign_master_log_pos_end

ulonglong Relay_log_info::ign_master_log_pos_end

◆ ignore_log_space_limit

bool Relay_log_info::ignore_log_space_limit

◆ inited_hash_workers

bool Relay_log_info::inited_hash_workers

◆ is_engine_ha_data_detached

bool Relay_log_info::is_engine_ha_data_detached

◆ is_group_master_log_pos_invalid

bool Relay_log_info::is_group_master_log_pos_invalid

◆ is_relay_log_recovery

bool Relay_log_info::is_relay_log_recovery

◆ last_assigned_worker

Slave_worker* Relay_log_info::last_assigned_worker

◆ last_clock

struct timespec Relay_log_info::last_clock

Identifies the last time a checkpoint routine has been executed.

◆ last_event_start_time

time_t Relay_log_info::last_event_start_time

◆ last_master_timestamp

time_t Relay_log_info::last_master_timestamp

◆ least_occupied_workers

Prealloced_array<ulong, 16> Relay_log_info::least_occupied_workers

◆ LINES_IN_RELAY_LOG_INFO_WITH_CHANNEL

const int Relay_log_info::LINES_IN_RELAY_LOG_INFO_WITH_CHANNEL = 8
staticprivate

◆ LINES_IN_RELAY_LOG_INFO_WITH_DELAY

const int Relay_log_info::LINES_IN_RELAY_LOG_INFO_WITH_DELAY = 5
staticprivate

◆ LINES_IN_RELAY_LOG_INFO_WITH_ID

const int Relay_log_info::LINES_IN_RELAY_LOG_INFO_WITH_ID = 7
staticprivate

◆ LINES_IN_RELAY_LOG_INFO_WITH_WORKERS

const int Relay_log_info::LINES_IN_RELAY_LOG_INFO_WITH_WORKERS = 6
staticprivate

◆ log_space_cond

mysql_cond_t Relay_log_info::log_space_cond

◆ log_space_limit

ulonglong Relay_log_info::log_space_limit

◆ log_space_lock

mysql_mutex_t Relay_log_info::log_space_lock

◆ log_space_total

ulonglong Relay_log_info::log_space_total

◆ logical_clock_cond

mysql_cond_t Relay_log_info::logical_clock_cond

◆ long_find_row_note_printed

bool Relay_log_info::long_find_row_note_printed
private

◆ m_flags

uint32 Relay_log_info::m_flags
private

◆ m_key_mts_temp_table_LOCK

PSI_mutex_key Relay_log_info::m_key_mts_temp_table_LOCK

◆ m_relay_log_truncated

bool Relay_log_info::m_relay_log_truncated = false
private

It will be set to true when receiver truncated relay log for some reason.

The truncated data may already be read by applier. So applier need to check it each time the binlog_end_pos is updated.

◆ m_table_map

table_mapping Relay_log_info::m_table_map

◆ mapping_db_to_worker

◆ max_updated_index

ulonglong Relay_log_info::max_updated_index

◆ mi

Master_info* Relay_log_info::mi

◆ mts_coordinator_basic_nap

ulong Relay_log_info::mts_coordinator_basic_nap

◆ mts_end_group_sets_max_dbs

bool Relay_log_info::mts_end_group_sets_max_dbs

◆ mts_events_assigned

ulonglong Relay_log_info::mts_events_assigned

◆ mts_gaq_LOCK

mysql_mutex_t Relay_log_info::mts_gaq_LOCK

◆ mts_group_status

enum { ... } Relay_log_info::mts_group_status

◆ mts_groups_assigned

ulonglong Relay_log_info::mts_groups_assigned

◆ mts_last_online_stat

time_t Relay_log_info::mts_last_online_stat

◆ mts_pending_jobs_size

ulonglong Relay_log_info::mts_pending_jobs_size

◆ mts_pending_jobs_size_max

ulonglong Relay_log_info::mts_pending_jobs_size_max

◆ mts_recovery_group_cnt

ulong Relay_log_info::mts_recovery_group_cnt

◆ mts_recovery_group_seen_begin

bool Relay_log_info::mts_recovery_group_seen_begin

◆ mts_recovery_index

ulong Relay_log_info::mts_recovery_index

◆ mts_slave_worker_queue_len_max

ulong Relay_log_info::mts_slave_worker_queue_len_max

◆ mts_temp_table_LOCK

mysql_mutex_t Relay_log_info::mts_temp_table_LOCK

◆ mts_total_wait_overlap

std::atomic<longlong> Relay_log_info::mts_total_wait_overlap

◆ mts_total_wait_worker_avail

ulonglong Relay_log_info::mts_total_wait_worker_avail

◆ mts_worker_underrun_level

long Relay_log_info::mts_worker_underrun_level

◆ mts_wq_excess_cnt

volatile long Relay_log_info::mts_wq_excess_cnt

◆ mts_wq_no_underrun_cnt

ulong Relay_log_info::mts_wq_no_underrun_cnt

◆ mts_wq_overfill_cnt

ulong Relay_log_info::mts_wq_overfill_cnt

◆ mts_wq_overrun_cnt

volatile ulong Relay_log_info::mts_wq_overrun_cnt

◆ mts_wq_oversize

bool Relay_log_info::mts_wq_oversize

◆ mts_wq_underrun_w_id

volatile ulong Relay_log_info::mts_wq_underrun_w_id

◆ new_group_master_log_name

char Relay_log_info::new_group_master_log_name[FN_REFLEN]

Storage for holding newly computed values for the last executed event group coordinates while the current group of events is being committed, see pre_commit, post_commit.

◆ new_group_master_log_pos

my_off_t Relay_log_info::new_group_master_log_pos

◆ new_group_relay_log_name

char Relay_log_info::new_group_relay_log_name[FN_REFLEN]

◆ new_group_relay_log_pos

my_off_t Relay_log_info::new_group_relay_log_pos

◆ opt_slave_parallel_workers

ulong Relay_log_info::opt_slave_parallel_workers

◆ original_commit_timestamp

uint64 Relay_log_info::original_commit_timestamp

◆ pending_jobs

volatile ulong Relay_log_info::pending_jobs

◆ pending_jobs_cond

mysql_cond_t Relay_log_info::pending_jobs_cond

◆ pending_jobs_lock

mysql_mutex_t Relay_log_info::pending_jobs_lock

◆ recovery_groups

MY_BITMAP Relay_log_info::recovery_groups

◆ recovery_groups_inited

bool Relay_log_info::recovery_groups_inited

◆ recovery_parallel_workers

ulong Relay_log_info::recovery_parallel_workers

◆ relay_log

MYSQL_BIN_LOG Relay_log_info::relay_log

◆ replicate_same_server_id

bool Relay_log_info::replicate_same_server_id

◆ reported_unsafe_warning

bool Relay_log_info::reported_unsafe_warning

◆ retried_trans

ulong Relay_log_info::retried_trans

◆ rli_checkpoint_seqno

uint Relay_log_info::rli_checkpoint_seqno

◆ rli_description_event

Format_description_log_event* Relay_log_info::rli_description_event
protected

◆ rli_fake

bool Relay_log_info::rli_fake
private

◆ row_stmt_start_timestamp

time_t Relay_log_info::row_stmt_start_timestamp
private

◆ rows_query_ev

Rows_query_log_event* Relay_log_info::rows_query_ev

◆ rpl_filter

Rpl_filter* Relay_log_info::rpl_filter

◆ save_temporary_tables

TABLE* Relay_log_info::save_temporary_tables

◆ slave_parallel_workers

ulong Relay_log_info::slave_parallel_workers

◆ slave_patternload_file

char Relay_log_info::slave_patternload_file[FN_REFLEN]

◆ slave_patternload_file_size

size_t Relay_log_info::slave_patternload_file_size

◆ slave_skip_counter

volatile uint32 Relay_log_info::slave_skip_counter

◆ slave_version_split

uchar Relay_log_info::slave_version_split[3]

◆ slave_worker_hash_cond

mysql_cond_t Relay_log_info::slave_worker_hash_cond

◆ slave_worker_hash_lock

mysql_mutex_t Relay_log_info::slave_worker_hash_lock

◆ sql_delay

time_t Relay_log_info::sql_delay
private

Delay slave SQL thread by this amount of seconds.

The delay is applied per transaction and based on the immediate master's commit time. Exceptionally, if a server in the replication chain does not support the commit timestamps in Gtid_log_event, the delay is applied per event and is based on the event timestamp. This is set with CHANGE MASTER TO MASTER_DELAY=X.

Guarded by data_lock. Initialized by the client thread executing START SLAVE. Written by client threads executing CHANGE MASTER TO MASTER_DELAY=X. Read by SQL thread and by client threads executing SHOW SLAVE STATUS. Note: must not be written while the slave SQL thread is running, since the SQL thread reads it without a lock when executing flush_info().

◆ sql_delay_end

time_t Relay_log_info::sql_delay_end
private

During a delay, specifies the point in time when the delay ends.

This is used for the SQL_Remaining_Delay column in SHOW SLAVE STATUS.

Guarded by data_lock. Written by the sql thread. Read by client threads executing SHOW SLAVE STATUS.

◆ sql_force_rotate_relay

bool Relay_log_info::sql_force_rotate_relay

◆ sql_thread_kill_accepted

bool Relay_log_info::sql_thread_kill_accepted

◆ stats_begin

struct timespec Relay_log_info::stats_begin

◆ stats_exec_time

ulonglong Relay_log_info::stats_exec_time

◆ stats_read_time

ulonglong Relay_log_info::stats_read_time

◆ tables_to_lock

RPL_TABLE_LIST* Relay_log_info::tables_to_lock

◆ tables_to_lock_count

uint Relay_log_info::tables_to_lock_count

◆ thd_tx_priority

int Relay_log_info::thd_tx_priority
private

◆ trans_retries

ulong Relay_log_info::trans_retries

◆ ts_exec

struct timespec Relay_log_info::ts_exec[2]

◆ until_condition

enum { ... } Relay_log_info::until_condition

◆ until_option

Until_option* Relay_log_info::until_option
private

◆ workers

Slave_worker_array Relay_log_info::workers

◆ workers_array_initialized

bool Relay_log_info::workers_array_initialized

◆ workers_copy_pfs

std::vector<Slave_worker *> Relay_log_info::workers_copy_pfs

◆ wq_size_waits_cnt

ulong Relay_log_info::wq_size_waits_cnt

The documentation for this class was generated from the following files: