• Marko Mäkelä's avatar
    MDEV-26450: Corruption due to innodb_undo_log_truncate · f5fddae3
    Marko Mäkelä authored
    At least since commit 055a3334
    (MDEV-13564) the undo log truncation in InnoDB did not work correctly.
    
    The main issue is that during the execution of
    trx_purge_truncate_history() some pages of the newly truncated
    undo tablespace could be discarded.
    
    This is improved from commit 1cb218c3
    which was applied to earlier-version branches.
    
    fsp_try_extend_data_file(): Apply the peculiar rounding of
    fil_space_t::size_in_header only to the system tablespace,
    whose size can be expressed in megabytes in a configuration parameter.
    Other files may freely grow by a number of pages.
    
    fseg_alloc_free_page_low(): Do allow the extension of undo tablespaces,
    and mention the file name in the error message.
    
    mtr_t::commit_shrink(): Implement crash-safe shrinking of a tablespace:
    (1) durably write the log
    (2) release the page latches of the rebuilt tablespace
    (3) release the mutexes
    (4) truncate the file
    (5) release the tablespace latch
    This is refactored from trx_purge_truncate_history().
    
    log_write_and_flush_prepare(), log_write_and_flush(): New functions
    to durably write log during mtr_t::commit_shrink().
    f5fddae3
undo_truncate.test 2.12 KB