Skip to content

Commit

Permalink
Handle out-of-space on binlog cache file
Browse files Browse the repository at this point in the history
Summary:
The binlog cache file code is designed to handle an error that would cause binlog corruption.  It does this by checking the error for a set of values that it expects and when it finds one it marks the cache to indicate an incident has occurred and this mark keeps it from writing corrupt entries to the binlog.  Unfortunately, during an out-of-space event, there is a lower level error that gets set which is not being overwritten when we set the expected error.  This means that when the code checks for the expected error it is not found - the original lower level error is found.  This diff modifies the checking code to scan through all associated conditions (which is a list of all encountered errors) to see if the expected error is present anywhere in the list.

This diff can be reverted if/when https://bugs.mysql.com/bug.php?id=72457 is resolved upstream.

Reviewed By: hermanlee

Differential Revision: D5021615

fbshipit-source-id: 65bcbc7
  • Loading branch information
jkedgar authored and facebook-github-bot committed May 8, 2017
1 parent 8bae713 commit e29ff14
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions sql/binlog.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3956,15 +3956,22 @@ bool MYSQL_BIN_LOG::check_write_error(THD *thd)
if (!thd->is_error())
DBUG_RETURN(checked);

switch (thd->get_stmt_da()->sql_errno())
{
case ER_TRANS_CACHE_FULL:
case ER_STMT_CACHE_FULL:
case ER_ERROR_ON_WRITE:
case ER_BINLOG_LOGGING_IMPOSSIBLE:
checked= TRUE;
break;
// Check all conditions for one that matches the expected error
const Sql_condition *err;
auto it= thd->get_stmt_da()->sql_conditions();
while ((err= it++) != nullptr && !checked)
{
switch (err->get_sql_errno())
{
case ER_TRANS_CACHE_FULL:
case ER_STMT_CACHE_FULL:
case ER_ERROR_ON_WRITE:
case ER_BINLOG_LOGGING_IMPOSSIBLE:
checked= TRUE;
break;
}
}

DBUG_PRINT("return", ("checked: %s", YESNO(checked)));
DBUG_RETURN(checked);
}
Expand Down

0 comments on commit e29ff14

Please sign in to comment.