Skip to content

Commit

Permalink
MDEV-35806: Error in read_log_event() corrupts relay log writer, cras…
Browse files Browse the repository at this point in the history
…hes server

In Log_event::read_log_event(), don't use IO_CACHE::error of the relay log's
IO_CACHE to signal an error back to the caller. When reading the active
relay log, this flag is also being used by the IO thread, and setting it can
randomly cause the IO thread to wrongly detect IO error on writing and
permanently disable the relay log.

This was seen sporadically in test case rpl.rpl_from_mysql80. The read
error set by the SQL thread in the IO_CACHE would be interpreted as a
write error by the IO thread, which would cause it to throw a fatal
error and close the relay log. And this would later cause CHANGE
MASTER to try to purge a closed relay log, resulting in nullptr crash.

SQL thread is not able to parse an event read from the relay log. This
can happen like here when replicating unknown events from a MySQL master,
potentially also for other reasons.

Also fix a mistake in my_b_flush_io_cache() introduced back in 2001
(fa09f2c) where my_b_flush_io_cache() could wrongly return an error set
in IO_CACHE::error, even if the flush operation itself succeeded.

Also fix another sporadic failure in rpl.rpl_from_mysql80 where the outout
of MASTER_POS_WAIT() depended on timing of SQL and IO thread.

Reviewed-by: Monty <[email protected]>
Signed-off-by: Kristian Nielsen <[email protected]>
  • Loading branch information
knielsen committed Jan 21, 2025
1 parent 28524f7 commit 844dcc9
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
2 changes: 1 addition & 1 deletion mysys/mf_iocache.c
Original file line number Diff line number Diff line change
Expand Up @@ -1735,7 +1735,7 @@ int my_b_flush_io_cache(IO_CACHE *info, int need_append_buffer_lock)
info->write_pos= info->write_buffer;
++info->disk_writes;
UNLOCK_APPEND_BUFFER;
DBUG_RETURN(info->error);
DBUG_RETURN(0);
}
}
UNLOCK_APPEND_BUFFER;
Expand Down
7 changes: 0 additions & 7 deletions sql/log.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5390,13 +5390,6 @@ int MYSQL_BIN_LOG::new_file_impl()
DBUG_RETURN(error);
}

if (log_file.error)
{
my_error(ER_SLAVE_RELAY_LOG_WRITE_FAILURE, MYF(ME_ERROR_LOG),
"Writing to the relay log prevented by an earlier error");
DBUG_RETURN(1);
}

mysql_mutex_lock(&LOCK_index);

/* Reuse old name if not binlog and not update log */
Expand Down

0 comments on commit 844dcc9

Please sign in to comment.