Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
WL#8845 Implement an InnoDB redo log format version identifier
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: Kevin Lewis <kevin.lewis@oracle.com> Reviewed-by: Annamalai Gurusami <annamalai.gurusami@oracle.com>
- Loading branch information
Marko Mäkelä
committed
Sep 11, 2015
1 parent
a68e844
commit af0aced
Showing
27 changed files
with
652 additions
and
674 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,14 @@ | ||
# redo log from before MySQL 5.7.9 | ||
# redo log from before MySQL 5.7.9, with corrupted log checkpoint | ||
# redo log from before MySQL 5.7.9, with corrupted log block | ||
# redo log from "after" MySQL 5.7.9, but with invalid header checksum | ||
# distant future redo log format, with valid header checksum | ||
# valid header, but old-format checkpoint blocks | ||
# valid header, valid checkpoint 1, all-zero (invalid) checkpoint 2, invalid block checksum | ||
# --innodb-force-recovery=6 (skip the entire redo log) | ||
# valid header, valid checkpoint 1, all-zero (invalid) checkpoint 2, invalid block number | ||
# --innodb-force-recovery=6 (skip the entire redo log) | ||
# Test a corrupted MLOG_FILE_NAME record. | ||
# valid header, valid checkpoint 1, all-zero (invalid) checkpoint 2 | ||
# Test a corrupted MLOG_FILE_NAME record. | ||
# valid header, invalid checkpoint 1, valid checkpoint 2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 0 additions & 47 deletions
47
mysql-test/suite/sys_vars/r/innodb_log_checksum_algorithm_basic.result
This file was deleted.
Oops, something went wrong.
42 changes: 42 additions & 0 deletions
42
mysql-test/suite/sys_vars/r/innodb_log_checksums_basic.result
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
SET @orig = @@global.innodb_log_checksums; | ||
SELECT @orig; | ||
@orig | ||
1 | ||
SET GLOBAL innodb_log_checksums = 'crc32'; | ||
ERROR 42000: Variable 'innodb_log_checksums' can't be set to the value of 'crc32' | ||
SELECT @@global.innodb_log_checksums; | ||
@@global.innodb_log_checksums | ||
1 | ||
SET GLOBAL innodb_log_checksums = 2; | ||
ERROR 42000: Variable 'innodb_log_checksums' can't be set to the value of '2' | ||
SELECT @@global.innodb_log_checksums; | ||
@@global.innodb_log_checksums | ||
1 | ||
SET GLOBAL innodb_log_checksums = 1e2; | ||
ERROR 42000: Incorrect argument type to variable 'innodb_log_checksums' | ||
SELECT @@global.innodb_log_checksums; | ||
@@global.innodb_log_checksums | ||
1 | ||
SET GLOBAL innodb_log_checksums = 1.0; | ||
ERROR 42000: Incorrect argument type to variable 'innodb_log_checksums' | ||
SELECT @@global.innodb_log_checksums; | ||
@@global.innodb_log_checksums | ||
1 | ||
SET innodb_log_checksums = OFF; | ||
ERROR HY000: Variable 'innodb_log_checksums' is a GLOBAL variable and should be set with SET GLOBAL | ||
SELECT @@global.innodb_log_checksums; | ||
@@global.innodb_log_checksums | ||
1 | ||
SET GLOBAL innodb_log_checksums = OFF; | ||
SELECT @@global.innodb_log_checksums; | ||
@@global.innodb_log_checksums | ||
0 | ||
SET GLOBAL innodb_log_checksums = default; | ||
SET GLOBAL innodb_log_checksums = ON; | ||
SELECT @@global.innodb_log_checksums; | ||
@@global.innodb_log_checksums | ||
1 | ||
SET GLOBAL innodb_log_checksums = @orig; | ||
SELECT @@global.innodb_log_checksums; | ||
@@global.innodb_log_checksums | ||
1 |
39 changes: 0 additions & 39 deletions
39
mysql-test/suite/sys_vars/t/innodb_log_checksum_algorithm_basic.test
This file was deleted.
Oops, something went wrong.
36 changes: 36 additions & 0 deletions
36
mysql-test/suite/sys_vars/t/innodb_log_checksums_basic.test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--source include/have_innodb.inc | ||
|
||
# Check the default value | ||
SET @orig = @@global.innodb_log_checksums; | ||
SELECT @orig; | ||
|
||
-- error ER_WRONG_VALUE_FOR_VAR | ||
SET GLOBAL innodb_log_checksums = 'crc32'; | ||
SELECT @@global.innodb_log_checksums; | ||
|
||
-- error ER_WRONG_VALUE_FOR_VAR | ||
SET GLOBAL innodb_log_checksums = 2; | ||
SELECT @@global.innodb_log_checksums; | ||
|
||
-- error ER_WRONG_TYPE_FOR_VAR | ||
SET GLOBAL innodb_log_checksums = 1e2; | ||
SELECT @@global.innodb_log_checksums; | ||
|
||
-- error ER_WRONG_TYPE_FOR_VAR | ||
SET GLOBAL innodb_log_checksums = 1.0; | ||
SELECT @@global.innodb_log_checksums; | ||
|
||
-- error ER_GLOBAL_VARIABLE | ||
SET innodb_log_checksums = OFF; | ||
SELECT @@global.innodb_log_checksums; | ||
|
||
SET GLOBAL innodb_log_checksums = OFF; | ||
SELECT @@global.innodb_log_checksums; | ||
|
||
SET GLOBAL innodb_log_checksums = default; | ||
|
||
SET GLOBAL innodb_log_checksums = ON; | ||
SELECT @@global.innodb_log_checksums; | ||
|
||
SET GLOBAL innodb_log_checksums = @orig; | ||
SELECT @@global.innodb_log_checksums; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.