Skip to content

Commit bdf62ec

Browse files
committed
MDEV-29374 InnoDB recovery fails with "Data structure corruption"
recv_sys_t::free_corrupted_page(): Identify the corrupted page in an error or warning message. buf_page_free(): Just in case, register the page as modified. This should already have been done in mtr_t::free() as part of fseg_free_page_low(). mtr_t::memo_push(): Simplify a condition, so that when invoked with MTR_MEMO_PAGE_X_MODIFY, we will do the right thing. fseg_free_page_low(): Remove an accidentally added return statement that prevented mtr_t::free() from being called. This fixes a regression that was introduced in commit 0b47c12 (MDEV-13542).
1 parent f410974 commit bdf62ec

File tree

9 files changed

+16
-6
lines changed

9 files changed

+16
-6
lines changed

mysql-test/suite/encryption/r/innodb-redo-badkey.result

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ call mtr.add_suppression("InnoDB: Database page corruption on disk or a failed r
88
call mtr.add_suppression("InnoDB: Failed to read page .* from file '.*'");
99
call mtr.add_suppression("InnoDB: OPT_PAGE_CHECKSUM mismatch");
1010
call mtr.add_suppression("InnoDB: Set innodb_force_recovery=1 to ignore corruption");
11+
call mtr.add_suppression("InnoDB: (Unable to apply log to|Discarding log for) corrupted page ");
1112
call mtr.add_suppression("InnoDB: Plugin initialization aborted");
1213
call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed");
1314
call mtr.add_suppression("\\[ERROR\\] InnoDB: Cannot decrypt \\[page id: space=");

mysql-test/suite/encryption/t/corrupted_during_recovery.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ call mtr.add_suppression("InnoDB: Database page corruption on disk or a failed r
99
call mtr.add_suppression("InnoDB: Failed to read page [123] from file '.*test.t1\\.ibd': Table is encrypted but decrypt failed");
1010
call mtr.add_suppression("InnoDB: The page \\[page id: space=\\d+, page number=3\\] in file '.*test.t1\\.ibd' cannot be decrypted");
1111
call mtr.add_suppression("InnoDB: Table in tablespace \\d+ encrypted. However key management plugin or used key_version \\d+ is not found or used encryption algorithm or method does not match. Can't continue opening the table.");
12+
call mtr.add_suppression("InnoDB: (Unable to apply log to|Discarding log for) corrupted page ");
1213
--enable_query_log
1314

1415
let INNODB_PAGE_SIZE=`select @@innodb_page_size`;

mysql-test/suite/encryption/t/innodb-redo-badkey.test

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ call mtr.add_suppression("InnoDB: Database page corruption on disk or a failed r
1717
call mtr.add_suppression("InnoDB: Failed to read page .* from file '.*'");
1818
call mtr.add_suppression("InnoDB: OPT_PAGE_CHECKSUM mismatch");
1919
call mtr.add_suppression("InnoDB: Set innodb_force_recovery=1 to ignore corruption");
20+
call mtr.add_suppression("InnoDB: (Unable to apply log to|Discarding log for) corrupted page ");
2021
call mtr.add_suppression("InnoDB: Plugin initialization aborted");
2122
call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed");
2223
# for innodb_checksum_algorithm=full_crc32 only

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ call mtr.add_suppression("Plugin 'InnoDB' init function returned error");
66
call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed");
77
call mtr.add_suppression("InnoDB: Database page corruption on disk or a failed read of file '.*test.t1\\.ibd' page");
88
call mtr.add_suppression("InnoDB: Failed to read page 3 from file '.*test.t1\\.ibd': Page read from tablespace is corrupted.");
9+
call mtr.add_suppression("InnoDB: (Unable to apply log to|Discarding log for) corrupted page .*, page number=3\\]");
910
call mtr.add_suppression("InnoDB: Table `test`.`t1` is corrupted. Please drop the table and recreate.");
1011
call mtr.add_suppression("InnoDB: File '.*test/t1\\.ibd' is corrupted");
1112
call mtr.add_suppression("InnoDB: A long wait .* was observed for dict_sys");

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
--disable_query_log
55
call mtr.add_suppression("InnoDB: Database page corruption on disk or a failed read of file '.*test.t1\\.ibd' page");
66
call mtr.add_suppression("\\[ERROR\\] InnoDB: Failed to read page 19 from file '.*test.t1\\.ibd': Page read from tablespace is corrupted\\.");
7+
call mtr.add_suppression("InnoDB: (Unable to apply log to|Discarding log for) corrupted page .*, page number=19\\]");
78
call mtr.add_suppression("\\[ERROR\\] InnoDB: Plugin initialization aborted at srv0start\\.cc.* with error Data structure corruption");
89
call mtr.add_suppression("\\[ERROR\\] Plugin 'InnoDB' (init function|registration)");
910
call mtr.add_suppression("\\[ERROR\\] InnoDB: We detected index corruption");

storage/innobase/buf/buf0buf.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2128,7 +2128,7 @@ void buf_page_free(fil_space_t *space, uint32_t page, mtr_t *mtr)
21282128
btr_search_drop_page_hash_index(block);
21292129
#endif /* BTR_CUR_HASH_ADAPT */
21302130
block->page.set_freed(block->page.state());
2131-
mtr->memo_push(block, MTR_MEMO_PAGE_X_FIX);
2131+
mtr->memo_push(block, MTR_MEMO_PAGE_X_MODIFY);
21322132
}
21332133

21342134
/** Get read access to a compressed page (usually of type

storage/innobase/fsp/fsp0fsp.cc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2593,7 +2593,6 @@ fseg_free_page_low(
25932593
if (UNIV_UNLIKELY(err != DB_SUCCESS)) {
25942594
return err;
25952595
}
2596-
return err;
25972596
}
25982597

25992598
mtr->free(*space, static_cast<uint32_t>(offset));

storage/innobase/include/mtr0mtr.inl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -48,13 +48,13 @@ mtr_t::memo_push(void* object, mtr_memo_type_t type)
4848
ut_ad(type <= MTR_MEMO_SPACE_S_LOCK);
4949
ut_ad(type == MTR_MEMO_PAGE_X_MODIFY || ut_is_2pow(type));
5050

51-
/* If this mtr has x-fixed a clean page then we set
52-
the made_dirty flag. This tells us if we need to
51+
/* If this mtr has U or X latched a clean page then we set
52+
the m_made_dirty flag. This tells us if we need to
5353
grab log_sys.flush_order_mutex at mtr_t::commit() so that we
54-
can insert the dirtied page into the flush list. */
54+
can insert the dirtied page into the buf_pool.flush_list. */
5555

5656
if (!m_made_dirty
57-
&& (type == MTR_MEMO_PAGE_X_FIX || type == MTR_MEMO_PAGE_SX_FIX)) {
57+
&& (type & (MTR_MEMO_PAGE_X_FIX | MTR_MEMO_PAGE_SX_FIX))) {
5858

5959
m_made_dirty = is_block_dirtied(
6060
reinterpret_cast<const buf_block_t*>(object));

storage/innobase/log/log0recv.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2949,7 +2949,13 @@ ATTRIBUTE_COLD void recv_sys_t::free_corrupted_page(page_id_t page_id)
29492949
p->second.log.clear();
29502950
pages.erase(p);
29512951
if (!srv_force_recovery)
2952+
{
29522953
set_corrupt_fs();
2954+
ib::error() << "Unable to apply log to corrupted page " << page_id
2955+
<< "; set innodb_force_recovery to ignore";
2956+
}
2957+
else
2958+
ib::warn() << "Discarding log for corrupted page " << page_id;
29532959
}
29542960

29552961
if (pages.empty())

0 commit comments

Comments
 (0)