MySQL  8.0.18
Source Code Documentation
Slave_worker Class Reference

#include <rpl_rli_pdb.h>

Inheritance diagram for Slave_worker:
Relay_log_info Rpl_info Slave_reporting_capability

Public Types

enum  en_running_state {
  NOT_RUNNING = 0, RUNNING = 1, ERROR_LEAVING = 2, STOP = 3,
  STOP_ACCEPTED
}
 
- Public Types inherited from Relay_log_info
enum  enum_priv_checks_status : int {
  enum_priv_checks_status::SUCCESS = 0, enum_priv_checks_status::USER_ANONYMOUS, enum_priv_checks_status::USERNAME_TOO_LONG, enum_priv_checks_status::HOSTNAME_TOO_LONG,
  enum_priv_checks_status::HOSTNAME_SYNTAX_ERROR, enum_priv_checks_status::USERNAME_NULL_HOSTNAME_NOT_NULL, enum_priv_checks_status::USER_DOES_NOT_EXIST, enum_priv_checks_status::USER_DOES_NOT_HAVE_PRIVILEGES,
  enum_priv_checks_status::USER_DATA_CORRUPTED, enum_priv_checks_status::LOAD_DATA_EVENT_NOT_ALLOWED
}
 Set of possible return values for the member methods related to PRIVILEGE_CHECKS_USER management. More...
 
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

 Slave_worker (Relay_log_info *rli, 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)
 
virtual ~Slave_worker ()
 
void copy_values_for_PFS (ulong worker_id, en_running_state running_status, THD *worker_thd, const Error &last_error, Gtid_monitoring_info *monitoring_info_arg)
 
int init_worker (Relay_log_info *, ulong)
 Method is executed by Coordinator at Worker startup time to initialize members parly with values supplied by Coordinator through rli. More...
 
int rli_init_info (bool)
 A part of Slave worker iitializer that provides a minimum context for MTS recovery. More...
 
int flush_info (bool force=false)
 
void slave_worker_ends_group (Log_event *, int)
 Deallocation routine to cancel out few effects of map_db_to_worker(). More...
 
const char * get_master_log_name ()
 
ulonglong get_master_log_pos ()
 
ulonglong set_master_log_pos (ulong val)
 
bool commit_positions (Log_event *evt, Slave_job_group *ptr_g, bool force)
 
bool commit_positions ()
 The method is a wrapper to provide uniform interface with STS and is to be called from Relay_log_info and Slave_worker pre_commit() methods. More...
 
void post_commit (bool on_rollback)
 See the comments for STS version of this method. More...
 
void rollback_positions (Slave_job_group *ptr_g)
 
bool reset_recovery_info ()
 Clean up a part of Worker info table that is regarded in in gaps collecting at recovery. More...
 
int set_rli_description_event (Format_description_log_event *fdle)
 The method runs at Worker initalization, at runtime when Coordinator supplied a new FD event for execution context, and at the Worker pool shutdown. More...
 
void reset_gaq_index ()
 
void set_gaq_index (ulong val)
 
int slave_worker_exec_event (Log_event *ev)
 MTS worker main routine. More...
 
bool retry_transaction (uint start_relay_number, my_off_t start_relay_pos, uint end_relay_number, my_off_t end_relay_pos)
 It is called after an error happens. More...
 
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...
 
const char * get_for_channel_str (bool upper_case=false) const
 return an extension "for channel channel_name" for error messages per channel More...
 
longlong sequence_number ()
 
bool found_order_commit_deadlock ()
 
void report_order_commit_deadlock ()
 
ulong get_master_server_version ()
 
- Public Member Functions inherited from Relay_log_info
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...
 
std::string get_privilege_checks_username () const
 Retrieves the username part of the PRIVILEGE_CHECKS_USER option of CHANGE MASTER TO statement. More...
 
std::string get_privilege_checks_hostname () const
 Retrieves the host part of the PRIVILEGE_CHECKS_USER option of CHANGE MASTER TO statement. More...
 
bool is_privilege_checks_user_null () const
 Returns whether or not there is no user configured for PRIVILEGE_CHECKS_USER. More...
 
bool is_privilege_checks_user_corrupted () const
 Returns whether or not the internal data regarding PRIVILEGE_CHECKS_USER is corrupted. More...
 
void clear_privilege_checks_user ()
 Clears the info related to the data initialized from PRIVILEGE_CHECKS_USER. More...
 
