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

ibuf_bitmap_mutex is an unnecessary contention point

Details

    Description

      The only purpose of ibuf_bitmap_mutex is to prevent a deadlock between two concurrent invocations of ibuf_update_free_bits_for_two_pages_low(a,b,mtr1) and ibuf_update_free_bits_for_two_pages_low(b,a,mtr2). The mutex is unnecessarily serializing the execution of the function. To avoid deadlocks, the following should suffice:

        /* Avoid a deadlock by acquiring multiple bitmap page latches in
        a consistent order (smaller page identifier first). */
        if (block1->page.id() > block2->page.id())
          std::swap(block1, block2);
       
        ibuf_set_free_bits_low(block1, ibuf_index_page_calc_free(block1), mtr);
        ibuf_set_free_bits_low(block2, ibuf_index_page_calc_free(block2), mtr);
      

      Attachments

        Activity

          It occurred to me that we can compare the pointers directly. What matters is that every code path that could acquire and hold multiple change buffer bitmap page latches will acquire them in a deterministic order.

            if (block1 > block2)
              std::swap(block1, block2);
          

          I think that most of the time we would have block1 == block2. Exclusive page latches can be acquired recursively.

          marko Marko Mäkelä added a comment - It occurred to me that we can compare the pointers directly. What matters is that every code path that could acquire and hold multiple change buffer bitmap page latches will acquire them in a deterministic order. if (block1 > block2) std::swap(block1, block2); I think that most of the time we would have block1 == block2 . Exclusive page latches can be acquired recursively.

          origin/bb-10.6-MDEV-28369 2d436f3541c5acb8f5808436f7913e80f2937f1f 2022-04-20T14:16:46+03:00
          performed well in RQG testing.

          mleich Matthias Leich added a comment - origin/bb-10.6- MDEV-28369 2d436f3541c5acb8f5808436f7913e80f2937f1f 2022-04-20T14:16:46+03:00 performed well in RQG testing.

          People

            marko Marko Mäkelä
            marko Marko Mäkelä
            Votes:
            0 Vote for this issue
            Watchers:
            2 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.