Skip to content
  • Marko Mäkelä's avatar
    af0acedd
    WL#8845 Implement an InnoDB redo log format version identifier · af0acedd
    Marko Mäkelä authored
    
    
    InnoDB has several times changed its redo log format by introducing
    new redo log record types. Format changes would lead to misleading
    reports of redo log corruption when processing individual redo log
    records.
    
    In the redo log header (start of the ib_logfile0 file), we will introduce
    a format version identifier and textual representation of the software
    version that created the redo log files.
    
    Furthermore, we change the checksum of redo log checkpoint pages, so that
    older versions of MySQL will refuse to start up on redo log files that
    were created with a MySQL server that includes this fix.
    
    We will also remove a number of unused fields from the redo log
    header and checkpoint pages (pages 0, 1, and 3).
    
    Some tests will be expanded, because with this fix,
    the server must refuse to start up with older redo log files,
    unless they are dirty.
    
    We will also replace the configuration parameter
    innodb_log_checksum_algorithm with the Boolean parameter
    innodb_log_checksums.
    We make CRC-32C the only checksum on the InnoDB redo log pages when
    innodb_log_checksums=ON (the default). Checksums on the header page
    and the checkpoint pages are never disabled.
    
    innodb_log_checksums_func_update(), innodb_log_checksums_update():
    Update triggers for the new global Boolean variable innodb_log_checksums.
    
    innodb_log_checksum_func_update(), innodb_log_checksum_algorithm_update():
    Removed along with the global parameter innodb_log_checksum_algorithm.
    
    Removed definitions:
    LOG_MAX_N_GROUPS
    log_group_read_checkpoint_info()
    log_checkpoint_get_nth_group_info()
    log_checkpoint_set_nth_group_info()
    log_block_calc_checksum_innodb()
    log_block_calc_checksum_crc32_legacy_big_endian()
    recv_check_cp_is_consistent()
    log_block_checksum_weak_validation()
    log_block_checksum_what_matches()
    log_block_checksum_fail_fatal()
    log_block_checksum_is_ok_or_old_format()
    LOG_CHECKPOINT_OFFSET_LOW32
    LOG_CHECKPOINT_ARCHIVED_LSN
    LOG_CHECKPOINT_GROUP_ARRAY
    LOG_CHECKPOINT_ARCHIVED_FILE_NO
    LOG_CHECKPOINT_ARCHIVED_OFFSET
    LOG_CHECKPOINT_ARRAY_END
    LOG_CHECKPOINT_CHECKSUM_1
    LOG_CHECKPOINT_CHECKSUM_2
    LOG_CHECKPOINT_FSP_FREE_LIMIT
    LOG_CHECKPOINT_FSP_MAGIC_N
    LOG_CHECKPOINT_FSP_MAGIC_N_VAL
    LOG_CHECKPOINT_OFFSET_HIGH32
    LOG_CHECKPOINT_SIZE
    LOG_GROUP_ID
    LOG_FILE_START_LSN
    LOG_FILE_NO
    LOG_FILE_WAS_CREATED_BY_HOT_BACKUP
    LOG_FILE_ARCH_COMPLETED
    LOG_FILE_END_LSN
    
    Changed definitions:
    LOG_CHECKPOINT_LOG_BUF_SIZE
    
    Added definitions:
    innodb_log_checksums: The current value of the SET GLOBAL variable.
    LOG_CHECKPOINT_OFFSET
    LOG_HEADER_FORMAT (repurposing LOG_GROUP_ID which was always 0)
    LOG_HEADER_PAD1 (unused 4 bytes, zero-initialized)
    LOG_HEADER_START_LSN
    LOG_HEADER_CREATOR (renamed from LOG_FILE_WAS_CREATED_BY_HOT_BACKUP)
    LOG_HEADER_CREATOR_END
    LOG_HEADER_CREATOR_CURRENT
    LOG_HEADER_FORMAT_CURRENT
    log_group_t::format
    
    log_block_calc_checksum_format_0(): Renamed from
    log_block_calc_checksum_innodb(). This is only used when upgrading the
    redo log from non-tagged format.
    
    recv_find_max_checkpoint_0(): New function, used when upgrading the
    redo log from non-tagged format.
    
    recv_log_format_0_recover(): New function, used when upgrading the
    redo log from non-tagged format. Checks if the redo log is clean.
    
    log_group_header_read(): Replaces log_group_read_checkpoint_info().
    Also used for reading the log header page (page 0).
    
    recv_check_log_header_checksum(): Replaces recv_check_cp_is_consistent().
    Also used for checking the log header page (page 0).
    
    log_block_checksum_is_ok(): Checks a log block checksum. It must either
    be CRC-32C, or we must have innodb_log_checksums=OFF.
    
    Changed functions:
    
    log_group_file_header_flush(): Always zero-initialize the buffer
    and initialize all LOG_HEADER_ fields.
    
    log_group_checkpoint(): Zero-initialize the checkpoint buffer,
    and write the checkpoint in the new format, with CRC-32C checksum.
    
    recv_find_max_checkpoint(): Support both the old log format
    (if the old-format redo log is logically empty) and the new format.
    
    recv_scan_log_recs(): Clean up the logic a bit. Display a message
    when encountering (and terminating log parsing due to) invalid
    log blocks. For now, keep the existing behaviour and do not display
    a message about log block header mismatch.
    
    recv_recovery_from_checkpoint_start(): Replace the whole "ibbackup" label.
    Check if a log upgrade or a normal recovery is needed.
    
    srv_prepare_to_delete_redo_log_files(): Display a message about
    upgrading the redo log.
    
    Other changes to startup:
    
    If we are going to upgrade the redo log, we must avoid writing any
    new redo log records before we have replaced the redo log.
    
    dict_check_sys_tablespaces(), dict_check_sys_tables(): Avoid
    updating SYS_DATAFILES if we are going to upgrade the redo log.
    
    dict_create_or_check_sys_virtual(): Do not modify anything if we are
    running in --innodb-read-only or --innodb-force-recovery=6 mode.
    
    RB: 10096
    Reviewed-by: default avatarKevin Lewis <kevin.lewis@oracle.com>
    Reviewed-by: default avatarAnnamalai Gurusami <annamalai.gurusami@oracle.com>
    af0acedd
    WL#8845 Implement an InnoDB redo log format version identifier
    Marko Mäkelä authored
    
    
    InnoDB has several times changed its redo log format by introducing
    new redo log record types. Format changes would lead to misleading
    reports of redo log corruption when processing individual redo log
    records.
    
    In the redo log header (start of the ib_logfile0 file), we will introduce
    a format version identifier and textual representation of the software
    version that created the redo log files.
    
    Furthermore, we change the checksum of redo log checkpoint pages, so that
    older versions of MySQL will refuse to start up on redo log files that
    were created with a MySQL server that includes this fix.
    
    We will also remove a number of unused fields from the redo log
    header and checkpoint pages (pages 0, 1, and 3).
    
    Some tests will be expanded, because with this fix,
    the server must refuse to start up with older redo log files,
    unless they are dirty.
    
    We will also replace the configuration parameter
    innodb_log_checksum_algorithm with the Boolean parameter
    innodb_log_checksums.
    We make CRC-32C the only checksum on the InnoDB redo log pages when
    innodb_log_checksums=ON (the default). Checksums on the header page
    and the checkpoint pages are never disabled.
    
    innodb_log_checksums_func_update(), innodb_log_checksums_update():
    Update triggers for the new global Boolean variable innodb_log_checksums.
    
    innodb_log_checksum_func_update(), innodb_log_checksum_algorithm_update():
    Removed along with the global parameter innodb_log_checksum_algorithm.
    
    Removed definitions:
    LOG_MAX_N_GROUPS
    log_group_read_checkpoint_info()
    log_checkpoint_get_nth_group_info()
    log_checkpoint_set_nth_group_info()
    log_block_calc_checksum_innodb()
    log_block_calc_checksum_crc32_legacy_big_endian()
    recv_check_cp_is_consistent()
    log_block_checksum_weak_validation()
    log_block_checksum_what_matches()
    log_block_checksum_fail_fatal()
    log_block_checksum_is_ok_or_old_format()
    LOG_CHECKPOINT_OFFSET_LOW32
    LOG_CHECKPOINT_ARCHIVED_LSN
    LOG_CHECKPOINT_GROUP_ARRAY
    LOG_CHECKPOINT_ARCHIVED_FILE_NO
    LOG_CHECKPOINT_ARCHIVED_OFFSET
    LOG_CHECKPOINT_ARRAY_END
    LOG_CHECKPOINT_CHECKSUM_1
    LOG_CHECKPOINT_CHECKSUM_2
    LOG_CHECKPOINT_FSP_FREE_LIMIT
    LOG_CHECKPOINT_FSP_MAGIC_N
    LOG_CHECKPOINT_FSP_MAGIC_N_VAL
    LOG_CHECKPOINT_OFFSET_HIGH32
    LOG_CHECKPOINT_SIZE
    LOG_GROUP_ID
    LOG_FILE_START_LSN
    LOG_FILE_NO
    LOG_FILE_WAS_CREATED_BY_HOT_BACKUP
    LOG_FILE_ARCH_COMPLETED
    LOG_FILE_END_LSN
    
    Changed definitions:
    LOG_CHECKPOINT_LOG_BUF_SIZE
    
    Added definitions:
    innodb_log_checksums: The current value of the SET GLOBAL variable.
    LOG_CHECKPOINT_OFFSET
    LOG_HEADER_FORMAT (repurposing LOG_GROUP_ID which was always 0)
    LOG_HEADER_PAD1 (unused 4 bytes, zero-initialized)
    LOG_HEADER_START_LSN
    LOG_HEADER_CREATOR (renamed from LOG_FILE_WAS_CREATED_BY_HOT_BACKUP)
    LOG_HEADER_CREATOR_END
    LOG_HEADER_CREATOR_CURRENT
    LOG_HEADER_FORMAT_CURRENT
    log_group_t::format
    
    log_block_calc_checksum_format_0(): Renamed from
    log_block_calc_checksum_innodb(). This is only used when upgrading the
    redo log from non-tagged format.
    
    recv_find_max_checkpoint_0(): New function, used when upgrading the
    redo log from non-tagged format.
    
    recv_log_format_0_recover(): New function, used when upgrading the
    redo log from non-tagged format. Checks if the redo log is clean.
    
    log_group_header_read(): Replaces log_group_read_checkpoint_info().
    Also used for reading the log header page (page 0).
    
    recv_check_log_header_checksum(): Replaces recv_check_cp_is_consistent().
    Also used for checking the log header page (page 0).
    
    log_block_checksum_is_ok(): Checks a log block checksum. It must either
    be CRC-32C, or we must have innodb_log_checksums=OFF.
    
    Changed functions:
    
    log_group_file_header_flush(): Always zero-initialize the buffer
    and initialize all LOG_HEADER_ fields.
    
    log_group_checkpoint(): Zero-initialize the checkpoint buffer,
    and write the checkpoint in the new format, with CRC-32C checksum.
    
    recv_find_max_checkpoint(): Support both the old log format
    (if the old-format redo log is logically empty) and the new format.
    
    recv_scan_log_recs(): Clean up the logic a bit. Display a message
    when encountering (and terminating log parsing due to) invalid
    log blocks. For now, keep the existing behaviour and do not display
    a message about log block header mismatch.
    
    recv_recovery_from_checkpoint_start(): Replace the whole "ibbackup" label.
    Check if a log upgrade or a normal recovery is needed.
    
    srv_prepare_to_delete_redo_log_files(): Display a message about
    upgrading the redo log.
    
    Other changes to startup:
    
    If we are going to upgrade the redo log, we must avoid writing any
    new redo log records before we have replaced the redo log.
    
    dict_check_sys_tablespaces(), dict_check_sys_tables(): Avoid
    updating SYS_DATAFILES if we are going to upgrade the redo log.
    
    dict_create_or_check_sys_virtual(): Do not modify anything if we are
    running in --innodb-read-only or --innodb-force-recovery=6 mode.
    
    RB: 10096
    Reviewed-by: default avatarKevin Lewis <kevin.lewis@oracle.com>
    Reviewed-by: default avatarAnnamalai Gurusami <annamalai.gurusami@oracle.com>
Loading