summaryrefslogtreecommitdiff
path: root/sql
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2017-02-05 02:23:49 +0200
committerSergei Golubchik <serg@mariadb.org>2017-02-28 16:10:47 +0100
commit4bad74e13955ee21015c6b8a9d4bd07624924efa (patch)
tree4cdc19790506479ced8062496f7cdb750a912303 /sql
parenta2de378c00c17b358fa784dcca6ab4ac11b56821 (diff)
downloadmariadb-git-4bad74e13955ee21015c6b8a9d4bd07624924efa.tar.gz
Added error checking for all calls to flush_relay_log_info() and stmt_done()
Diffstat (limited to 'sql')
-rw-r--r--sql/log.cc11
-rw-r--r--sql/log_event.cc17
-rw-r--r--sql/log_event_old.cc4
-rw-r--r--sql/rpl_rli.cc10
-rw-r--r--sql/rpl_rli.h2
-rw-r--r--sql/slave.cc14
-rw-r--r--sql/sql_repl.cc3
7 files changed, 40 insertions, 21 deletions
diff --git a/sql/log.cc b/sql/log.cc
index cd215822d44..bdd60b4d420 100644
--- a/sql/log.cc
+++ b/sql/log.cc
@@ -4129,7 +4129,7 @@ err:
int MYSQL_BIN_LOG::purge_first_log(Relay_log_info* rli, bool included)
{
- int error;
+ int error, errcode;
char *to_purge_if_included= NULL;
inuse_relaylog *ir;
ulonglong log_space_reclaimed= 0;
@@ -4200,7 +4200,8 @@ int MYSQL_BIN_LOG::purge_first_log(Relay_log_info* rli, bool included)
}
/* Store where we are in the new file for the execution thread */
- flush_relay_log_info(rli);
+ if (flush_relay_log_info(rli))
+ error= LOG_INFO_IO;
DBUG_EXECUTE_IF("crash_before_purge_logs", DBUG_SUICIDE(););
@@ -4216,11 +4217,13 @@ int MYSQL_BIN_LOG::purge_first_log(Relay_log_info* rli, bool included)
* Need to update the log pos because purge logs has been called
* after fetching initially the log pos at the begining of the method.
*/
- if((error=find_log_pos(&rli->linfo, rli->event_relay_log_name, 0)))
+ if ((errcode= find_log_pos(&rli->linfo, rli->event_relay_log_name, 0)))
{
char buff[22];
+ if (!error)
+ error= errcode;
sql_print_error("next log error: %d offset: %s log: %s included: %d",
- error,
+ errcode,
llstr(rli->linfo.index_file_offset,buff),
rli->group_relay_log_name,
included);
diff --git a/sql/log_event.cc b/sql/log_event.cc
index 14f6bb20b47..43e8df7b801 100644
--- a/sql/log_event.cc
+++ b/sql/log_event.cc
@@ -6244,9 +6244,11 @@ bool Rotate_log_event::write(IO_CACHE* file)
@retval
0 ok
+ 1 error
*/
int Rotate_log_event::do_update_pos(rpl_group_info *rgi)
{
+ int error= 0;
Relay_log_info *rli= rgi->rli;
DBUG_ENTER("Rotate_log_event::do_update_pos");
#ifndef DBUG_OFF
@@ -6298,7 +6300,7 @@ int Rotate_log_event::do_update_pos(rpl_group_info *rgi)
(ulong) rli->group_master_log_pos));
mysql_mutex_unlock(&rli->data_lock);
rpl_global_gtid_slave_state->record_and_update_gtid(thd, rgi);
- flush_relay_log_info(rli);
+ error= flush_relay_log_info(rli);
/*
Reset thd->variables.option_bits and sql_mode etc, because this could
@@ -6316,8 +6318,7 @@ int Rotate_log_event::do_update_pos(rpl_group_info *rgi)
else
rgi->inc_event_relay_log_pos();
-
- DBUG_RETURN(0);
+ DBUG_RETURN(error);
}
@@ -8174,6 +8175,7 @@ void Stop_log_event::print(FILE* file, PRINT_EVENT_INFO* print_event_info)
int Stop_log_event::do_update_pos(rpl_group_info *rgi)
{
+ int error= 0;
Relay_log_info *rli= rgi->rli;
DBUG_ENTER("Stop_log_event::do_update_pos");
/*
@@ -8189,9 +8191,10 @@ int Stop_log_event::do_update_pos(rpl_group_info *rgi)
{
rpl_global_gtid_slave_state->record_and_update_gtid(thd, rgi);
rli->inc_group_relay_log_pos(0, rgi);
- flush_relay_log_info(rli);
+ if (flush_relay_log_info(rli))
+ error= 1;
}
- DBUG_RETURN(0);
+ DBUG_RETURN(error);
}
#endif /* !MYSQL_CLIENT */
@@ -10178,8 +10181,8 @@ int
Rows_log_event::do_update_pos(rpl_group_info *rgi)
{
Relay_log_info *rli= rgi->rli;
- DBUG_ENTER("Rows_log_event::do_update_pos");
int error= 0;
+ DBUG_ENTER("Rows_log_event::do_update_pos");
DBUG_PRINT("info", ("flags: %s",
get_flags(STMT_END_F) ? "STMT_END_F " : ""));
@@ -10191,7 +10194,7 @@ Rows_log_event::do_update_pos(rpl_group_info *rgi)
Step the group log position if we are not in a transaction,
otherwise increase the event log position.
*/
- rli->stmt_done(log_pos, thd, rgi);
+ error= rli->stmt_done(log_pos, thd, rgi);
/*
Clear any errors in thd->net.last_err*. It is not known if this is
needed or not. It is believed that any errors that may exist in
diff --git a/sql/log_event_old.cc b/sql/log_event_old.cc
index 22ef970dab9..8bdb81f5283 100644
--- a/sql/log_event_old.cc
+++ b/sql/log_event_old.cc
@@ -1843,8 +1843,8 @@ int
Old_rows_log_event::do_update_pos(rpl_group_info *rgi)
{
Relay_log_info *rli= rgi->rli;
- DBUG_ENTER("Old_rows_log_event::do_update_pos");
int error= 0;
+ DBUG_ENTER("Old_rows_log_event::do_update_pos");
DBUG_PRINT("info", ("flags: %s",
get_flags(STMT_END_F) ? "STMT_END_F " : ""));
@@ -1856,7 +1856,7 @@ Old_rows_log_event::do_update_pos(rpl_group_info *rgi)
Step the group log position if we are not in a transaction,
otherwise increase the event log position.
*/
- rli->stmt_done(log_pos, thd, rgi);
+ error= rli->stmt_done(log_pos, thd, rgi);
/*
Clear any errors in thd->net.last_err*. It is not known if this is
needed or not. It is believed that any errors that may exist in
diff --git a/sql/rpl_rli.cc b/sql/rpl_rli.cc
index c570105cdf6..7eacf539d19 100644
--- a/sql/rpl_rli.cc
+++ b/sql/rpl_rli.cc
@@ -432,7 +432,7 @@ Failed to open the existing relay log info file '%s' (errno %d)",
}
rli->inited= 1;
mysql_mutex_unlock(&rli->data_lock);
- DBUG_RETURN(error);
+ DBUG_RETURN(0);
err:
sql_print_error("%s", msg);
@@ -1304,9 +1304,10 @@ bool Relay_log_info::is_until_satisfied(THD *thd, Log_event *ev)
}
-void Relay_log_info::stmt_done(my_off_t event_master_log_pos, THD *thd,
+bool Relay_log_info::stmt_done(my_off_t event_master_log_pos, THD *thd,
rpl_group_info *rgi)
{
+ int error= 0;
DBUG_ENTER("Relay_log_info::stmt_done");
DBUG_ASSERT(rgi->rli == this);
@@ -1358,10 +1359,11 @@ void Relay_log_info::stmt_done(my_off_t event_master_log_pos, THD *thd,
}
DBUG_EXECUTE_IF("inject_crash_before_flush_rli", DBUG_SUICIDE(););
if (mi->using_gtid == Master_info::USE_GTID_NO)
- flush_relay_log_info(this);
+ if (flush_relay_log_info(this))
+ error= 1;
DBUG_EXECUTE_IF("inject_crash_after_flush_rli", DBUG_SUICIDE(););
}
- DBUG_VOID_RETURN;
+ DBUG_RETURN(error);
}
diff --git a/sql/rpl_rli.h b/sql/rpl_rli.h
index efcec83b880..7fc41786957 100644
--- a/sql/rpl_rli.h
+++ b/sql/rpl_rli.h
@@ -416,7 +416,7 @@ public:
relay log info and used to produce information for <code>SHOW
SLAVE STATUS</code>.
*/
- void stmt_done(my_off_t event_log_pos, THD *thd, rpl_group_info *rgi);
+ bool stmt_done(my_off_t event_log_pos, THD *thd, rpl_group_info *rgi);
int alloc_inuse_relaylog(const char *name);
void free_inuse_relaylog(inuse_relaylog *ir);
void reset_inuse_relaylog();
diff --git a/sql/slave.cc b/sql/slave.cc
index 1bb2b534693..1634a56a4b6 100644
--- a/sql/slave.cc
+++ b/sql/slave.cc
@@ -4788,8 +4788,15 @@ log '%s' at position %s, relay log '%s' position: %s%s", RPL_LOG_NAME,
if (rli->mi->using_gtid != Master_info::USE_GTID_NO)
{
ulong domain_count;
+ my_bool save_log_all_errors= thd->log_all_errors;
+ /*
+ We don't need to check return value for flush_relay_log_info()
+ as any errors should be logged to stderr
+ */
+ thd->log_all_errors= 1;
flush_relay_log_info(rli);
+ thd->log_all_errors= save_log_all_errors;
if (mi->using_parallel())
{
/*
@@ -6715,9 +6722,12 @@ static Log_event* next_event(rpl_group_info *rgi, ulonglong *event_size)
}
rli->event_relay_log_pos = BIN_LOG_HEADER_SIZE;
strmake_buf(rli->event_relay_log_name,rli->linfo.log_file_name);
- flush_relay_log_info(rli);
+ if (flush_relay_log_info(rli))
+ {
+ errmsg= "error flushing relay log";
+ goto err;
+ }
}
-
/*
Now we want to open this next log. To know if it's a hot log (the one
being written by the I/O thread now) or a cold log, we can use
diff --git a/sql/sql_repl.cc b/sql/sql_repl.cc
index 7d4fb110229..560b7ede183 100644
--- a/sql/sql_repl.cc
+++ b/sql/sql_repl.cc
@@ -3619,7 +3619,8 @@ 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).
*/
- flush_relay_log_info(&mi->rli);
+ if (flush_relay_log_info(&mi->rli))
+ ret= 1;
mysql_cond_broadcast(&mi->data_cond);
mysql_mutex_unlock(&mi->rli.data_lock);