Added error checking for all calls to flush_relay_log_info() and stmt_done()
This commit is contained in:
parent
a2de378c00
commit
4bad74e139
11
sql/log.cc
11
sql/log.cc
@ -4129,7 +4129,7 @@ err:
|
|||||||
|
|
||||||
int MYSQL_BIN_LOG::purge_first_log(Relay_log_info* rli, bool included)
|
int MYSQL_BIN_LOG::purge_first_log(Relay_log_info* rli, bool included)
|
||||||
{
|
{
|
||||||
int error;
|
int error, errcode;
|
||||||
char *to_purge_if_included= NULL;
|
char *to_purge_if_included= NULL;
|
||||||
inuse_relaylog *ir;
|
inuse_relaylog *ir;
|
||||||
ulonglong log_space_reclaimed= 0;
|
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 */
|
/* 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(););
|
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
|
* Need to update the log pos because purge logs has been called
|
||||||
* after fetching initially the log pos at the begining of the method.
|
* 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];
|
char buff[22];
|
||||||
|
if (!error)
|
||||||
|
error= errcode;
|
||||||
sql_print_error("next log error: %d offset: %s log: %s included: %d",
|
sql_print_error("next log error: %d offset: %s log: %s included: %d",
|
||||||
error,
|
errcode,
|
||||||
llstr(rli->linfo.index_file_offset,buff),
|
llstr(rli->linfo.index_file_offset,buff),
|
||||||
rli->group_relay_log_name,
|
rli->group_relay_log_name,
|
||||||
included);
|
included);
|
||||||
|
@ -6244,9 +6244,11 @@ bool Rotate_log_event::write(IO_CACHE* file)
|
|||||||
|
|
||||||
@retval
|
@retval
|
||||||
0 ok
|
0 ok
|
||||||
|
1 error
|
||||||
*/
|
*/
|
||||||
int Rotate_log_event::do_update_pos(rpl_group_info *rgi)
|
int Rotate_log_event::do_update_pos(rpl_group_info *rgi)
|
||||||
{
|
{
|
||||||
|
int error= 0;
|
||||||
Relay_log_info *rli= rgi->rli;
|
Relay_log_info *rli= rgi->rli;
|
||||||
DBUG_ENTER("Rotate_log_event::do_update_pos");
|
DBUG_ENTER("Rotate_log_event::do_update_pos");
|
||||||
#ifndef DBUG_OFF
|
#ifndef DBUG_OFF
|
||||||
@ -6298,7 +6300,7 @@ int Rotate_log_event::do_update_pos(rpl_group_info *rgi)
|
|||||||
(ulong) rli->group_master_log_pos));
|
(ulong) rli->group_master_log_pos));
|
||||||
mysql_mutex_unlock(&rli->data_lock);
|
mysql_mutex_unlock(&rli->data_lock);
|
||||||
rpl_global_gtid_slave_state->record_and_update_gtid(thd, rgi);
|
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
|
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
|
else
|
||||||
rgi->inc_event_relay_log_pos();
|
rgi->inc_event_relay_log_pos();
|
||||||
|
|
||||||
|
DBUG_RETURN(error);
|
||||||
DBUG_RETURN(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -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 Stop_log_event::do_update_pos(rpl_group_info *rgi)
|
||||||
{
|
{
|
||||||
|
int error= 0;
|
||||||
Relay_log_info *rli= rgi->rli;
|
Relay_log_info *rli= rgi->rli;
|
||||||
DBUG_ENTER("Stop_log_event::do_update_pos");
|
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);
|
rpl_global_gtid_slave_state->record_and_update_gtid(thd, rgi);
|
||||||
rli->inc_group_relay_log_pos(0, 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 */
|
#endif /* !MYSQL_CLIENT */
|
||||||
@ -10178,8 +10181,8 @@ int
|
|||||||
Rows_log_event::do_update_pos(rpl_group_info *rgi)
|
Rows_log_event::do_update_pos(rpl_group_info *rgi)
|
||||||
{
|
{
|
||||||
Relay_log_info *rli= rgi->rli;
|
Relay_log_info *rli= rgi->rli;
|
||||||
DBUG_ENTER("Rows_log_event::do_update_pos");
|
|
||||||
int error= 0;
|
int error= 0;
|
||||||
|
DBUG_ENTER("Rows_log_event::do_update_pos");
|
||||||
|
|
||||||
DBUG_PRINT("info", ("flags: %s",
|
DBUG_PRINT("info", ("flags: %s",
|
||||||
get_flags(STMT_END_F) ? "STMT_END_F " : ""));
|
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,
|
Step the group log position if we are not in a transaction,
|
||||||
otherwise increase the event log position.
|
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
|
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
|
needed or not. It is believed that any errors that may exist in
|
||||||
|
@ -1843,8 +1843,8 @@ int
|
|||||||
Old_rows_log_event::do_update_pos(rpl_group_info *rgi)
|
Old_rows_log_event::do_update_pos(rpl_group_info *rgi)
|
||||||
{
|
{
|
||||||
Relay_log_info *rli= rgi->rli;
|
Relay_log_info *rli= rgi->rli;
|
||||||
DBUG_ENTER("Old_rows_log_event::do_update_pos");
|
|
||||||
int error= 0;
|
int error= 0;
|
||||||
|
DBUG_ENTER("Old_rows_log_event::do_update_pos");
|
||||||
|
|
||||||
DBUG_PRINT("info", ("flags: %s",
|
DBUG_PRINT("info", ("flags: %s",
|
||||||
get_flags(STMT_END_F) ? "STMT_END_F " : ""));
|
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,
|
Step the group log position if we are not in a transaction,
|
||||||
otherwise increase the event log position.
|
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
|
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
|
needed or not. It is believed that any errors that may exist in
|
||||||
|
@ -432,7 +432,7 @@ Failed to open the existing relay log info file '%s' (errno %d)",
|
|||||||
}
|
}
|
||||||
rli->inited= 1;
|
rli->inited= 1;
|
||||||
mysql_mutex_unlock(&rli->data_lock);
|
mysql_mutex_unlock(&rli->data_lock);
|
||||||
DBUG_RETURN(error);
|
DBUG_RETURN(0);
|
||||||
|
|
||||||
err:
|
err:
|
||||||
sql_print_error("%s", msg);
|
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)
|
rpl_group_info *rgi)
|
||||||
{
|
{
|
||||||
|
int error= 0;
|
||||||
DBUG_ENTER("Relay_log_info::stmt_done");
|
DBUG_ENTER("Relay_log_info::stmt_done");
|
||||||
|
|
||||||
DBUG_ASSERT(rgi->rli == this);
|
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(););
|
DBUG_EXECUTE_IF("inject_crash_before_flush_rli", DBUG_SUICIDE(););
|
||||||
if (mi->using_gtid == Master_info::USE_GTID_NO)
|
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_EXECUTE_IF("inject_crash_after_flush_rli", DBUG_SUICIDE(););
|
||||||
}
|
}
|
||||||
DBUG_VOID_RETURN;
|
DBUG_RETURN(error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -416,7 +416,7 @@ public:
|
|||||||
relay log info and used to produce information for <code>SHOW
|
relay log info and used to produce information for <code>SHOW
|
||||||
SLAVE STATUS</code>.
|
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);
|
int alloc_inuse_relaylog(const char *name);
|
||||||
void free_inuse_relaylog(inuse_relaylog *ir);
|
void free_inuse_relaylog(inuse_relaylog *ir);
|
||||||
void reset_inuse_relaylog();
|
void reset_inuse_relaylog();
|
||||||
|
14
sql/slave.cc
14
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)
|
if (rli->mi->using_gtid != Master_info::USE_GTID_NO)
|
||||||
{
|
{
|
||||||
ulong domain_count;
|
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);
|
flush_relay_log_info(rli);
|
||||||
|
thd->log_all_errors= save_log_all_errors;
|
||||||
if (mi->using_parallel())
|
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;
|
rli->event_relay_log_pos = BIN_LOG_HEADER_SIZE;
|
||||||
strmake_buf(rli->event_relay_log_name,rli->linfo.log_file_name);
|
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
|
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
|
being written by the I/O thread now) or a cold log, we can use
|
||||||
|
@ -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
|
in-memory value at restart (thus causing errors, as the old relay log does
|
||||||
not exist anymore).
|
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_cond_broadcast(&mi->data_cond);
|
||||||
mysql_mutex_unlock(&mi->rli.data_lock);
|
mysql_mutex_unlock(&mi->rli.data_lock);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user