void set_privilege_checks_user_corrupted (bool is_corrupted)
 Sets the flag that tells whether or not the data regarding the PRIVILEGE_CHECKS_USER is corrupted. More...
 
enum_priv_checks_status set_privilege_checks_user (char const *param_privilege_checks_username, char const *param_privilege_checks_hostname)
 Initializes data related to PRIVILEGE_CHECKS_USER, specifically the user name and the user hostname. More...
 
enum_priv_checks_status check_privilege_checks_user ()
 Checks the validity and integrity of the data related to PRIVILEGE_CHECKS_USER, specifically the user name and the user hostname. More...
 
enum_priv_checks_status check_privilege_checks_user (char const *param_privilege_checks_username, char const *param_privilege_checks_hostname)
 Checks the validity and integrity of the data related to PRIVILEGE_CHECKS_USER, specifically the user name and the user hostname. More...
 
enum_priv_checks_status check_applier_acl_user (char const *param_privilege_checks_username, char const *param_privilege_checks_hostname)
 Checks the existence of user provided as part of the PRIVILEGE_CHECKS_USER option. More...
 
std::pair< const char *, const char * > print_applier_security_context_user_host () const
 Returns a printable representation of the username and hostname currently being used in the applier security context or empty strings other wise. More...
 
void report_privilege_check_error (enum loglevel level, enum_priv_checks_status status_code, bool to_client, char const *channel_name=nullptr, char const *user_name=nullptr, char const *host_name=nullptr) const
 Outputs the error message associated with applier thread user privilege checks error error_code. More...
 
enum_priv_checks_status initialize_security_context (THD *thd)
 Initializes the security context associated with the PRIVILEGE_CHECKS_USER user that is to be used by the provided THD object. More...
 
enum_priv_checks_status initialize_applier_security_context ()
 Initializes the security context associated with the PRIVILEGE_CHECKS_USER user that is to be used by the applier thread. 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)
 
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 ()
 
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 ()
 
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...
 
- 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 () const
 
int remove_info ()
 
int clean_info ()
 
bool is_transactional () const
 
bool update_is_transactional ()
 
char * get_description_info () const
 
bool copy_info (Rpl_info_handler *from, Rpl_info_handler *to)
 
uint get_internal_id () const
 
char * get_channel () const
 
- 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=nullptr) 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_worker_fields ()
 
static void set_nullable_fields (MY_BITMAP *nullable_fields)
 Sets bits for columns that are allowed to be NULL. More...
 
static const uintget_table_pk_field_indexes ()
 Returns an array with the expected column numbers of the primary key fields of the table repository. More...
 
static uint get_channel_field_index ()
 Returns the index of the Channel_name field of the table repository. More...
 
- Static Public Member Functions inherited from Relay_log_info
static size_t get_number_info_rli_fields ()
 
static void set_nullable_fields (MY_BITMAP *nullable_fields)
 Sets bits for columns that are allowed to be NULL. More...
 

Public Attributes

Slave_jobs_queue jobs
 
mysql_mutex_t jobs_lock
 
mysql_cond_t jobs_cond
 
Relay_log_infoc_rli
 
Prealloced_array< db_worker_hash_entry *, SLAVE_INIT_DBS_IN_GROUPcurr_group_exec_parts
 
bool curr_group_seen_sequence_number
 
ulong id
 
volatile ulong last_group_done_index
 
ulonglong last_groups_assigned_index
 
ulong wq_empty_waits
 
ulong events_done
 
ulong groups_done
 
volatile int curr_jobs
 
long usage_partition
 
bool end_group_sets_max_dbs
 
volatile bool relay_log_change_notified
 
volatile bool checkpoint_notified
 
volatile bool master_log_change_notified
 
bool fd_change_notified
 
ulong bitmap_shifted
 
long wq_overrun_cnt
 
ulong overrun_level
 
ulong underrun_level
 
ulong excess_cnt
 
char checkpoint_relay_log_name [FN_REFLEN]
 
ulonglong checkpoint_relay_log_pos
 
char checkpoint_master_log_name [FN_REFLEN]
 
ulonglong checkpoint_master_log_pos
 
MY_BITMAP group_executed
 
MY_BITMAP group_shifted
 
ulong worker_checkpoint_seqno
 
ulong server_version
 
en_running_state volatile running_status
 
