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

Race condition on log checkpoint

    XMLWordPrintable

    Details

      Description

      This was found while testing MDEV-13542.

      mysqld: /data/Server/bb-10.6-MDEV-13542L/storage/innobase/buf/buf0flu.cc:175: void buf_pool_t::insert_into_flush_list(buf_block_t*, lsn_t): Assertion `((&(&log_sys.flush_order_mutex)->m_mutex)->count > 0 && pthread_equal(pthread_self(), (&(&log_sys.flush_order_mutex)->m_mutex)->thread))' failed.
      

      The corresponding source code is:

      void buf_pool_t::insert_into_flush_list(buf_block_t *block, lsn_t lsn)
      {
        mysql_mutex_assert_not_owner(&mutex);
        mysql_mutex_assert_owner(&log_sys.flush_order_mutex);
      

      The assertion fails, because log_sys.flush_order_mutex is not being held, even though it is supposed to be.

      This could lead to incorrect log checkpoints being written, that is, invalid crash recovery or backup. The fix is simple:

      diff --git a/storage/innobase/mtr/mtr0mtr.cc b/storage/innobase/mtr/mtr0mtr.cc
      index 2feb5a0583f..f13b677742b 100644
      --- a/storage/innobase/mtr/mtr0mtr.cc
      +++ b/storage/innobase/mtr/mtr0mtr.cc
      @@ -1263,4 +1263,6 @@ void mtr_t::modify(const buf_block_t &block)
         }
         iteration.functor.found->type= static_cast<mtr_memo_type_t>
           (iteration.functor.found->type | MTR_MEMO_MODIFY);
      +  if (is_block_dirtied(&block))
      +    m_made_dirty= true;
       }
      

      The flag mtr_t::m_made_dirty will inform mtr_t::commit() to acquire the mutex.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              marko Marko Mäkelä
              Reporter:
              marko Marko Mäkelä
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Git Integration

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