diff options
Diffstat (limited to 'sql/slave.cc')
-rw-r--r-- | sql/slave.cc | 142 |
1 files changed, 71 insertions, 71 deletions
diff --git a/sql/slave.cc b/sql/slave.cc index 0854bc123f9..cb957b7b3b5 100644 --- a/sql/slave.cc +++ b/sql/slave.cc @@ -33,8 +33,8 @@ #include "rpl_tblmap.h" -int queue_event(MASTER_INFO* mi,const char* buf,ulong event_len); -static Log_event* next_event(RELAY_LOG_INFO* rli); +int queue_event(Master_info* mi,const char* buf,ulong event_len); +static Log_event* next_event(Relay_log_info* rli); #define FLAGSTR(V,F) ((V)&(F)?#F" ":"") @@ -46,7 +46,7 @@ MY_BITMAP slave_error_mask; typedef bool (*CHECK_KILLED_FUNC)(THD*,void*); char* slave_load_tmpdir = 0; -MASTER_INFO *active_mi= 0; +Master_info *active_mi= 0; my_bool replicate_same_server_id; ulonglong relay_log_space_limit = 0; @@ -54,7 +54,7 @@ ulonglong relay_log_space_limit = 0; When slave thread exits, we need to remember the temporary tables so we can re-use them on slave start. - TODO: move the vars below under MASTER_INFO + TODO: move the vars below under Master_info */ int disconnect_slave_event_count = 0, abort_slave_event_count = 0; @@ -114,24 +114,24 @@ failed read" typedef enum { SLAVE_THD_IO, SLAVE_THD_SQL} SLAVE_THD_TYPE; -static int process_io_rotate(MASTER_INFO* mi, Rotate_log_event* rev); -static int process_io_create_file(MASTER_INFO* mi, Create_file_log_event* cev); -static bool wait_for_relay_log_space(RELAY_LOG_INFO* rli); -static inline bool io_slave_killed(THD* thd,MASTER_INFO* mi); -static inline bool sql_slave_killed(THD* thd,RELAY_LOG_INFO* rli); +static int process_io_rotate(Master_info* mi, Rotate_log_event* rev); +static int process_io_create_file(Master_info* mi, Create_file_log_event* cev); +static bool wait_for_relay_log_space(Relay_log_info* rli); +static inline bool io_slave_killed(THD* thd,Master_info* mi); +static inline bool sql_slave_killed(THD* thd,Relay_log_info* rli); static int init_slave_thread(THD* thd, SLAVE_THD_TYPE thd_type); -static int safe_connect(THD* thd, MYSQL* mysql, MASTER_INFO* mi); -static int safe_reconnect(THD* thd, MYSQL* mysql, MASTER_INFO* mi, +static int safe_connect(THD* thd, MYSQL* mysql, Master_info* mi); +static int safe_reconnect(THD* thd, MYSQL* mysql, Master_info* mi, bool suppress_warnings); -static int connect_to_master(THD* thd, MYSQL* mysql, MASTER_INFO* mi, +static int connect_to_master(THD* thd, MYSQL* mysql, Master_info* mi, bool reconnect, bool suppress_warnings); static int safe_sleep(THD* thd, int sec, CHECK_KILLED_FUNC thread_killed, void* thread_killed_arg); static int request_table_dump(MYSQL* mysql, const char* db, const char* table); static int create_table_from_dump(THD* thd, MYSQL *mysql, const char* db, const char* table_name, bool overwrite); -static int get_master_version_and_clock(MYSQL* mysql, MASTER_INFO* mi); -static Log_event* next_event(RELAY_LOG_INFO* rli); +static int get_master_version_and_clock(MYSQL* mysql, Master_info* mi); +static Log_event* next_event(Relay_log_info* rli); /* Find out which replications threads are running @@ -151,7 +151,7 @@ static Log_event* next_event(RELAY_LOG_INFO* rli); If inverse == 1, stopped threads */ -void init_thread_mask(int* mask,MASTER_INFO* mi,bool inverse) +void init_thread_mask(int* mask,Master_info* mi,bool inverse) { bool set_io = mi->slave_running, set_sql = mi->rli.slave_running; register int tmp_mask=0; @@ -172,7 +172,7 @@ void init_thread_mask(int* mask,MASTER_INFO* mi,bool inverse) lock_slave_threads() */ -void lock_slave_threads(MASTER_INFO* mi) +void lock_slave_threads(Master_info* mi) { DBUG_ENTER("lock_slave_threads"); @@ -187,7 +187,7 @@ void lock_slave_threads(MASTER_INFO* mi) unlock_slave_threads() */ -void unlock_slave_threads(MASTER_INFO* mi) +void unlock_slave_threads(Master_info* mi) { DBUG_ENTER("unlock_slave_threads"); @@ -214,7 +214,7 @@ int init_slave() TODO: re-write this to interate through the list of files for multi-master */ - active_mi= new MASTER_INFO; + active_mi= new Master_info; /* If master_host is not specified, try to read it from the master_info file. @@ -304,7 +304,7 @@ void init_slave_skip_errors(const char* arg) } -int terminate_slave_threads(MASTER_INFO* mi,int thread_mask,bool skip_lock) +int terminate_slave_threads(Master_info* mi,int thread_mask,bool skip_lock) { DBUG_ENTER("terminate_slave_threads"); @@ -393,7 +393,7 @@ int start_slave_thread(pthread_handler h_func, pthread_mutex_t *start_lock, pthread_cond_t *start_cond, volatile uint *slave_running, volatile ulong *slave_run_id, - MASTER_INFO* mi, + Master_info* mi, bool high_priority) { pthread_t th; @@ -463,7 +463,7 @@ int start_slave_thread(pthread_handler h_func, pthread_mutex_t *start_lock, */ int start_slave_threads(bool need_slave_mutex, bool wait_for_start, - MASTER_INFO* mi, const char* master_info_fname, + Master_info* mi, const char* master_info_fname, const char* slave_info_fname, int thread_mask) { pthread_mutex_t *lock_io=0,*lock_sql=0,*lock_cond_io=0,*lock_cond_sql=0; @@ -503,7 +503,7 @@ int start_slave_threads(bool need_slave_mutex, bool wait_for_start, #ifdef NOT_USED_YET -static int end_slave_on_walk(MASTER_INFO* mi, uchar* /*unused*/) +static int end_slave_on_walk(Master_info* mi, uchar* /*unused*/) { DBUG_ENTER("end_slave_on_walk"); @@ -549,7 +549,7 @@ void end_slave() } -static bool io_slave_killed(THD* thd, MASTER_INFO* mi) +static bool io_slave_killed(THD* thd, Master_info* mi) { DBUG_ENTER("io_slave_killed"); @@ -559,7 +559,7 @@ static bool io_slave_killed(THD* thd, MASTER_INFO* mi) } -static bool sql_slave_killed(THD* thd, RELAY_LOG_INFO* rli) +static bool sql_slave_killed(THD* thd, Relay_log_info* rli) { DBUG_ENTER("sql_slave_killed"); @@ -699,7 +699,7 @@ int init_intvar_from_file(int* var, IO_CACHE* f, int default_val) 1 error */ -static int get_master_version_and_clock(MYSQL* mysql, MASTER_INFO* mi) +static int get_master_version_and_clock(MYSQL* mysql, Master_info* mi) { const char* errmsg= 0; DBUG_ENTER("get_master_version_and_clock"); @@ -1018,7 +1018,7 @@ err: int fetch_master_table(THD *thd, const char *db_name, const char *table_name, - MASTER_INFO *mi, MYSQL *mysql, bool overwrite) + Master_info *mi, MYSQL *mysql, bool overwrite) { int error= 1; const char *errmsg=0; @@ -1073,10 +1073,10 @@ int fetch_master_table(THD *thd, const char *db_name, const char *table_name, } -static bool wait_for_relay_log_space(RELAY_LOG_INFO* rli) +static bool wait_for_relay_log_space(Relay_log_info* rli) { bool slave_killed=0; - MASTER_INFO* mi = rli->mi; + Master_info* mi = rli->mi; const char *save_proc_info; THD* thd = mi->io_thd; DBUG_ENTER("wait_for_relay_log_space"); @@ -1108,9 +1108,9 @@ Waiting for the slave SQL thread to free enough relay log space"); ignored events' end position for the use of the slave SQL thread, by calling this function. Only that thread can call it (see assertion). */ -static void write_ignored_events_info_to_relay_log(THD *thd, MASTER_INFO *mi) +static void write_ignored_events_info_to_relay_log(THD *thd, Master_info *mi) { - RELAY_LOG_INFO *rli= &mi->rli; + Relay_log_info *rli= &mi->rli; pthread_mutex_t *log_lock= rli->relay_log.get_log_lock(); DBUG_ENTER("write_ignored_events_info_to_relay_log"); @@ -1151,7 +1151,7 @@ static void write_ignored_events_info_to_relay_log(THD *thd, MASTER_INFO *mi) } -int register_slave_on_master(MYSQL* mysql, MASTER_INFO *mi, +int register_slave_on_master(MYSQL* mysql, Master_info *mi, bool *suppress_warnings) { uchar buf[1024], *pos= buf; @@ -1200,7 +1200,7 @@ int register_slave_on_master(MYSQL* mysql, MASTER_INFO *mi, } -bool show_master_info(THD* thd, MASTER_INFO* mi) +bool show_master_info(THD* thd, Master_info* mi) { // TODO: fix this for multi-master List<Item> field_list; @@ -1322,8 +1322,8 @@ bool show_master_info(THD* thd, MASTER_INFO* mi) protocol->store((ulonglong) mi->rli.log_space_total); protocol->store( - mi->rli.until_condition==RELAY_LOG_INFO::UNTIL_NONE ? "None": - ( mi->rli.until_condition==RELAY_LOG_INFO::UNTIL_MASTER_POS? "Master": + mi->rli.until_condition==Relay_log_info::UNTIL_NONE ? "None": + ( mi->rli.until_condition==Relay_log_info::UNTIL_MASTER_POS? "Master": "Relay"), &my_charset_bin); protocol->store(mi->rli.until_log_name, &my_charset_bin); protocol->store((ulonglong) mi->rli.until_log_pos); @@ -1419,7 +1419,7 @@ void set_slave_thread_options(THD* thd) DBUG_VOID_RETURN; } -void set_slave_thread_default_charset(THD* thd, RELAY_LOG_INFO const *rli) +void set_slave_thread_default_charset(THD* thd, Relay_log_info const *rli) { DBUG_ENTER("set_slave_thread_default_charset"); @@ -1437,7 +1437,7 @@ void set_slave_thread_default_charset(THD* thd, RELAY_LOG_INFO const *rli) the thread. That the cache has to be invalidated is a secondary effect. */ - const_cast<RELAY_LOG_INFO*>(rli)->cached_charset_invalidate(); + const_cast<Relay_log_info*>(rli)->cached_charset_invalidate(); DBUG_VOID_RETURN; } @@ -1515,7 +1515,7 @@ static int safe_sleep(THD* thd, int sec, CHECK_KILLED_FUNC thread_killed, } -static int request_dump(MYSQL* mysql, MASTER_INFO* mi, +static int request_dump(MYSQL* mysql, Master_info* mi, bool *suppress_warnings) { uchar buf[FN_REFLEN + 10]; @@ -1599,7 +1599,7 @@ command"); number Length of packet */ -static ulong read_event(MYSQL* mysql, MASTER_INFO *mi, bool* suppress_warnings) +static ulong read_event(MYSQL* mysql, Master_info *mi, bool* suppress_warnings) { ulong len; DBUG_ENTER("read_event"); @@ -1647,7 +1647,7 @@ static ulong read_event(MYSQL* mysql, MASTER_INFO *mi, bool* suppress_warnings) } -int check_expected_error(THD* thd, RELAY_LOG_INFO const *rli, +int check_expected_error(THD* thd, Relay_log_info const *rli, int expected_error) { DBUG_ENTER("check_expected_error"); @@ -1709,7 +1709,7 @@ static int has_temporary_error(THD *thd) DBUG_RETURN(0); } -static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) +static int exec_relay_log_event(THD* thd, Relay_log_info* rli) { DBUG_ENTER("exec_relay_log_event"); @@ -1727,7 +1727,7 @@ static int exec_relay_log_event(THD* thd, RELAY_LOG_INFO* rli) was an event ignored by the I/O thread just before (BUG#13861 to be fixed). */ - if (rli->until_condition!=RELAY_LOG_INFO::UNTIL_NONE && + if (rli->until_condition!=Relay_log_info::UNTIL_NONE && rli->is_until_satisfied()) { char buf[22]; @@ -1944,7 +1944,7 @@ on this slave.\ } -static bool check_io_slave_killed(THD *thd, MASTER_INFO *mi, const char *info) +static bool check_io_slave_killed(THD *thd, Master_info *mi, const char *info) { if (io_slave_killed(thd, mi)) { @@ -1982,7 +1982,7 @@ static bool check_io_slave_killed(THD *thd, MASTER_INFO *mi, const char *info) @retval 1 There was an error. */ -static int try_to_reconnect(THD *thd, MYSQL *mysql, MASTER_INFO *mi, +static int try_to_reconnect(THD *thd, MYSQL *mysql, Master_info *mi, uint *retry_count, bool suppress_warnings, const char *messages[SLAVE_RECON_MSG_MAX]) { @@ -2038,8 +2038,8 @@ pthread_handler_t handle_slave_io(void *arg) { THD *thd; // needs to be first for thread_stack MYSQL *mysql; - MASTER_INFO *mi = (MASTER_INFO*)arg; - RELAY_LOG_INFO *rli= &mi->rli; + Master_info *mi = (Master_info*)arg; + Relay_log_info *rli= &mi->rli; char llbuff[22]; uint retry_count; bool suppress_warnings; @@ -2312,7 +2312,7 @@ err: /* Forget the relay log's format */ delete mi->rli.relay_log.description_event_for_queue; mi->rli.relay_log.description_event_for_queue= 0; - // TODO: make rpl_status part of MASTER_INFO + // TODO: make rpl_status part of Master_info change_rpl_status(RPL_ACTIVE_SLAVE,RPL_IDLE_SLAVE); DBUG_ASSERT(thd->net.buff != 0); net_end(&thd->net); // destructor will not free it, because net.vio is 0 @@ -2344,7 +2344,7 @@ pthread_handler_t handle_slave_sql(void *arg) THD *thd; /* needs to be first for thread_stack */ char llbuff[22],llbuff1[22]; - RELAY_LOG_INFO* rli = &((MASTER_INFO*)arg)->rli; + Relay_log_info* rli = &((Master_info*)arg)->rli; const char *errmsg; // needs to call my_thread_init(), otherwise we get a coredump in DBUG_ stuff @@ -2613,7 +2613,7 @@ the slave SQL thread with \"SLAVE START\". We stopped at log \ process_io_create_file() */ -static int process_io_create_file(MASTER_INFO* mi, Create_file_log_event* cev) +static int process_io_create_file(Master_info* mi, Create_file_log_event* cev) { int error = 1; ulong num_bytes; @@ -2740,7 +2740,7 @@ err: */ -static int process_io_rotate(MASTER_INFO *mi, Rotate_log_event *rev) +static int process_io_rotate(Master_info *mi, Rotate_log_event *rev) { DBUG_ENTER("process_io_rotate"); safe_mutex_assert_owner(&mi->data_lock); @@ -2788,14 +2788,14 @@ static int process_io_rotate(MASTER_INFO *mi, Rotate_log_event *rev) Reads a 3.23 event and converts it to the slave's format. This code was copied from MySQL 4.0. */ -static int queue_binlog_ver_1_event(MASTER_INFO *mi, const char *buf, +static int queue_binlog_ver_1_event(Master_info *mi, const char *buf, ulong event_len) { const char *errmsg = 0; ulong inc_pos; bool ignore_event= 0; char *tmp_buf = 0; - RELAY_LOG_INFO *rli= &mi->rli; + Relay_log_info *rli= &mi->rli; DBUG_ENTER("queue_binlog_ver_1_event"); /* @@ -2906,13 +2906,13 @@ static int queue_binlog_ver_1_event(MASTER_INFO *mi, const char *buf, Reads a 4.0 event and converts it to the slave's format. This code was copied from queue_binlog_ver_1_event(), with some affordable simplifications. */ -static int queue_binlog_ver_3_event(MASTER_INFO *mi, const char *buf, +static int queue_binlog_ver_3_event(Master_info *mi, const char *buf, ulong event_len) { const char *errmsg = 0; ulong inc_pos; char *tmp_buf = 0; - RELAY_LOG_INFO *rli= &mi->rli; + Relay_log_info *rli= &mi->rli; DBUG_ENTER("queue_binlog_ver_3_event"); /* read_log_event() will adjust log_pos to be end_log_pos */ @@ -2970,7 +2970,7 @@ err: setup with 3.23 master or 4.0 master */ -static int queue_old_event(MASTER_INFO *mi, const char *buf, +static int queue_old_event(Master_info *mi, const char *buf, ulong event_len) { DBUG_ENTER("queue_old_event"); @@ -2998,11 +2998,11 @@ static int queue_old_event(MASTER_INFO *mi, const char *buf, any >=5.0.0 format. */ -int queue_event(MASTER_INFO* mi,const char* buf, ulong event_len) +int queue_event(Master_info* mi,const char* buf, ulong event_len) { int error= 0; ulong inc_pos; - RELAY_LOG_INFO *rli= &mi->rli; + Relay_log_info *rli= &mi->rli; pthread_mutex_t *log_lock= rli->relay_log.get_log_lock(); DBUG_ENTER("queue_event"); @@ -3154,7 +3154,7 @@ err: } -void end_relay_log_info(RELAY_LOG_INFO* rli) +void end_relay_log_info(Relay_log_info* rli) { DBUG_ENTER("end_relay_log_info"); @@ -3198,7 +3198,7 @@ void end_relay_log_info(RELAY_LOG_INFO* rli) # Error */ -static int safe_connect(THD* thd, MYSQL* mysql, MASTER_INFO* mi) +static int safe_connect(THD* thd, MYSQL* mysql, Master_info* mi) { DBUG_ENTER("safe_connect"); @@ -3215,7 +3215,7 @@ static int safe_connect(THD* thd, MYSQL* mysql, MASTER_INFO* mi) master_retry_count times */ -static int connect_to_master(THD* thd, MYSQL* mysql, MASTER_INFO* mi, +static int connect_to_master(THD* thd, MYSQL* mysql, Master_info* mi, bool reconnect, bool suppress_warnings) { int slave_was_killed; @@ -3321,7 +3321,7 @@ replication resumed in log '%s' at position %s", mi->user, master_retry_count times */ -static int safe_reconnect(THD* thd, MYSQL* mysql, MASTER_INFO* mi, +static int safe_reconnect(THD* thd, MYSQL* mysql, Master_info* mi, bool suppress_warnings) { DBUG_ENTER("safe_reconnect"); @@ -3358,7 +3358,7 @@ static int safe_reconnect(THD* thd, MYSQL* mysql, MASTER_INFO* mi, 1 write error */ -bool flush_relay_log_info(RELAY_LOG_INFO* rli) +bool flush_relay_log_info(Relay_log_info* rli) { bool error=0; DBUG_ENTER("flush_relay_log_info"); @@ -3392,7 +3392,7 @@ bool flush_relay_log_info(RELAY_LOG_INFO* rli) Called when we notice that the current "hot" log got rotated under our feet. */ -static IO_CACHE *reopen_relay_log(RELAY_LOG_INFO *rli, const char **errmsg) +static IO_CACHE *reopen_relay_log(Relay_log_info *rli, const char **errmsg) { DBUG_ENTER("reopen_relay_log"); DBUG_ASSERT(rli->cur_log != &rli->cache_buf); @@ -3413,7 +3413,7 @@ static IO_CACHE *reopen_relay_log(RELAY_LOG_INFO *rli, const char **errmsg) } -static Log_event* next_event(RELAY_LOG_INFO* rli) +static Log_event* next_event(Relay_log_info* rli) { Log_event* ev; IO_CACHE* cur_log = rli->cur_log; @@ -3605,10 +3605,10 @@ static Log_event* next_event(RELAY_LOG_INFO* rli) // prevent the I/O thread from blocking next times rli->ignore_log_space_limit= 1; /* - If the I/O thread is blocked, unblock it. - Ok to broadcast after unlock, because the mutex is only destroyed in - ~st_relay_log_info(), i.e. when rli is destroyed, and rli will not be - destroyed before we exit the present function. + If the I/O thread is blocked, unblock it. Ok to broadcast + after unlock, because the mutex is only destroyed in + ~Relay_log_info(), i.e. when rli is destroyed, and rli will + not be destroyed before we exit the present function. */ pthread_mutex_unlock(&rli->log_space_lock); pthread_cond_broadcast(&rli->log_space_cond); @@ -3765,10 +3765,10 @@ err: is void). */ -void rotate_relay_log(MASTER_INFO* mi) +void rotate_relay_log(Master_info* mi) { DBUG_ENTER("rotate_relay_log"); - RELAY_LOG_INFO* rli= &mi->rli; + Relay_log_info* rli= &mi->rli; /* We don't lock rli->run_lock. This would lead to deadlocks. */ pthread_mutex_lock(&mi->run_lock); @@ -3809,11 +3809,11 @@ end: /** Detects, based on master's version (as found in the relay log), if master has a certain bug. - @param rli RELAY_LOG_INFO which tells the master's version + @param rli Relay_log_info which tells the master's version @param bug_id Number of the bug as found in bugs.mysql.com @return TRUE if master has the bug, FALSE if it does not. */ -bool rpl_master_has_bug(RELAY_LOG_INFO *rli, uint bug_id) +bool rpl_master_has_bug(Relay_log_info *rli, uint bug_id) { struct st_version_range_for_one_bug { uint bug_id; |