Skip to content

Commit 8a1e913

Browse files
Bug #21951764 IMPOSSIBLE TO UPGRADE DATABASE FROM 5.7 TO 5.8,
EVEN WHEN STOPPING GRACEFULLY Problem: ======= In function logs_empty_and_mark_files_at_shutdown(), checkpoint is done repeatedly until log_sys->lsn == log_sys->last_checkpoint_lsn. So after writing MLOG_CHECKPOINT record, log_sys->lsn will be greater than last_checkpoint_lsn. In the next iteration of log_make_checkpoint_at(), updation is done only the checkpoint lsn in the log file header with the log_sys->lsn. In trunk, there will no MLOG_CHECKPOINT record after checkpoint_lsn and it leads to upgrade failure. Solution: ======== To verify if the shutdown is normal before upgrade, make sure that there are no redo log records after checkpoint lsn. Reviewed-by: Marko Makela<marko.makela@oracle.com> RB:11603
1 parent 8b678ce commit 8a1e913

File tree

4 files changed

+21
-12
lines changed

4 files changed

+21
-12
lines changed

mysql-test/suite/innodb/r/log_corruption.result

+4-1
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@
1313
# --innodb-force-recovery=6 (skip the entire redo log)
1414
# valid 5.7.9 header, valid checkpoint 1, no matching MLOG_CHECKSUM
1515
# --innodb-force-recovery=6 (skip the entire redo log)
16-
# upgrade: valid 5.7.9 header, valid checkpoint 1, clean redo log
16+
# upgrade: valid 5.7.9 header, valid checkpoint 1, logically non empty
17+
# redo log
1718
# Test a corrupted MLOG_FILE_NAME record.
1819
# current header, valid checkpoint 1, all-zero (invalid) checkpoint 2
1920
# Test a corrupted MLOG_FILE_NAME record.
2021
# valid header, invalid checkpoint 1, valid checkpoint 2
22+
# Upgrade: valid 5.7.9 header, valid checkpoint 1, logically empty
23+
# redo log

mysql-test/suite/innodb/t/log_corruption.test

+14-4
Original file line numberDiff line numberDiff line change
@@ -113,15 +113,14 @@ let SEARCH_PATTERN=Plugin 'InnoDB' registration as a STORAGE ENGINE failed;
113113
let SEARCH_PATTERN=InnoDB: Cannot create sys_virtual system tables. running in read-only mode;
114114
--source include/search_pattern_in_file.inc
115115

116-
--echo # upgrade: valid 5.7.9 header, valid checkpoint 1, clean redo log
116+
--echo # upgrade: valid 5.7.9 header, valid checkpoint 1, logically non empty
117+
--echo # redo log
117118
--remove_file $newdir/ib_logfile0
118119
--exec unzip $MYSQL_TEST_DIR/suite/innodb/t/log_corruption4d.zip -d $newdir > $SEARCH_FILE
119120
--error 1
120121
--exec $MYSQLD $args --innodb-log-file-size=4M
121-
let SEARCH_PATTERN=InnoDB: Upgrading redo log: 2\\*.* pages, LSN=1213964;
122+
let SEARCH_PATTERN=InnoDB: Upgrade after a crash is not supported\\. This redo log was created with malicious intentions, or perhaps\\.;
122123
--source include/search_pattern_in_file.inc
123-
# This was created by the upgrade.
124-
--remove_file $newdir/ib_buffer_pool
125124

126125
# Replace database with 1M redo logs from before MySQL 5.7.9
127126
--remove_file $newdir/ib_logfile0
@@ -165,6 +164,17 @@ let SEARCH_PATTERN= len 22. hex 38000000000012860cb7809781e80006626f67757300. as
165164
let SEARCH_PATTERN=InnoDB: Set innodb_force_recovery to ignore this error;
166165
--source include/search_pattern_in_file.inc
167166

167+
--echo # Upgrade: valid 5.7.9 header, valid checkpoint 1, logically empty
168+
--echo # redo log
169+
--remove_file $newdir/ib_logfile0
170+
--exec unzip $MYSQL_TEST_DIR/suite/innodb/t/log_corruption7.zip -d $newdir > $SEARCH_FILE
171+
--error 1
172+
--exec $MYSQLD $args
173+
let SEARCH_PATTERN=InnoDB: Upgrading redo log: 2\\*.* pages, LSN=1213973;
174+
--source include/search_pattern_in_file.inc
175+
# This was created by the upgrade.
176+
--remove_file $newdir/ib_buffer_pool
177+
168178
--remove_file $SEARCH_FILE
169179
--remove_file $newdir/ibdata1
170180
--remove_file $newdir/ib_logfile0
1.46 KB
Binary file not shown.

storage/innobase/log/log0recv.cc

+3-7
Original file line numberDiff line numberDiff line change
@@ -1111,15 +1111,11 @@ recv_log_recover_5_7(lsn_t lsn)
11111111
return(DB_CORRUPTION);
11121112
}
11131113

1114-
/* On a clean shutdown, there will only be the MLOG_CHECKPOINT
1115-
record pointing to our checkpoint. */
1114+
/* On a clean shutdown, the redo log will be logically empty
1115+
after the checkpoint lsn. */
11161116

11171117
if (log_block_get_data_len(buf)
1118-
!= ((source_offset + SIZE_OF_MLOG_CHECKPOINT)
1119-
& (OS_FILE_LOG_BLOCK_SIZE - 1))
1120-
|| log_block_get_first_rec_group(buf) != LOG_BLOCK_HDR_SIZE
1121-
|| mach_read_from_1(buf + LOG_BLOCK_HDR_SIZE) != MLOG_CHECKPOINT
1122-
|| mach_read_from_8(buf + (LOG_BLOCK_HDR_SIZE + 1)) != lsn) {
1118+
!= (source_offset & (OS_FILE_LOG_BLOCK_SIZE - 1))) {
11231119
ib::error() << NO_UPGRADE_RECOVERY_MSG
11241120
<< log_header_creator
11251121
<< NO_UPGRADE_RTFM_MSG;

0 commit comments

Comments
 (0)