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

Infinite loop on SET GLOBAL innodb_log_archive=ON

    XMLWordPrintable

Details

    • Can result in hang or crash
    • Q3/2026 Server Development

    Description

      A test that is being introduced by MDEV-39061 would time out due to an infinite loop. Initially, I was unable to reproduce it on my system. Adding more concurrency helped to delay a log checkpoint sufficiently:

      MTR_TESTCASE_TIMEOUT=1 mysql-test/mtr --repeat=15 --parallel=40 mariabackup.huge_lsn,SERVER,strict_full_crc32{,,,,,,,}{,,,,}
      

      This would allow the test to fail in my development environment, where nproc reports 24:

      mariabackup.huge_lsn 'SERVER,strict_full_crc32' w20 [ 9 pass ]  13969
      mariabackup.huge_lsn 'SERVER,strict_full_crc32' w3 [ 8 pass ]  14219
      mariabackup.huge_lsn 'SERVER,strict_full_crc32' w39 [ fail ]  timeout after 60 seconds
      

      With some added logging, I figured out the problem. The fix is quite simple: When we wait for a log checkpoint, we must wait for it to be not behind the latest sampled LSN. On one code path, which matches the test case, we are subtracting from the wait_lsn before waiting, causing buf_flush_wait(wait_lsn, false) to be a no-op (no checkpoint executed, even though there are some dirty pages):

      diff --git a/storage/innobase/log/log0log.cc b/storage/innobase/log/log0log.cc
      index ee8d43a68e5..c8aa06b02dc 100644
      --- a/storage/innobase/log/log0log.cc
      +++ b/storage/innobase/log/log0log.cc
      @@ -811,14 +811,15 @@ void log_t::set_archive(my_bool archive, THD *thd) noexcept
       
           if (archive)
           {
      -      wait_lsn-= (wait_lsn - first_lsn) % capacity();
      +      const lsn_t limit{wait_lsn - (wait_lsn - first_lsn) % capacity()};
             /* We are in innodb_log_archive=OFF. If the file has wrapped
             around between the checkpoint and the current position, we must
             wait for a log checkpoint not before the desired first_lsn of
             our innodb_log_archive=ON log file, because that format does not
             allow any wrap-around. */
      -      if (checkpoint < wait_lsn)
      +      if (checkpoint < limit)
               goto retry_after_checkpoint;
      +      wait_lsn= limit;
           }
           else if (circular_recovery_from_sequence_bit_0)
           {
      

      Attachments

        Issue Links

          Activity

            People

              thiru Thirunarayanan Balathandayuthapani
              marko Marko Mäkelä
              Marko Mäkelä Marko Mäkelä
              Thirunarayanan Balathandayuthapani Thirunarayanan Balathandayuthapani
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Time Tracking

                  Estimated:
                  Original Estimate - 3.3h Original Estimate - 3.3h
                  3.3h
                  Remaining:
                  Time Spent - 4.25h Remaining Estimate - 3.3h
                  3.3h
                  Logged:
                  Time Spent - 4.25h Remaining Estimate - 3.3h
                  4.25h

                  Git Integration

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