diff options
Diffstat (limited to 'sql/sql_repl.cc')
-rw-r--r-- | sql/sql_repl.cc | 71 |
1 files changed, 30 insertions, 41 deletions
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc index ef6d0706da0..edff750a9a3 100644 --- a/sql/sql_repl.cc +++ b/sql/sql_repl.cc @@ -182,6 +182,7 @@ struct binlog_send_info { { error_text[0] = 0; bzero(&error_gtid, sizeof(error_gtid)); + until_binlog_state.init(); } }; @@ -494,7 +495,7 @@ static enum enum_binlog_checksum_alg get_binlog_checksum_value_at_connect(THD * TODO - Inform the slave threads that they should sync the position - in the binary log file with flush_relay_log_info. + in the binary log file with Relay_log_info::flush(). Now they sync is done for next read. */ @@ -864,7 +865,6 @@ get_binlog_list(MEM_ROOT *memroot) !(e->name= strmake_root(memroot, fname, length))) { mysql_bin_log.unlock_index(); - my_error(ER_OUTOFMEMORY, MYF(0), length + 1 + sizeof(*e)); DBUG_RETURN(NULL); } e->next= current_list; @@ -1562,7 +1562,7 @@ is_until_reached(binlog_send_info *info, ulong *ev_offset, break; case GTID_UNTIL_STOP_AFTER_TRANSACTION: if (event_type != XID_EVENT && - (event_type != QUERY_EVENT || + (event_type != QUERY_EVENT || /* QUERY_COMPRESSED_EVENT would never be commmit or rollback */ !Query_log_event::peek_is_commit_rollback (info->packet->ptr()+*ev_offset, info->packet->length()-*ev_offset, @@ -1796,7 +1796,7 @@ send_event_to_slave(binlog_send_info *info, Log_event_type event_type, return NULL; case GTID_SKIP_TRANSACTION: if (event_type == XID_EVENT || - (event_type == QUERY_EVENT && + (event_type == QUERY_EVENT && /* QUERY_COMPRESSED_EVENT would never be commmit or rollback */ Query_log_event::peek_is_commit_rollback(packet->ptr() + ev_offset, len - ev_offset, current_checksum_alg))) @@ -2046,12 +2046,6 @@ static int init_binlog_sender(binlog_send_info *info, info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG; return 1; } - if (!server_id_supplied) - { - info->errmsg= "Misconfigured master - server id was not set"; - info->error= ER_MASTER_FATAL_ERROR_READING_BINLOG; - return 1; - } char search_file_name[FN_REFLEN]; const char *name=search_file_name; @@ -2112,9 +2106,7 @@ static int init_binlog_sender(binlog_send_info *info, linfo->pos= *pos; // note: publish that we use file, before we open it - mysql_mutex_lock(&LOCK_thread_count); thd->current_linfo= linfo; - mysql_mutex_unlock(&LOCK_thread_count); if (check_start_offset(info, linfo->log_file_name, *pos)) return 1; @@ -2620,7 +2612,7 @@ static int send_events(binlog_send_info *info, IO_CACHE* log, LOG_INFO* linfo, Gtid_list_log_event glev(&info->until_binlog_state, 0); if (reset_transmit_packet(info, info->flags, &ev_offset, &info->errmsg) || - fake_gtid_list_event(info, &glev, &info->errmsg, my_b_tell(log))) + fake_gtid_list_event(info, &glev, &info->errmsg, (uint32)my_b_tell(log))) { info->error= ER_UNKNOWN_ERROR; return 1; @@ -2630,7 +2622,7 @@ static int send_events(binlog_send_info *info, IO_CACHE* log, LOG_INFO* linfo, if (info->until_gtid_state && is_until_reached(info, &ev_offset, event_type, &info->errmsg, - my_b_tell(log))) + (uint32)my_b_tell(log))) { if (info->errmsg) { @@ -2685,7 +2677,7 @@ static int send_one_binlog_file(binlog_send_info *info, if (end_pos <= 1) { /** end of file or error */ - return end_pos; + return (int)end_pos; } /** @@ -2849,6 +2841,13 @@ err: THD_STAGE_INFO(thd, stage_waiting_to_finalize_termination); RUN_HOOK(binlog_transmit, transmit_stop, (thd, flags)); + if (info->thd->killed == KILL_SLAVE_SAME_ID) + { + info->errmsg= "A slave with the same server_uuid/server_id as this slave " + "has connected to the master"; + info->error= ER_SLAVE_SAME_ID; + } + const bool binlog_open = my_b_inited(&log); if (file >= 0) { @@ -2856,13 +2855,12 @@ err: mysql_file_close(file, MYF(MY_WME)); } - mysql_mutex_lock(&LOCK_thread_count); - thd->current_linfo = 0; - mysql_mutex_unlock(&LOCK_thread_count); + thd->reset_current_linfo(); thd->variables.max_allowed_packet= old_max_allowed_packet; delete info->fdev; - if (info->error == ER_MASTER_FATAL_ERROR_READING_BINLOG && binlog_open) + if ((info->error == ER_MASTER_FATAL_ERROR_READING_BINLOG || + info->error == ER_SLAVE_SAME_ID) && binlog_open) { /* detailing the fatal error message with coordinates @@ -2978,7 +2976,7 @@ int start_slave(THD* thd , Master_info* mi, bool net_report) { /* connection was deleted while we waited for lock_slave_threads */ mi->unlock_slave_threads(); - my_error(WARN_NO_MASTER_INFO, mi->connection_name.length, + my_error(WARN_NO_MASTER_INFO, MYF(0), (int) mi->connection_name.length, mi->connection_name.str); DBUG_RETURN(-1); } @@ -3018,12 +3016,6 @@ int start_slave(THD* thd , Master_info* mi, bool net_report) if (init_master_info(mi,master_info_file_tmp,relay_log_info_file_tmp, 0, thread_mask)) slave_errno=ER_MASTER_INFO; - else if (!server_id_supplied) - { - slave_errno= ER_BAD_SLAVE; net_report= 0; - my_message(slave_errno, "Misconfigured slave: server_id was not set; Fix in config file", - MYF(0)); - } else if (!*mi->host) { slave_errno= ER_BAD_SLAVE; net_report= 0; @@ -3242,7 +3234,7 @@ int reset_slave(THD *thd, Master_info* mi) { /* connection was deleted while we waited for lock_slave_threads */ mi->unlock_slave_threads(); - my_error(WARN_NO_MASTER_INFO, mi->connection_name.length, + my_error(WARN_NO_MASTER_INFO, MYF(0), (int) mi->connection_name.length, mi->connection_name.str); DBUG_RETURN(-1); } @@ -3275,6 +3267,7 @@ int reset_slave(THD *thd, Master_info* mi) mi->clear_error(); mi->rli.clear_error(); mi->rli.clear_until_condition(); + mi->rli.clear_sql_delay(); mi->rli.slave_skip_counter= 0; // close master_info_file, relay_log_info_file, set mi->inited=rli->inited=0 @@ -3336,10 +3329,8 @@ err: SYNOPSIS kill_zombie_dump_threads() slave_server_id the slave's server id - */ - void kill_zombie_dump_threads(uint32 slave_server_id) { mysql_mutex_lock(&LOCK_thread_count); @@ -3363,7 +3354,7 @@ void kill_zombie_dump_threads(uint32 slave_server_id) it will be slow because it will iterate through the list again. We just to do kill the thread ourselves. */ - tmp->awake(KILL_QUERY); + tmp->awake(KILL_SLAVE_SAME_ID); mysql_mutex_unlock(&tmp->LOCK_thd_data); } } @@ -3386,7 +3377,8 @@ static bool get_string_parameter(char *to, const char *from, size_t length, uint from_numchars= cs->cset->numchars(cs, from, from + from_length); if (from_numchars > length / cs->mbmaxlen) { - my_error(ER_WRONG_STRING_LENGTH, MYF(0), from, name, length / cs->mbmaxlen); + my_error(ER_WRONG_STRING_LENGTH, MYF(0), from, name, + (int) (length / cs->mbmaxlen)); return 1; } memcpy(to, from, from_length+1); @@ -3455,7 +3447,7 @@ bool change_master(THD* thd, Master_info* mi, bool *master_info_added) { /* connection was deleted while we waited for lock_slave_threads */ mi->unlock_slave_threads(); - my_error(WARN_NO_MASTER_INFO, mi->connection_name.length, + my_error(WARN_NO_MASTER_INFO, MYF(0), (int) mi->connection_name.length, mi->connection_name.str); DBUG_RETURN(TRUE); } @@ -3596,6 +3588,9 @@ bool change_master(THD* thd, Master_info* mi, bool *master_info_added) if (lex_mi->ssl != LEX_MASTER_INFO::LEX_MI_UNCHANGED) mi->ssl= (lex_mi->ssl == LEX_MASTER_INFO::LEX_MI_ENABLE); + if (lex_mi->sql_delay != -1) + mi->rli.set_sql_delay(lex_mi->sql_delay); + if (lex_mi->ssl_verify_server_cert != LEX_MASTER_INFO::LEX_MI_UNCHANGED) mi->ssl_verify_server_cert= (lex_mi->ssl_verify_server_cert == LEX_MASTER_INFO::LEX_MI_ENABLE); @@ -3780,7 +3775,7 @@ bool change_master(THD* thd, Master_info* mi, bool *master_info_added) in-memory value at restart (thus causing errors, as the old relay log does not exist anymore). */ - if (flush_relay_log_info(&mi->rli)) + if (mi->rli.flush()) ret= 1; mysql_cond_broadcast(&mi->data_cond); mysql_mutex_unlock(&mi->rli.data_lock); @@ -3909,10 +3904,7 @@ bool mysql_show_binlog_events(THD* thd) goto err; } - /* These locks is here to enable syncronization with log_in_use() */ - mysql_mutex_lock(&LOCK_thread_count); - thd->current_linfo = &linfo; - mysql_mutex_unlock(&LOCK_thread_count); + thd->current_linfo= &linfo; if ((file=open_binlog(&log, linfo.log_file_name, &errmsg)) < 0) goto err; @@ -4044,10 +4036,7 @@ err: else my_eof(thd); - /* These locks is here to enable syncronization with log_in_use() */ - mysql_mutex_lock(&LOCK_thread_count); - thd->current_linfo= 0; - mysql_mutex_unlock(&LOCK_thread_count); + thd->reset_current_linfo(); thd->variables.max_allowed_packet= old_max_allowed_packet; DBUG_RETURN(ret); } |