bool exit_incremented
 
- Public Attributes inherited from Relay_log_info
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< int32atomic_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 Member Functions

virtual void do_report (loglevel level, int err_code, const char *msg, va_list v_args) const
 
- 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)
 

Private Member Functions

void end_info ()
 
bool read_info (Rpl_info_handler *from)
 
bool write_info (Rpl_info_handler *to)
 
Slave_workeroperator= (const Slave_worker &info)
 
 Slave_worker (const Slave_worker &info)
 
bool worker_sleep (ulong seconds)
 Sleep for a given amount of seconds or until killed. More...
 
bool read_and_apply_events (uint start_relay_number, my_off_t start_relay_pos, uint end_relay_number, my_off_t end_relay_pos)
 Read events from relay logs and apply them. More...
 
void assign_partition_db (Log_event *ev)
 
void reset_order_commit_deadlock ()
 

Private Attributes

ulong gaq_index
 
ulonglong master_log_pos
 
bool m_order_commit_deadlock
 

Additional Inherited Members

- Protected Attributes inherited from Relay_log_info
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] = {0}
 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...
 

Member Enumeration Documentation

◆ en_running_state

Enumerator
NOT_RUNNING 
RUNNING 
ERROR_LEAVING 
STOP 
STOP_ACCEPTED 

Constructor & Destructor Documentation

◆ Slave_worker() [1/2]

Slave_worker::Slave_worker ( Relay_log_info rli,
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 
)

◆ ~Slave_worker()

Slave_worker::~Slave_worker ( )
virtual

◆ Slave_worker() [2/2]

Slave_worker::Slave_worker ( const Slave_worker info)
private

Member Function Documentation

◆ assign_partition_db()

void Slave_worker::assign_partition_db ( Log_event ev)
private

◆ commit_positions() [1/2]

bool Slave_worker::commit_positions ( Log_event evt,
Slave_job_group ptr_g,
bool  force 
)

◆ commit_positions() [2/2]

bool Slave_worker::commit_positions ( )
inlinevirtual

The method is a wrapper to provide uniform interface with STS and is to be called from Relay_log_info and Slave_worker pre_commit() methods.

Reimplemented from Relay_log_info.

◆ copy_values_for_PFS()

void Slave_worker::copy_values_for_PFS ( ulong  worker_id,
en_running_state  running_status,
THD worker_thd,
const Error last_error,
Gtid_monitoring_info monitoring_info_arg 
)

◆ do_report()

void Slave_worker::do_report ( loglevel  level,
int  err_code,
const char *  msg,
va_list  v_args 
) const
protectedvirtual

Reimplemented from Slave_reporting_capability.

◆ end_info()

void Slave_worker::end_info ( )
private

◆ flush_info()

int Slave_worker::flush_info ( bool  force = false)

◆ found_order_commit_deadlock()

bool Slave_worker::found_order_commit_deadlock ( )
inline

◆ get_c_rli()

virtual Relay_log_info* Slave_worker::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 from Relay_log_info.

◆ get_channel_field_index()

uint Slave_worker::get_channel_field_index ( )
static

Returns the index of the Channel_name field of the table repository.

◆ get_for_channel_str()

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

return an extension "for channel channel_name" for error messages per channel

Reimplemented from Relay_log_info.

◆ get_master_log_name()

const char * Slave_worker::get_master_log_name ( )

◆ get_master_log_pos()

ulonglong Slave_worker::get_master_log_pos ( )
inline

◆ get_master_server_version()

ulong Slave_worker::get_master_server_version ( )
inline
Returns
either the master server version as extracted from the last installed Format_description_log_event, or when it was not installed then the slave own server version.

◆ get_number_worker_fields()

size_t Slave_worker::get_number_worker_fields ( )
static

◆ get_table_pk_field_indexes()

const uint * Slave_worker::get_table_pk_field_indexes ( )
static

Returns an array with the expected column numbers of the primary key fields of the table repository.

◆ init_worker()

int Slave_worker::init_worker ( Relay_log_info rli,
ulong  i 
)

Method is executed by Coordinator at Worker startup time to initialize members parly with values supplied by Coordinator through rli.

Parameters
rliCoordinator's Relay_log_info pointer
iidentifier of the Worker
Returns
0 success non-zero failure

◆ operator=()

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

◆ post_commit()

void Slave_worker::post_commit ( bool  on_rollback)
inlinevirtual

