21 #include "rpl_utility.h"
22 #include "rpl_tblmap.h"
23 #include "rpl_reporting.h"
24 #include "rpl_utility.h"
27 #include "sql_class.h"
31 extern uint sql_slave_skip_counter;
106 friend class Rpl_info_factory;
127 inline bool belongs_to_client()
129 DBUG_ASSERT(info_thd);
130 return !info_thd->slave_thread;
140 bool replicate_same_server_id;
169 bool is_relay_log_recovery;
178 TABLE *save_temporary_tables;
187 uint32 cur_log_old_open_count;
208 char group_relay_log_name[FN_REFLEN];
209 ulonglong group_relay_log_pos;
210 char event_relay_log_name[FN_REFLEN];
211 ulonglong event_relay_log_pos;
212 ulonglong future_event_relay_log_pos;
226 char group_master_log_name[FN_REFLEN];
227 volatile my_off_t group_master_log_pos;
235 #if MYSQL_VERSION_ID < 40100
236 ulonglong future_master_log_pos;
238 ulonglong future_group_master_log_pos;
245 int add_logged_gtid(rpl_sidno sidno, rpl_gno gno)
249 DBUG_ASSERT(sidno <= global_sid_map->get_max_sidno());
251 if (gtid_set.
_add_gtid(sidno, gno) != RETURN_STATUS_OK)
255 const Gtid_set *get_gtid_set()
const {
return >id_set; }
258 ulonglong pos,
bool need_data_lock,
260 bool look_for_description_event);
268 ulonglong log_space_limit,log_space_total;
269 bool ignore_log_space_limit;
276 bool sql_force_rotate_relay;
278 time_t last_master_timestamp;
296 volatile uint32 slave_skip_counter;
297 volatile ulong abort_pos_wait;
311 enum {UNTIL_NONE= 0, UNTIL_MASTER_POS, UNTIL_RELAY_POS,
312 UNTIL_SQL_BEFORE_GTIDS, UNTIL_SQL_AFTER_GTIDS,
313 UNTIL_SQL_AFTER_MTS_GAPS
319 char until_log_name[FN_REFLEN];
320 ulonglong until_log_pos;
322 ulong until_log_name_extension;
334 bool until_sql_gtids_first_event;
341 UNTIL_LOG_NAMES_CMP_UNKNOWN= -2, UNTIL_LOG_NAMES_CMP_LESS= -1,
342 UNTIL_LOG_NAMES_CMP_EQUAL= 0, UNTIL_LOG_NAMES_CMP_GREATER= 1
343 } until_log_names_cmp_result;
345 char cached_charset[6];
353 ulong trans_retries, retried_trans;
363 char ign_master_log_name_end[FN_REFLEN];
364 ulonglong ign_master_log_pos_end;
370 char slave_patternload_file[FN_REFLEN];
371 size_t slave_patternload_file_size;
385 if (until_condition==UNTIL_RELAY_POS)
386 until_log_names_cmp_result= UNTIL_LOG_NAMES_CMP_UNKNOWN;
395 if (until_condition==UNTIL_MASTER_POS)
396 until_log_names_cmp_result= UNTIL_LOG_NAMES_CMP_UNKNOWN;
399 inline void inc_event_relay_log_pos()
401 event_relay_log_pos= future_event_relay_log_pos;
404 int inc_group_relay_log_pos(ulonglong log_pos,
405 bool need_data_lock);
409 int wait_for_gtid_set(THD* thd,
String* gtid, longlong timeout);
410 void close_temporary_tables();
414 inline ulonglong until_pos()
416 return ((until_condition == UNTIL_MASTER_POS) ? group_master_log_pos :
417 group_relay_log_pos);
421 uint tables_to_lock_count;
426 bool get_table_data(
TABLE *table_arg,
table_def **tabledef_var,
TABLE **conv_table_var)
const
428 DBUG_ASSERT(tabledef_var && conv_table_var);
429 for (
TABLE_LIST *ptr= tables_to_lock ; ptr != NULL ; ptr= ptr->next_global)
430 if (ptr->table == table_arg)
434 DBUG_PRINT(
"debug", (
"Fetching table data for table %s.%s:"
435 " tabledef: %p, conv_table: %p",
436 table_arg->s->db.str, table_arg->s->table_name.str,
437 *tabledef_var, *conv_table_var));
450 bool cached_charset_compare(
char *charset)
const;
452 void cleanup_context(THD *,
bool);
453 void slave_close_thread_tables(THD *);
454 void clear_tables_to_lock();
462 time_t last_event_start_time;
475 bool deferred_events_collecting;
486 volatile ulong pending_jobs;
489 ulong mts_slave_worker_queue_len_max;
490 ulonglong mts_pending_jobs_size;
491 ulonglong mts_pending_jobs_size_max;
492 bool mts_wq_oversize;
493 Slave_worker *last_assigned_worker;
498 Slave_committed_queue *gaq;
504 bool curr_group_seen_gtid;
505 bool curr_group_seen_begin;
506 bool curr_group_isolated;
507 bool mts_end_group_sets_max_dbs;
508 volatile ulong mts_wq_underrun_w_id;
519 volatile long mts_wq_excess_cnt;
520 long mts_worker_underrun_level;
521 ulong mts_coordinator_basic_nap;
522 ulong opt_slave_parallel_workers;
523 ulong slave_parallel_workers;
524 ulong recovery_parallel_workers;
525 uint checkpoint_seqno;
526 uint checkpoint_group;
528 bool recovery_groups_inited;
529 ulong mts_recovery_group_cnt;
530 ulong mts_recovery_index;
531 bool mts_recovery_group_seen_begin;
570 ulonglong mts_events_assigned;
571 ulong mts_groups_assigned;
572 volatile ulong mts_wq_overrun_cnt;
573 ulong wq_size_waits_cnt;
578 ulong mts_wq_no_underrun_cnt;
579 ulong mts_wq_overfill_cnt;
587 time_t mts_last_online_stat;
602 return mts_recovery_group_cnt != 0;
612 DBUG_ASSERT(!ret || workers.elements > 0);
624 mts_group_status == MTS_IN_GROUP;
650 inline void cleanup_after_query()
653 deferred_events->rewind();
656 void cleanup_after_session()
659 delete deferred_events;
685 m_flags |= (1UL << flag);
697 return m_flags & (1UL << flag);
707 m_flags &= ~(1UL << flag);
721 return (info_thd->variables.option_bits & OPTION_BEGIN) ||
725 int count_relay_log_space();
730 int flush_current_log();
731 void set_master_info(Master_info *info);
733 inline ulonglong get_future_event_relay_log_pos() {
return future_event_relay_log_pos; }
734 inline void set_future_event_relay_log_pos(ulonglong log_pos)
736 future_event_relay_log_pos= log_pos;
739 inline const char* get_group_master_log_name() {
return group_master_log_name; }
740 inline ulonglong get_group_master_log_pos() {
return group_master_log_pos; }
741 inline void set_group_master_log_name(
const char *log_file_name)
743 strmake(group_master_log_name,log_file_name,
sizeof(group_master_log_name)-1);
745 inline void set_group_master_log_pos(ulonglong log_pos)
747 group_master_log_pos= log_pos;
750 inline const char* get_group_relay_log_name() {
return group_relay_log_name; }
751 inline ulonglong get_group_relay_log_pos() {
return group_relay_log_pos; }
752 inline void set_group_relay_log_name(
const char *log_file_name)
754 strmake(group_relay_log_name,log_file_name,
sizeof(group_relay_log_name)-1);
756 inline void set_group_relay_log_name(
const char *log_file_name,
size_t len)
758 strmake(group_relay_log_name, log_file_name, len);
760 inline void set_group_relay_log_pos(ulonglong log_pos)
762 group_relay_log_pos= log_pos;
765 inline const char* get_event_relay_log_name() {
return event_relay_log_name; }
766 inline ulonglong get_event_relay_log_pos() {
return event_relay_log_pos; }
767 inline void set_event_relay_log_name(
const char *log_file_name)
769 strmake(event_relay_log_name,log_file_name,
sizeof(event_relay_log_name)-1);
771 inline void set_event_relay_log_name(
const char *log_file_name,
size_t len)
773 strmake(event_relay_log_name,log_file_name, len);
775 inline void set_event_relay_log_pos(ulonglong log_pos)
777 event_relay_log_pos= log_pos;
779 inline const char* get_rpl_log_name()
781 return (group_master_log_name[0] ? group_master_log_name :
"FIRST");
784 #if MYSQL_VERSION_ID < 40100
785 inline ulonglong get_future_master_log_pos() {
return future_master_log_pos; }
787 inline ulonglong get_future_group_master_log_pos() {
return future_group_master_log_pos; }
788 inline void set_future_group_master_log_pos(ulonglong log_pos)
790 future_group_master_log_pos= log_pos;
794 static size_t get_number_info_rli_fields();
810 sql_delay_end= delay_end;
811 THD_STAGE_INFO(info_thd, stage_sql_thd_waiting_until_delay);
814 int32 get_sql_delay() {
return sql_delay; }
815 void set_sql_delay(time_t _sql_delay) { sql_delay= _sql_delay; }
816 time_t get_sql_delay_end() {
return sql_delay_end; }
819 #ifdef HAVE_PSI_INTERFACE
820 ,PSI_mutex_key *param_key_info_run_lock,
821 PSI_mutex_key *param_key_info_data_lock,
822 PSI_mutex_key *param_key_info_sleep_lock,
823 PSI_mutex_key *param_key_info_data_cond,
824 PSI_mutex_key *param_key_info_start_cond,
825 PSI_mutex_key *param_key_info_stop_cond,
826 PSI_mutex_key *param_key_info_sleep_cond
837 bool reported_unsafe_warning;
839 time_t get_row_stmt_start_timestamp()
841 return row_stmt_start_timestamp;
844 time_t set_row_stmt_start_timestamp()
846 if (row_stmt_start_timestamp == 0)
847 row_stmt_start_timestamp= my_time(0);
849 return row_stmt_start_timestamp;
852 void reset_row_stmt_start_timestamp()
854 row_stmt_start_timestamp= 0;
857 void set_long_find_row_note_printed()
859 long_find_row_note_printed=
true;
862 void unset_long_find_row_note_printed()
864 long_find_row_note_printed=
false;
867 bool is_long_find_row_note_printed()
869 return long_find_row_note_printed;
884 return rli_description_event;
891 uchar slave_version_split[3];
919 time_t sql_delay_end;
927 static const int LINES_IN_RELAY_LOG_INFO_WITH_DELAY= 5;
932 static const int LINES_IN_RELAY_LOG_INFO_WITH_WORKERS= 6;
938 static const int LINES_IN_RELAY_LOG_INFO_WITH_ID= 7;
940 bool read_info(Rpl_info_handler *from);
941 bool write_info(Rpl_info_handler *
to);
950 time_t row_stmt_start_timestamp;
951 bool long_find_row_note_printed;
958 bool error_on_rli_init_info;
961 bool mysql_show_relaylog_events(THD* thd);
967 inline bool is_mts_worker(
const THD *thd)
969 return thd->system_thread == SYSTEM_THREAD_SLAVE_WORKER;