• Marko Mäkelä's avatar
    MDEV-14717: Prevent crash-downgrade to earlier MariaDB 10.2 · 980d1bf1
    Marko Mäkelä authored
    A crash-downgrade of a RENAME (or TRUNCATE or table-rebuilding
    ALTER TABLE or OPTIMIZE TABLE) operation to an earlier 10.2 version
    would trigger a debug assertion failure during rollback,
    in trx_roll_pop_top_rec_of_trx(). In a non-debug build, the
    TRX_UNDO_RENAME_TABLE record would be misinterpreted as an
    update_undo log record, and typically the file name would be
    interpreted as DB_TRX_ID,DB_ROLL_PTR,PRIMARY KEY. If a matching
    record would be found, row_undo_mod() would hit ut_error in
    switch (node->rec_type). Typically, ut_a(table2 == NULL) would
    fail when opening the table from SQL.
    
    Because of this, we prevent a crash-downgrade to earlier MariaDB 10.2
    versions by changing the InnoDB redo log format identifier to the
    10.3 identifier, and by introducing a subformat identifier so that
    10.2 can continue to refuse crash-downgrade from 10.3 or later.
    After a clean shutdown, a downgrade to MariaDB 10.2.13 or later would
    still be possible thanks to MDEV-14909. A downgrade to older 10.2
    versions is only possible after removing the log files (not recommended).
    
    LOG_HEADER_FORMAT_CURRENT: Change to 103 (originally the 10.3 format).
    
    log_group_t: Add subformat. For 10.2, we will use subformat 1,
    and will refuse crash recovery from any other subformat of the
    10.3 format, that is, a genuine 10.3 redo log.
    
    recv_find_max_checkpoint(): Allow startup after clean shutdown
    from a future LOG_HEADER_FORMAT_10_4 (unencrypted only).
    We cannot handle the encrypted 10.4 redo log block format,
    which was introduced in MDEV-12041. Allow crash recovery from
    the original 10.2 format as well as the new format.
    In Mariabackup --backup, do not allow any startup from 10.3 or 10.4
    redo logs.
    
    recv_recovery_from_checkpoint_start(): Skip redo log apply for
    clean 10.3 redo log, but not for the new 10.2 redo log
    (10.3 format, subformat 1).
    
    srv_prepare_to_delete_redo_log_files(): On format or subformat
    mismatch, set srv_log_file_size = 0, so that we will display the
    correct message.
    
    innobase_start_or_create_for_mysql(): Check for format or subformat
    mismatch.
    
    xtrabackup_backup_func(): Remove debug assertions that were made
    redundant by the code changes in recv_find_max_checkpoint().
    980d1bf1
xtrabackup.cc 174 KB