• Marko Mäkelä's avatar
    MDEV-21069 Crash on DROP TABLE if the data file is corrupted · b80df9eb
    Marko Mäkelä authored
    buf_read_ibuf_merge_pages(): Discard any page numbers that are
    outside the current bounds of the tablespace, by invoking the
    function ibuf_delete_recs() that was introduced in MDEV-20934.
    This could avoid an infinite change buffer merge loop on
    innodb_fast_shutdown=0, because normally the change buffer merge
    would only be attempted if a page was successfully loaded into
    the buffer pool.
    
    dict_drop_index_tree(): Add the parameter trx_t*.
    To prevent the DROP TABLE crash, do not invoke btr_free_if_exists()
    if the entire .ibd file will be dropped. Thus, we will avoid a crash
    if the BTR_SEG_LEAF or BTR_SEG_TOP of the index is corrupted,
    and we will also avoid unnecessarily accessing the to-be-dropped
    tablespace via the buffer pool.
    
    In MariaDB 10.2, we disable the DROP TABLE fix if innodb_safe_truncate=0,
    because the backup-unsafe MySQL 5.7 WL#6501 form of TRUNCATE TABLE
    requires that the individual pages be freed inside the tablespace.
    b80df9eb
ibuf0ibuf.cc 140 KB