[MDEV-31333] fsp_free_page() fails to move the extent from FSP_FREE_FRAG to FSP_FREE list Created: 2023-05-24  Updated: 2023-07-26  Resolved: 2023-05-24

Status: Closed
Project: MariaDB Server
Component/s: Storage Engine - InnoDB
Affects Version/s: 10.6.9, 10.9.2, 10.6, 10.7, 10.8, 10.9, 10.10, 10.11, 11.0
Fix Version/s: 10.6.15, 10.9.8, 10.10.6, 10.11.5, 11.1.2

Type: Bug Priority: Major
Reporter: Thirunarayanan Balathandayuthapani Assignee: Thirunarayanan Balathandayuthapani
Resolution: Fixed Votes: 0
Labels: None

Issue Links:
Problem/Incident
is caused by MDEV-13542 Crashing on a corrupted page is unhel... Closed

 Description   

InnoDB should set the XDES_FREE_BIT of the page before checking whether the
current extent is free.

        if (!xdes_get_n_used(descr)) {
                /* The extent has become free: move it to another list */
                err = flst_remove(header, FSP_HEADER_OFFSET + FSP_FREE_FRAG,
                                  xdes, xoffset, mtr);
                if (UNIV_UNLIKELY(err != DB_SUCCESS)) {
                        return err;
                }
                err = fsp_free_extent(space, offset, mtr);
                if (UNIV_UNLIKELY(err != DB_SUCCESS)) {
                        return err;
                }
        }
 
        mtr->free(*space, static_cast<uint32_t>(offset));
        xdes_set_free<true>(*xdes, descr, offset % FSP_EXTENT_SIZE, mtr);

This issue was caused in 10.6 by the following patch:

commit 0b47c126e31cddda1e94588799599e138400bcf8
Author: Marko Mäkelä <marko.makela@mariadb.com>
Date:   Mon Jun 6 14:03:22 2022 +0300
 
    MDEV-13542: Crashing on corrupted page is unhelpful



 Comments   
Comment by Thirunarayanan Balathandayuthapani [ 2023-05-24 ]

Patch is in bb-10.6-MDEV-31333

Comment by Marko Mäkelä [ 2023-05-24 ]

OK to push. Thank you for catching this.

I understand that writing a test case for this is tricky. We will cover this in MDEV-14795, which is where you found this regression.

Comment by Thirunarayanan Balathandayuthapani [ 2023-07-26 ]

Even though the extent is completely free, InnoDB fails to add the extent into FSP_FREE list. Extent doesn't get leaked in the tablespace.
Subsequent user actions could make use of the freed extent in FSP_FREE_FRAG List. User won't get affected by this issue.

Generated at Thu Feb 08 10:23:03 UTC 2024 using Jira 8.20.16#820016-sha1:9d11dbea5f4be3d4cc21f03a88dd11d8c8687422.