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

Off-by-one condition in log_t::persist()

    XMLWordPrintable

Details

    • Related to performance

    Description

      In the review of MDEV-39770, Gemini pointed out that a condition is off by one. I had changed this condition while implementing MDEV-37949:

      diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc
      index aad4f768f08..af9c1d190f9 100644
      --- a/storage/innobase/log/log0log.cc
      +++ b/storage/innobase/log/log0log.cc
      @@ -1547,7 +1547,7 @@ void log_t::persist(lsn_t lsn) noexcept
       
         lsn_t old= flushed_to_disk_lsn.load(std::memory_order_relaxed);
       
      -  if (old > lsn)
      +  if (old >= lsn)
           return;
       
         ut_ad(is_mmap_writeable());
      

      This only affects the persistent memory code path. If the above patch is applied, the test innodb.log_archive,mmap, which is restarting the server multiple times, would would hit a debug assertion multiple times on server shutdown:

      13.0 7f0ed40ad551e7db7506b5576f00d1435abb4b72

      innodb.log_archive 'mmap'                w1 [ fail ]  Found warnings/errors in server log file!
              Test ended at 2026-05-28 10:27:30
      line
      mariadbd: /mariadb/main/storage/innobase/mtr/mtr0mtr.cc:1317: static void log_t::append(byte*&, const void*, size_t): Assertion `log_sys.is_mmap() ? ((d >= log_sys.buf && d + size <= log_sys.buf + log_sys.file_size) || (log_sys.archive && d >= log_sys.resize_buf && d + size <= log_sys.resize_buf + log_sys.resize_target)) : (d >= log_sys.buf && d + size <= log_sys.buf + log_sys.buf_size)' failed.
      260528 10:27:27 [ERROR] /dev/shm/m/sql/mariadbd got signal 6 ;
      mariadbd: /mariadb/main/storage/innobase/mtr/mtr0mtr.cc:1317: static void log_t::append(byte*&, const void*, size_t): Assertion `log_sys.is_mmap() ? ((d >= log_sys.buf && d + size <= log_sys.buf + log_sys.file_size) || (log_sys.archive && d >= log_sys.resize_buf && d + size <= log_sys.resize_buf + log_sys.resize_target)) : (d >= log_sys.buf && d + size <= log_sys.buf + log_sys.buf_size)' failed.
      260528 10:27:28 [ERROR] /dev/shm/m/sql/mariadbd got signal 6 ;
      ^ Found warnings in /dev/shm/m/mysql-test/var/1/log/mysqld.1.err
      

      It is unclear whether there is any practical performance impact of this. When I implemented the change, I must have thought that it is unlikely. Persistent memory and Linux mount -o dax are not a commonly used configuration. We simulate it when the log file resides in /dev/shm.

      Attachments

        Issue Links

          Activity

            People

              marko Marko Mäkelä
              marko Marko Mäkelä
              Marko Mäkelä Marko Mäkelä
              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.