See the comments for STS version of this method.

Reimplemented from Relay_log_info.

◆ read_and_apply_events()

bool Slave_worker::read_and_apply_events ( uint  start_relay_number,
my_off_t  start_relay_pos,
uint  end_relay_number,
my_off_t  end_relay_pos 
)
private

Read events from relay logs and apply them.

Parameters
[in]start_relay_numberThe extension number of the relay log which includes the first event of the transaction.
[in]start_relay_posThe offset of the transaction's first event.
[in]end_relay_numberThe extension number of the relay log which includes the last event it should retry.
[in]end_relay_posThe offset of the last event it should retry.
Returns
false if succeeds, otherwise returns true.

◆ read_info()

bool Slave_worker::read_info ( Rpl_info_handler from)
privatevirtual

Reimplemented from Relay_log_info.

◆ report_order_commit_deadlock()

void Slave_worker::report_order_commit_deadlock ( )
inline

◆ reset_gaq_index()

void Slave_worker::reset_gaq_index ( )
inline

◆ reset_order_commit_deadlock()

void Slave_worker::reset_order_commit_deadlock ( )
inlineprivate

◆ reset_recovery_info()

bool Slave_worker::reset_recovery_info ( )

Clean up a part of Worker info table that is regarded in in gaps collecting at recovery.

This worker won't contribute to recovery bitmap at future slave restart (see mts_recovery_groups).

Returns
false as success true as failure

◆ retry_transaction()

bool Slave_worker::retry_transaction ( uint  start_relay_number,
my_off_t  start_relay_pos,
uint  end_relay_number,
my_off_t  end_relay_pos 
)

It is called after an error happens.

It checks if that is an temporary error and if the situation is allow to retry the transaction. Then it will retry the transaction if it is allowed. Retry policy and logic is similar to single-threaded slave.

Parameters
[in]start_relay_numberThe extension number of the relay log which includes the first event of the transaction.
[in]start_relay_posThe offset of the transaction's first event.
[in]end_relay_numberThe extension number of the relay log which includes the last event it should retry.
[in]end_relay_posThe offset of the last event it should retry.
Returns
false if succeeds, otherwise returns true.

◆ rli_init_info()

int Slave_worker::rli_init_info ( bool  is_gaps_collecting_phase)

A part of Slave worker iitializer that provides a minimum context for MTS recovery.

Parameters
is_gaps_collecting_phase
   clarifies what state the caller
   executes this method from. When it's @c true
   that is @c mts_recovery_groups() and Worker should
   restore the last session time info which is processed
   to collect gaps that is not executed transactions (groups).
   Such recovery Slave_worker intance is destroyed at the end of
   @c mts_recovery_groups().
   Whet it's @c false Slave_worker is initialized for the run time
   nad should not read the last session time stale info.
   Its info will be ultimately reset once all gaps are executed
   to finish off recovery.
Returns
0 on success, non-zero for a failure

◆ rollback_positions()

void Slave_worker::rollback_positions ( Slave_job_group ptr_g)

◆ sequence_number()

longlong Slave_worker::sequence_number ( )
inline

◆ set_gaq_index()

void Slave_worker::set_gaq_index ( ulong  val)
inline

◆ set_info_search_keys()

bool Slave_worker::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.

Reimplemented from Relay_log_info.

◆ set_master_log_pos()

ulonglong Slave_worker::set_master_log_pos ( ulong  val)
inline

◆ set_nullable_fields()

void Slave_worker::set_nullable_fields ( MY_BITMAP nullable_fields)
static

Sets bits for columns that are allowed to be NULL.

Parameters
nullable_fieldsthe bitmap to hold the nullable fields.

◆ set_rli_description_event()

int Slave_worker::set_rli_description_event ( Format_description_log_event fdle)
inlinevirtual

The method runs at Worker initalization, at runtime when Coordinator supplied a new FD event for execution context, and at the Worker pool shutdown.

Similarly to the Coordinator's Relay_log_info::set_rli_description_event() the possibly existing old FD is destoyed, carefully; each worker decrements Format_description_log_event::atomic_usage_counter and when it is made zero the destructor runs. Unlike to Coordinator's role, the usage counter of the new FD is not incremented, see Log_event::get_slave_worker() where and why it's done there.

Notice, the method is run as well by Coordinator per each Worker at MTS shutdown time.

