• Marko Mäkelä's avatar
    MDEV-32027 Opening all .ibd files on InnoDB startup can be slow · eb1f8b29
    Marko Mäkelä authored
    dict_find_max_space_id(): Return SELECT MAX(SPACE) FROM SYS_TABLES.
    
    dict_check_tablespaces_and_store_max_id(): In the normal case
    (no encryption plugin has been loaded and the change buffer is empty),
    invoke dict_find_max_space_id() and do not open any .ibd files.
    If a std::set<uint32_t> has been specified, open the files whose
    tablespace ID is mentioned. Else, open all data files that are identified
    by SYS_TABLES records.
    
    fil_ibd_open(): Remove a call to os_file_get_last_error() that can
    report a misleading error, such as EINVAL inside my_realpath() that is
    not an actual error. This could be invoked when a data file is found
    but the FSP_SPACE_FLAGS are incorrect, such as is the case for
    table test.td in
    ./mtr --mysqld=--innodb-buffer-pool-dump-at-shutdown=0 innodb.table_flags
    
    buf_load(): If any tablespaces could not be found, invoke
    dict_check_tablespaces_and_store_max_id() on the missing tablespaces.
    
    dict_load_tablespace(): Try to load the tablespace unless it was found
    to be futile. This fixes failures related to FTS_*.ibd files for
    FULLTEXT INDEX.
    
    btr_cur_t::search_leaf(): Prevent a crash when the tablespace
    does not exist. This was caught by the test innodb_fts.fts_concurrent_insert
    when the change to dict_load_tablespaces() was not present.
    
    We modify a few tests to ensure that tables will not be loaded at startup.
    For some fault injection tests this means that the corrupted tables
    will not be loaded, because dict_load_tablespace() would perform stricter
    checks than dict_check_tablespaces_and_store_max_id().
    
    Tested by: Matthias Leich
    Reviewed by: Thirunarayanan Balathandayuthapani
    eb1f8b29
restart.opt 147 Bytes