• Marko Mäkelä's avatar
    MDEV-28870 InnoDB: Missing FILE_CREATE, FILE_DELETE or FILE_MODIFY before FILE_CHECKPOINT · 2e43af69
    Marko Mäkelä authored
    There was a race condition between log_checkpoint_low() and
    deleting or renaming data files. The scenario is as follows:
    
    1. The buffer pool does not contain dirty pages.
    2. A FILE_DELETE or FILE_RENAME record is written.
    3. The checkpoint LSN will be moved ahead of the write of the record.
    4. The server is killed before the file is actually renamed or deleted.
    
    We will prevent this race condition by ensuring that a log checkpoint
    cannot occur between the durable write and the file system operation:
    
    1. Durably write the FILE_DELETE or FILE_RENAME record.
    2. Perform the file system operation.
    3. Allow any log checkpoint to proceed.
    
    mtr_t::commit_file(): Implement the DELETE or RENAME logic.
    
    fil_delete_tablespace(): Delegate some of the logic to
    mtr_t::commit_file().
    
    fil_space_t::rename(): Delegate some logic to mtr_t::commit_file().
    Remove the debug injection point fil_rename_tablespace_failure_2
    because we do test RENAME failures without any debug injection.
    
    fil_name_write_rename_low(), fil_name_write_rename(): Remove.
    
    Tested by Matthias Leich
    2e43af69
mtr0mtr.cc 43.9 KB