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

Simply testing if binary logging is enabled

    XMLWordPrintable

Details

    • Bug
    • Status: In Progress (View Workflow)
    • Major
    • Resolution: Unresolved
    • None
    • 13.0
    • None
    • None
    • Q2/2026 Galera Maintenance

    Description

      In the MariaDB server most of the code uses different expressions to
      test if binary logging should be done for the current query.

      In many cases the current code does a lot of not needed work before
      noticing that binary logging is not needed, which affects performance.

      There is also a lot of different variables that affects if binary logging
      should be used:

      • (thd->variables.option_bits & OPTION_BIN_LOG)
      • (thd->variables.option_bits & OPTION_BIN_TMP_LOG_OFF)
      • WSREP(thd) && wsrep_emulate_bin_log && WSREP_PROVIDER_EXISTS_
      • mysql_bin_log.is_open()
      • xxx_binlog_local_stmt_filter()
      • binlog_filter
      • thd->variables.sql_log_bin

      The goal is to move all states to a single variable (for performance,
      simplicity and easier debugging). We should ignore all possible
      extra work if binary logging is not needed for a particular query.

      In most cases we can now use one the following functions to check if
      we binary logging is needed. We need different version to be able
      to shortcut code if binary logging is not enabled (with different
      code paths if Galera is enabled or not).

      • binlog_ready()
      • binlog_ready_with_wsrep()
      • binlog_ready_no_wsrep()
      • binlog_ready_precheck()
      • binlog_ready_later()

      The state of binary logging is stored in thd->binlog_state.
      There are a few bits that shows why binary logging is needed and
      one bit for every different reasons for disabling binary logging.
      By printing this variable (gdb prints all bits with there enum name)
      one can exactly see why binary logging is not happening.

      The initial bits are set in THD::THD() and THD::init() and verified in
      THD::decide_logging_format().

      In the current patch all testing of OPTION_BIN_LOG and most testing of
      mysql_bin_log.is_open() is removed.
      We should over time remove all testing of mysql_bin_log.is_open() from the
      main code, except in binlog commit, as the value can change 'anytime' if
      binlog rotation fails, which is very likely to result in crashes.
      (The patch fixes some of these).

      Attachments

        Issue Links

          Activity

            People

              seppo Seppo Jaakola
              monty Michael Widenius
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Git Integration

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