• Marko Mäkelä's avatar
    MDEV-11623 MariaDB 10.1 fails to start datadir created with · ab1e6fef
    Marko Mäkelä authored
    MariaDB 10.0/MySQL 5.6 using innodb-page-size!=16K
    
    The storage format of FSP_SPACE_FLAGS was accidentally broken
    already in MariaDB 10.1.0. This fix is bringing the format in
    line with other MySQL and MariaDB release series.
    
    Please refer to the comments that were added to fsp0fsp.h
    for details.
    
    This is an INCOMPATIBLE CHANGE that affects users of
    page_compression and non-default innodb_page_size. Upgrading
    to this release will correct the flags in the data files.
    If you want to downgrade to earlier MariaDB 10.1.x, please refer
    to the test innodb.101_compatibility how to reset the
    FSP_SPACE_FLAGS in the files.
    
    NOTE: MariaDB 10.1.0 to 10.1.20 can misinterpret
    uncompressed data files with innodb_page_size=4k or 64k as
    compressed innodb_page_size=16k files, and then probably fail
    when trying to access the pages. See the comments in the
    function fsp_flags_convert_from_101() for detailed analysis.
    
    Move PAGE_COMPRESSION to FSP_SPACE_FLAGS bit position 16.
    In this way, compressed innodb_page_size=16k tablespaces will not
    be mistaken for uncompressed ones by MariaDB 10.1.0 to 10.1.20.
    
    Derive PAGE_COMPRESSION_LEVEL, ATOMIC_WRITES and DATA_DIR from the
    dict_table_t::flags when the table is available, in
    fil_space_for_table_exists_in_mem() or fil_open_single_table_tablespace().
    During crash recovery, fil_load_single_table_tablespace() will use
    innodb_compression_level for the PAGE_COMPRESSION_LEVEL.
    
    FSP_FLAGS_MEM_MASK: A bitmap of the memory-only fil_space_t::flags
    that are not to be written to FSP_SPACE_FLAGS. Currently, these will
    include PAGE_COMPRESSION_LEVEL, ATOMIC_WRITES and DATA_DIR.
    
    Introduce the macro FSP_FLAGS_PAGE_SSIZE(). We only support
    one innodb_page_size for the whole instance.
    
    When creating a dummy tablespace for the redo log, use
    fil_space_t::flags=0. The flags are never written to the redo log files.
    
    Remove many FSP_FLAGS_SET_ macros.
    
    dict_tf_verify_flags(): Remove. This is basically only duplicating
    the logic of dict_tf_to_fsp_flags(), used in a debug assertion.
    
    fil_space_t::mark: Remove. This flag was not used for anything.
    
    fil_space_for_table_exists_in_mem(): Remove the unnecessary parameter
    mark_space, and add a parameter for table flags. Check that
    fil_space_t::flags match the table flags, and adjust the (memory-only)
    flags based on the table flags.
    
    fil_node_open_file(): Remove some redundant or unreachable conditions,
    do not use stderr for output, and avoid unnecessary server aborts.
    
    fil_user_tablespace_restore_page(): Convert the flags, so that the
    correct page_size will be used when restoring a page from the
    doublewrite buffer.
    
    fil_space_get_page_compressed(), fsp_flags_is_page_compressed(): Remove.
    It suffices to have fil_space_is_page_compressed().
    
    FSP_FLAGS_WIDTH_DATA_DIR, FSP_FLAGS_WIDTH_PAGE_COMPRESSION_LEVEL,
    FSP_FLAGS_WIDTH_ATOMIC_WRITES: Remove, because these flags do not
    exist in the FSP_SPACE_FLAGS but only in memory.
    
    fsp_flags_try_adjust(): New function, to adjust the FSP_SPACE_FLAGS
    in page 0. Called by fil_open_single_table_tablespace(),
    fil_space_for_table_exists_in_mem(), innobase_start_or_create_for_mysql()
    except if --innodb-read-only is active.
    
    fsp_flags_is_valid(ulint): Reimplement from the scratch, with
    accurate comments. Do not display any details of detected
    inconsistencies, because the output could be confusing when
    dealing with MariaDB 10.1.x data files.
    
    fsp_flags_convert_from_101(ulint): Convert flags from buggy
    MariaDB 10.1.x format, or return ULINT_UNDEFINED if the flags
    cannot be in MariaDB 10.1.x format.
    
    fsp_flags_match(): Check the flags when probing files.
    Implemented based on fsp_flags_is_valid()
    and fsp_flags_convert_from_101().
    
    dict_check_tablespaces_and_store_max_id(): Do not access the
    page after committing the mini-transaction.
    
    IMPORT TABLESPACE fixes:
    
    AbstractCallback::init(): Convert the flags.
    
    FetchIndexRootPages::operator(): Check that the tablespace flags match the
    table flags. Do not attempt to convert tablespace flags to table flags,
    because the conversion would necessarily be lossy.
    
    PageConverter::update_header(): Write back the correct flags.
    This takes care of the flags in IMPORT TABLESPACE.
    ab1e6fef
dict0pagecompress.h 2.89 KB