Details

    Description

      When a InnoDB data file page is freed, its contents becomes garbage, and any storage allocated in the data file is wasted.

      MariaDB 10.4 introduced an InnoDB redo log record MLOG_INIT_FREE_PAGE for marking pages as freed. In MDEV-12353 (MariaDB 10.5.2), that record was replaced with FREE_PAGE. This record could be treated as no-op, or we can punch a hole for page_compressed=1 tables.

      If innodb_immediate_scrub_data_uncompressed is set, we should initialize the page with zeros. This will replace some of the non-working scrubbing logic (MDEV-8139). The scrubbing will be fixed further in MDEV-8139.

      The following parameters will be deprecated and ignored and the problematic ‘background scrubbing’ code removed:

      • innodb-background-scrub-data-uncompressed
      • innodb-background-scrub-data-compressed
      • innodb-background-scrub-data-interval
      • innodb-background-scrub-data-check-interval

      For page_compressed tables the freed page will be hole-punched

      Attachments

        Issue Links

          Activity

            MariaDB 10.4.3 will introduce a MLOG_INIT_FREE_PAGE record for this purpose. This allows this bug to be fixed in MariaDB 10.4 later without breaking crash-downgrade to earlier MariaDB 10.4 versions.

            In MDEV-12699, MLOG_INIT_FREE_PAGE should be handled in a similar way as the existing record MLOG_INIT_FILE_PAGE2.

            marko Marko Mäkelä added a comment - MariaDB 10.4.3 will introduce a MLOG_INIT_FREE_PAGE record for this purpose. This allows this bug to be fixed in MariaDB 10.4 later without breaking crash-downgrade to earlier MariaDB 10.4 versions. In MDEV-12699 , MLOG_INIT_FREE_PAGE should be handled in a similar way as the existing record MLOG_INIT_FILE_PAGE2 .

            I think that this is realistic to do in the 10.4 time frame. Assigning to myself, because this is closely related to MDEV-12699, which I am working on.

            marko Marko Mäkelä added a comment - I think that this is realistic to do in the 10.4 time frame. Assigning to myself, because this is closely related to MDEV-12699 , which I am working on.

            When scrubbing is not enabled and the page is not on SSD and the file is not page_compressed, we can discard the page from the buf_pool->flush_list once the MLOG_INIT_FREE_PAGE record has been written. For scrubbing, it is kind of mandatory to initialize the page.

            For non-compressed tables on SSD, we will have to evaluate whether punching holes is going to improve or hurt performance on the average.

            marko Marko Mäkelä added a comment - When scrubbing is not enabled and the page is not on SSD and the file is not page_compressed , we can discard the page from the buf_pool->flush_list once the MLOG_INIT_FREE_PAGE record has been written. For scrubbing, it is kind of mandatory to initialize the page. For non-compressed tables on SSD, we will have to evaluate whether punching holes is going to improve or hurt performance on the average.

            As part of this, we should simplify the freeing of B-tree root pages:

            diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc
            index 753ed9b077c..21609edb7f3 100644
            --- a/storage/innobase/btr/btr0btr.cc
            +++ b/storage/innobase/btr/btr0btr.cc
            @@ -961,12 +961,9 @@ constexpr index_id_t	BTR_FREED_INDEX_ID = 0;
             
             /** Free a B-tree root page. btr_free_but_not_root() must already
             have been called.
            -In a persistent tablespace, the caller must invoke fsp_init_file_page()
            -before mtr.commit().
             @param[in,out]	block		index root page
            -@param[in,out]	mtr		mini-transaction
            -@param[in]	invalidate	whether to invalidate PAGE_INDEX_ID */
            -static void btr_free_root(buf_block_t *block, mtr_t *mtr, bool invalidate)
            +@param[in,out]	mtr		mini-transaction */
            +static void btr_free_root(buf_block_t *block, mtr_t *mtr)
             {
               ut_ad(mtr_memo_contains_flagged(mtr, block,
             				  MTR_MEMO_PAGE_X_FIX | MTR_MEMO_PAGE_SX_FIX));
            

            (Obviously, also the code inside if (invalidate) should be removed and the callers be adjusted.)
            We should ensure that MLOG_INIT_FREE_PAGE records will be emitted by fseg_free_step(), and thus no log needs to be written in this function.

            marko Marko Mäkelä added a comment - As part of this, we should simplify the freeing of B-tree root pages: diff --git a/storage/innobase/btr/btr0btr.cc b/storage/innobase/btr/btr0btr.cc index 753ed9b077c..21609edb7f3 100644 --- a/storage/innobase/btr/btr0btr.cc +++ b/storage/innobase/btr/btr0btr.cc @@ -961,12 +961,9 @@ constexpr index_id_t BTR_FREED_INDEX_ID = 0; /** Free a B-tree root page. btr_free_but_not_root() must already have been called. -In a persistent tablespace, the caller must invoke fsp_init_file_page() -before mtr.commit(). @param[in,out] block index root page -@param[in,out] mtr mini-transaction -@param[in] invalidate whether to invalidate PAGE_INDEX_ID */ -static void btr_free_root(buf_block_t *block, mtr_t *mtr, bool invalidate) +@param[in,out] mtr mini-transaction */ +static void btr_free_root(buf_block_t *block, mtr_t *mtr) { ut_ad(mtr_memo_contains_flagged(mtr, block, MTR_MEMO_PAGE_X_FIX | MTR_MEMO_PAGE_SX_FIX)); (Obviously, also the code inside if (invalidate) should be removed and the callers be adjusted.) We should ensure that MLOG_INIT_FREE_PAGE records will be emitted by fseg_free_step() , and thus no log needs to be written in this function.

            This looks OK to me, after addressing my feedback for commit 1 of 2. We will address the following later, ideally before the 10.5 GA release:

            • clean up btr_free_root() as I suggested in my previous comment
            • address the FIXME comments in buf_page_free() by introducing a data structure that covers freed page ranges also for pages that are not in the buffer pool, and enable the scrubbing tests (MDEV-8139)
            marko Marko Mäkelä added a comment - This looks OK to me, after addressing my feedback for commit 1 of 2 . We will address the following later, ideally before the 10.5 GA release: clean up btr_free_root() as I suggested in my previous comment address the FIXME comments in buf_page_free() by introducing a data structure that covers freed page ranges also for pages that are not in the buffer pool, and enable the scrubbing tests ( MDEV-8139 )

            commit a5584b13d1e04f38b843602413669591aa65c359 (HEAD -> 10.5, origin/10.5, 10.5-work)
            Author: Thirunarayanan Balathandayuthapani <thiru@mariadb.com>
            Date:   Tue Mar 10 10:47:24 2020 +0530
             
            commit a35b4ae89871d8184f04abb112c385481d557dbb
            Author: Thirunarayanan Balathandayuthapani <thiru@mariadb.com>
            Date:   Mon Mar 9 13:25:33 2020 +0530
             
                MDEV-15528 Punch holes when pages are freed
            

            Patch has been pushed to 10.5. Thanks to marko and @matthias.leich for testing abd reviewing it

            thiru Thirunarayanan Balathandayuthapani added a comment - commit a5584b13d1e04f38b843602413669591aa65c359 (HEAD -> 10.5, origin/10.5, 10.5-work) Author: Thirunarayanan Balathandayuthapani <thiru@mariadb.com> Date: Tue Mar 10 10:47:24 2020 +0530   commit a35b4ae89871d8184f04abb112c385481d557dbb Author: Thirunarayanan Balathandayuthapani <thiru@mariadb.com> Date: Mon Mar 9 13:25:33 2020 +0530   MDEV-15528 Punch holes when pages are freed Patch has been pushed to 10.5. Thanks to marko and @matthias.leich for testing abd reviewing it

            People

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