Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-40544

Assertion fail / Memory leak in `mariadb-binlog --force-read`

    XMLWordPrintable

Details

    Description

      Code Analysis

      Log_event::read_log_event(IO_CACHE*, ...) has an assertion saying that error cases should not generate an event:

        if (unlikely(error))
        {
          DBUG_ASSERT(!res);
      


      But a checksum error in Log_event::read_log_event(const uchar *buf, ...) outputs both an error message and, under --force-read, an Unknown_log_event substitute.

      MDEV-35643's explicit refute of TRANSACTION_PAYLOAD_EVENT and PARTIAL_UPDATE_ROWS_EVENT events also have the same problematic code pattern.
      (This means a perfectly valid MySQL binlog can trigger this bug.)

      On non-debug (release) builds that don't include assertions, the snippet immediately after this assertion ends the function without cleaning up the unexpected Unknown_log_event, which is a memory leak.

          if (force_opt)
            DBUG_RETURN(new Unknown_log_event());
      

      MTR Reproduction

      --source include/have_debug.inc
      --source include/have_binlog_format_mixed.inc # format-agnostic
      RESET MASTER;
      FLUSH BINARY LOGS;
       
      --let $MYSQLD_DATADIR= `SELECT @@datadir`
      --echo #MYSQL_BINLOG --verify-binlog-checksum --force-read --debug=d,simulate_checksum_test_failure #MYSQLD_DATADIR/master-bin.000001 2>&1
      --exec $MYSQL_BINLOG --verify-binlog-checksum --force-read --debug=d,simulate_checksum_test_failure $MYSQLD_DATADIR/master-bin.000001 2>&1
      

      Fix Recommendation

      Since --force-read is defined as "output invalid events as 'Unknown event's rather than error", the conditions above should output an Unknown_log_event but not an error.

      Attachments

        Issue Links

          Activity

            People

              ParadoxV5 Jimmy Hú
              ParadoxV5 Jimmy Hú
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - 1d
                  1d
                  Remaining:
                  Time Spent - 1h Remaining Estimate - 7h
                  7h
                  Logged:
                  Time Spent - 1h Remaining Estimate - 7h
                  1h

                  Git Integration

                    Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.