Bug #96827 mysqlbinlog needs options to abort if invalid events are found on in-use binlogs
Submitted: 11 Sep 0:24 Modified: 11 Sep 6:23
Reporter: Yoshinori Matsunobu (OCA) Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:5.6, 8.0.17, 5.6.45, 5.7.27 OS:Any
Assigned to: CPU Architecture:Any
Tags: mysqlbinlog

[11 Sep 0:24] Yoshinori Matsunobu
Description:
If mysqlbinlog finds a corrupted binlog event (e.g. binlog event checksum failure), it aborts if the binlog file was properly closed. However, it silently exits with exit code 0 if the corrupted event was found on the active (marked as LOG_EVENT_BINLOG_IN_USE_F) binlog files.

But in some cases, we may want to know if binlog files have corrupted events on in-use (not properly closed) binlog files as well, rather than silently ignoring errors.

Why not adding a command line argument to control whether to ignore event errors on in-use binlog files?

How to repeat:
Generate binary logs with binlog checksum enabled. Edit the newest (opened) binary log and edit some events (e.g. changing table name in table_map log event). Run mysqlbinlog --verify-binlog-checksum to see if errors are printed and check exit code.

5.6:  mysqlbinlog prints "Event crc check failed! Most likely there is event corruption." on event checksum error, but it exits with 0.

    Log_event* ev = Log_event::read_log_event(file, glob_description_event,
                                              opt_verify_binlog_checksum);
    if (!ev)
    {
      /*
        if binlog wasn't closed properly ("in use" flag is set) don't complain
        about a corruption, but treat it as EOF and move to the next binlog.
      */
      if (glob_description_event->flags & LOG_EVENT_BINLOG_IN_USE_F)
        file->error= 0;

8.0.17  mysqlbinlog does not print anything on event checksum error, and exits with 0.

    Log_event *ev = mysqlbinlog_file_reader.read_event_object();
    if (ev == NULL) {
      /*
        if binlog wasn't closed properly ("in use" flag is set) don't complain
        about a corruption, but treat it as EOF and move to the next binlog.
      */
      if ((mysqlbinlog_file_reader.format_description_event()->header()->flags &
           LOG_EVENT_BINLOG_IN_USE_F) ||
          mysqlbinlog_file_reader.get_error_type() ==
              Binlog_read_error::READ_EOF)
        goto end;

Suggested fix:
Adding a new command line argument in mysqlbinlog to control whether to ignore event errors on in-use binlog files.
[11 Sep 6:23] Umesh Shastry
Hello Yoshinori,

Thank you for the report.
Verified as described.

regards,
Umesh