• Marko Mäkelä's avatar
    MDEV-16283 ALTER TABLE...DISCARD TABLESPACE still takes long on a large buffer pool · 6aa50bad
    Marko Mäkelä authored
    Also fixes MDEV-14727, MDEV-14491
    InnoDB: Error: Waited for 5 secs for hash index ref_count (1) to drop to 0
    by replacing the flawed wait logic in dict_index_remove_from_cache_low().
    
    On DISCARD TABLESPACE, there is no need to drop the adaptive hash index.
    We must drop it on IMPORT TABLESPACE, and eventually on DROP TABLE or
    DROP INDEX. As long as the dict_index_t object remains in the cache
    and the table remains inaccessible, the adaptive hash index entries
    to orphaned pages would not do any harm. They would be dropped when
    buffer pool pages are reused for something else.
    
    btr_search_drop_page_hash_when_freed(), buf_LRU_drop_page_hash_batch():
    Remove the parameter zip_size, and pass 0 to buf_page_get_gen().
    
    buf_page_get_gen(): Ignore zip_size if mode==BUF_PEEK_IF_IN_POOL.
    
    buf_LRU_drop_page_hash_for_tablespace(): Drop the adaptive hash index
    even if the tablespace is inaccessible.
    
    buf_LRU_drop_page_hash_for_tablespace(): New global function, to drop
    the adaptive hash index.
    
    buf_LRU_flush_or_remove_pages(), fil_delete_tablespace():
    Remove the parameter drop_ahi.
    
    dict_index_remove_from_cache_low(): Actively drop the adaptive hash index
    if entries exist. This should prevent InnoDB hangs on DROP TABLE or
    DROP INDEX.
    
    row_import_for_mysql(): Drop any adaptive hash index entries for the table.
    
    row_drop_table_for_mysql(): Drop any adaptive hash index for the table,
    except if the table resides in the system tablespace. (DISCARD TABLESPACE
    does not apply to the system tablespace, and we do no want to drop the
    adaptive hash index for other tables than the one that is being dropped.)
    
    row_truncate_table_for_mysql(): Drop any adaptive hash index entries for
    the table, except if the table resides in the system tablespace.
    6aa50bad
fil0fil.cc 177 KB