MDEV-14795 InnoDB system tablespace cannot be shrunk
- Introduce the option :autoshrink attribute to be added to innodb_data_file_path variable to allow the shrinking of system tablespace during startup process. Steps for shrinking the system tablespace: 1) Find the last used extent in system tablespace by iterating through the BITMAP in extent descriptor pages 2) If the last used extent is lesser than user specified size then set desired target size to user specified size. 3) Store the page contents of "to be modified" extent descriptor pages, latches the "to be modified" extent descriptor pages and check for buffer pool memory availability 4) Make checkpoint to flush all pages in buffer pool, so that pages in flush list doesn't have to use doublewrite buffer and disable doublewrite buffer during shrinking process 5) Update the FSP_SIZE and FSP_FREE_LIMIT in header page 6) Remove the "to be truncated" pages from FSP_FREE and FSP_FREE_FRAG list 7) Reset the bitmap in the last descriptor pages for the "to be truncated" pages. 8) In case of multiple files, calculate the truncated last file size and do the truncation in last file 9) Check whether mini-transaction log size doesn't exceed the minimum value of innodb_log_buffer_size which is 2MB. In that case, replace the modified buffer pool pages with the page old content. 11) Commit the mini-transaction for shrinking the tablespace and enable/disable the doublewrite buffer depends on user specified value. recv_sys_t::apply(): Handle the truncation of system tablespace only if the recovered tablespace size is lesser than actual existing size.
Showing
Please register or sign in to comment