Todo: consider to merge logics of the method with that of Relay_log_info class.

Parameters
fdlepointer to a new Format_description_log_event
Returns
1 if an error was encountered, 0 otherwise.

Reimplemented from Relay_log_info.

◆ slave_worker_ends_group()

void Slave_worker::slave_worker_ends_group ( Log_event ev,
int  error 
)

Deallocation routine to cancel out few effects of map_db_to_worker().

Involved into processing of the group APH tuples are updated. last_group_done_index member is set to the GAQ index of the current group. CGEP the Worker partition cache is cleaned up.

Parameters
eva pointer to Log_event
errorerror code after processing the event by caller.

◆ slave_worker_exec_event()

int Slave_worker::slave_worker_exec_event ( Log_event ev)

MTS worker main routine.

The worker thread loops in waiting for an event, executing it and fixing statistics counters.

Returns
0 success -1 got killed or an error happened during applying

◆ worker_sleep()

bool Slave_worker::worker_sleep ( ulong  seconds)
private

Sleep for a given amount of seconds or until killed.

Parameters
secondsThe number of seconds to sleep.
Return values
Trueif the thread has been killed, false otherwise.

◆ write_info()

bool Slave_worker::write_info ( Rpl_info_handler to)
privatevirtual

Reimplemented from Relay_log_info.

Member Data Documentation

◆ bitmap_shifted

ulong Slave_worker::bitmap_shifted

◆ c_rli

Relay_log_info* Slave_worker::c_rli

◆ checkpoint_master_log_name

char Slave_worker::checkpoint_master_log_name[FN_REFLEN]

◆ checkpoint_master_log_pos

ulonglong Slave_worker::checkpoint_master_log_pos

◆ checkpoint_notified

volatile bool Slave_worker::checkpoint_notified

◆ checkpoint_relay_log_name

char Slave_worker::checkpoint_relay_log_name[FN_REFLEN]

◆ checkpoint_relay_log_pos

ulonglong Slave_worker::checkpoint_relay_log_pos

◆ curr_group_exec_parts

Prealloced_array<db_worker_hash_entry *, SLAVE_INIT_DBS_IN_GROUP> Slave_worker::curr_group_exec_parts

◆ curr_group_seen_sequence_number

bool Slave_worker::curr_group_seen_sequence_number

◆ curr_jobs

volatile int Slave_worker::curr_jobs

◆ end_group_sets_max_dbs

bool Slave_worker::end_group_sets_max_dbs

◆ events_done

ulong Slave_worker::events_done

◆ excess_cnt

ulong Slave_worker::excess_cnt

◆ exit_incremented

bool Slave_worker::exit_incremented

◆ fd_change_notified

bool Slave_worker::fd_change_notified

◆ gaq_index

ulong Slave_worker::gaq_index
private

◆ group_executed

MY_BITMAP Slave_worker::group_executed

◆ group_shifted

MY_BITMAP Slave_worker::group_shifted

◆ groups_done

ulong Slave_worker::groups_done

◆ id

ulong Slave_worker::id

◆ jobs

Slave_jobs_queue Slave_worker::jobs

◆ jobs_cond

mysql_cond_t Slave_worker::jobs_cond

◆ jobs_lock

mysql_mutex_t Slave_worker::jobs_lock

◆ last_group_done_index

volatile ulong Slave_worker::last_group_done_index

◆ last_groups_assigned_index

ulonglong Slave_worker::last_groups_assigned_index

◆ m_order_commit_deadlock

bool Slave_worker::m_order_commit_deadlock
private

◆ master_log_change_notified

volatile bool Slave_worker::master_log_change_notified

◆ master_log_pos

ulonglong Slave_worker::master_log_pos
private

◆ overrun_level

ulong Slave_worker::overrun_level

◆ relay_log_change_notified

volatile bool Slave_worker::relay_log_change_notified

◆ running_status

en_running_state volatile Slave_worker::running_status

◆ server_version

ulong Slave_worker::server_version

◆ underrun_level

ulong Slave_worker::underrun_level

◆ usage_partition

long Slave_worker::usage_partition

◆ worker_checkpoint_seqno

ulong Slave_worker::worker_checkpoint_seqno

◆ wq_empty_waits

ulong Slave_worker::wq_empty_waits

◆ wq_overrun_cnt

long Slave_worker::wq_overrun_cnt

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