diff options
author | Sergei Golubchik <serg@mariadb.org> | 2017-07-18 14:59:10 +0200 |
---|---|---|
committer | Sergei Golubchik <serg@mariadb.org> | 2017-07-18 14:59:10 +0200 |
commit | 9a5fe1f4ea53f26690bfe2cd4f42050bfccaf4af (patch) | |
tree | 5456add57977533b445a03d2e03e87ffa7f483d8 /sql/rpl_rli.cc | |
parent | e7fd6ed3875bd91dbd30a62291ae471c35da8fdf (diff) | |
parent | 34cd74e52185de2ea3156e8295de3c638cde8c88 (diff) | |
download | mariadb-git-9a5fe1f4ea53f26690bfe2cd4f42050bfccaf4af.tar.gz |
Merge remote-tracking branch 'mysql/5.5' into 5.5
Diffstat (limited to 'sql/rpl_rli.cc')
-rw-r--r-- | sql/rpl_rli.cc | 52 |
1 files changed, 42 insertions, 10 deletions
diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc index b01f74408a6..52e60c237dc 100644 --- a/sql/rpl_rli.cc +++ b/sql/rpl_rli.cc @@ -1,5 +1,5 @@ -/* Copyright (c) 2006, 2013, Oracle and/or its affiliates. - Copyright (c) 2011, 2013, Monty Program Ab +/* Copyright (c) 2006, 2017, Oracle and/or its affiliates. + Copyright (c) 2011, 2017, MariaDB Corporation This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -42,7 +42,8 @@ Relay_log_info::Relay_log_info(bool is_slave_recovery) no_storage(FALSE), replicate_same_server_id(::replicate_same_server_id), info_fd(-1), cur_log_fd(-1), relay_log(&sync_relaylog_period), sync_counter(0), is_relay_log_recovery(is_slave_recovery), - save_temporary_tables(0), cur_log_old_open_count(0), group_relay_log_pos(0), + save_temporary_tables(0), cur_log_old_open_count(0), + error_on_rli_init_info(false), group_relay_log_pos(0), event_relay_log_pos(0), #if HAVE_valgrind is_fake(FALSE), @@ -112,7 +113,7 @@ int init_relay_log_info(Relay_log_info* rli, const char* info_fname) { char fname[FN_REFLEN+128]; - int info_fd; + int info_fd= -1; const char* msg = 0; int error = 0; DBUG_ENTER("init_relay_log_info"); @@ -122,6 +123,8 @@ int init_relay_log_info(Relay_log_info* rli, DBUG_RETURN(0); fn_format(fname, info_fname, mysql_data_home, "", 4+32); mysql_mutex_lock(&rli->data_lock); + if (rli->error_on_rli_init_info) + goto err; info_fd = rli->info_fd; rli->cur_log_fd = -1; rli->slave_skip_counter=0; @@ -358,11 +361,14 @@ Failed to open the existing relay log info file '%s' (errno %d)", goto err; } rli->inited= 1; + rli->error_on_rli_init_info= false; mysql_mutex_unlock(&rli->data_lock); DBUG_RETURN(error); err: - sql_print_error("%s", msg); + rli->error_on_rli_init_info= true; + if (msg) + sql_print_error("%s", msg); end_io_cache(&rli->info_file); if (info_fd >= 0) mysql_file_close(info_fd, MYF(0)); @@ -947,6 +953,8 @@ int purge_relay_logs(Relay_log_info* rli, THD *thd, bool just_reset, const char** errmsg) { int error=0; + const char *ln; + char name_buf[FN_REFLEN]; DBUG_ENTER("purge_relay_logs"); /* @@ -973,12 +981,34 @@ int purge_relay_logs(Relay_log_info* rli, THD *thd, bool just_reset, if (!rli->inited) { DBUG_PRINT("info", ("rli->inited == 0")); - DBUG_RETURN(0); - } - - DBUG_ASSERT(rli->slave_running == 0); - DBUG_ASSERT(rli->mi->slave_running == 0); + if (rli->error_on_rli_init_info) + { + ln= rli->relay_log.generate_name(opt_relay_logname, "-relay-bin", + 1, name_buf); + if (rli->relay_log.open_index_file(opt_relaylog_index_name, ln, TRUE)) + { + sql_print_error("Unable to purge relay log files. Failed to open relay " + "log index file:%s.", rli->relay_log.get_index_fname()); + DBUG_RETURN(1); + } + if (rli->relay_log.open(ln, LOG_BIN, 0, SEQ_READ_APPEND, 0, + (max_relay_log_size ? max_relay_log_size : + max_binlog_size), 1, TRUE)) + { + sql_print_error("Unable to purge relay log files. Failed to open relay " + "log file:%s.", rli->relay_log.get_log_fname()); + DBUG_RETURN(1); + } + } + else + DBUG_RETURN(0); + } + else + { + DBUG_ASSERT(rli->slave_running == 0); + DBUG_ASSERT(rli->mi->slave_running == 0); + } rli->slave_skip_counter=0; mysql_mutex_lock(&rli->data_lock); @@ -1016,6 +1046,8 @@ int purge_relay_logs(Relay_log_info* rli, THD *thd, bool just_reset, rli->group_relay_log_pos, 0 /* do not need data lock */, errmsg, 0); + if (!rli->inited && rli->error_on_rli_init_info) + rli->relay_log.close(LOG_CLOSE_INDEX | LOG_CLOSE_STOP_EVENT); err: #ifndef DBUG_OFF char buf[22]; |