Commit bdf62ece authored by Marko Mäkelä's avatar Marko Mäkelä

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 0b47c126 (MDEV-13542).
parent f410974f
......@@ -8,6 +8,7 @@ call mtr.add_suppression("InnoDB: Database page corruption on disk or a failed r
call mtr.add_suppression("InnoDB: Failed to read page .* from file '.*'");
call mtr.add_suppression("InnoDB: OPT_PAGE_CHECKSUM mismatch");
call mtr.add_suppression("InnoDB: Set innodb_force_recovery=1 to ignore corruption");
call mtr.add_suppression("InnoDB: (Unable to apply log to|Discarding log for) corrupted page ");
call mtr.add_suppression("InnoDB: Plugin initialization aborted");
call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed");
call mtr.add_suppression("\\[ERROR\\] InnoDB: Cannot decrypt \\[page id: space=");
......
......@@ -9,6 +9,7 @@ call mtr.add_suppression("InnoDB: Database page corruption on disk or a failed r
call mtr.add_suppression("InnoDB: Failed to read page [123] from file '.*test.t1\\.ibd': Table is encrypted but decrypt failed");
call mtr.add_suppression("InnoDB: The page \\[page id: space=\\d+, page number=3\\] in file '.*test.t1\\.ibd' cannot be decrypted");
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.");
call mtr.add_suppression("InnoDB: (Unable to apply log to|Discarding log for) corrupted page ");
--enable_query_log
let INNODB_PAGE_SIZE=`select @@innodb_page_size`;
......
......@@ -17,6 +17,7 @@ call mtr.add_suppression("InnoDB: Database page corruption on disk or a failed r
call mtr.add_suppression("InnoDB: Failed to read page .* from file '.*'");
call mtr.add_suppression("InnoDB: OPT_PAGE_CHECKSUM mismatch");
call mtr.add_suppression("InnoDB: Set innodb_force_recovery=1 to ignore corruption");
call mtr.add_suppression("InnoDB: (Unable to apply log to|Discarding log for) corrupted page ");
call mtr.add_suppression("InnoDB: Plugin initialization aborted");
call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed");
# for innodb_checksum_algorithm=full_crc32 only
......
......@@ -6,6 +6,7 @@ call mtr.add_suppression("Plugin 'InnoDB' init function returned error");
call mtr.add_suppression("Plugin 'InnoDB' registration as a STORAGE ENGINE failed");
call mtr.add_suppression("InnoDB: Database page corruption on disk or a failed read of file '.*test.t1\\.ibd' page");
call mtr.add_suppression("InnoDB: Failed to read page 3 from file '.*test.t1\\.ibd': Page read from tablespace is corrupted.");
call mtr.add_suppression("InnoDB: (Unable to apply log to|Discarding log for) corrupted page .*, page number=3\\]");
call mtr.add_suppression("InnoDB: Table `test`.`t1` is corrupted. Please drop the table and recreate.");
call mtr.add_suppression("InnoDB: File '.*test/t1\\.ibd' is corrupted");
call mtr.add_suppression("InnoDB: A long wait .* was observed for dict_sys");
......
......@@ -4,6 +4,7 @@
--disable_query_log
call mtr.add_suppression("InnoDB: Database page corruption on disk or a failed read of file '.*test.t1\\.ibd' page");
call mtr.add_suppression("\\[ERROR\\] InnoDB: Failed to read page 19 from file '.*test.t1\\.ibd': Page read from tablespace is corrupted\\.");
call mtr.add_suppression("InnoDB: (Unable to apply log to|Discarding log for) corrupted page .*, page number=19\\]");
call mtr.add_suppression("\\[ERROR\\] InnoDB: Plugin initialization aborted at srv0start\\.cc.* with error Data structure corruption");
call mtr.add_suppression("\\[ERROR\\] Plugin 'InnoDB' (init function|registration)");
call mtr.add_suppression("\\[ERROR\\] InnoDB: We detected index corruption");
......
......@@ -2128,7 +2128,7 @@ void buf_page_free(fil_space_t *space, uint32_t page, mtr_t *mtr)
btr_search_drop_page_hash_index(block);
#endif /* BTR_CUR_HASH_ADAPT */
block->page.set_freed(block->page.state());
mtr->memo_push(block, MTR_MEMO_PAGE_X_FIX);
mtr->memo_push(block, MTR_MEMO_PAGE_X_MODIFY);
}
/** Get read access to a compressed page (usually of type
......
......@@ -2593,7 +2593,6 @@ fseg_free_page_low(
if (UNIV_UNLIKELY(err != DB_SUCCESS)) {
return err;
}
return err;
}
mtr->free(*space, static_cast<uint32_t>(offset));
......
......@@ -48,13 +48,13 @@ mtr_t::memo_push(void* object, mtr_memo_type_t type)
ut_ad(type <= MTR_MEMO_SPACE_S_LOCK);
ut_ad(type == MTR_MEMO_PAGE_X_MODIFY || ut_is_2pow(type));
/* If this mtr has x-fixed a clean page then we set
the made_dirty flag. This tells us if we need to
/* If this mtr has U or X latched a clean page then we set
the m_made_dirty flag. This tells us if we need to
grab log_sys.flush_order_mutex at mtr_t::commit() so that we
can insert the dirtied page into the flush list. */
can insert the dirtied page into the buf_pool.flush_list. */
if (!m_made_dirty
&& (type == MTR_MEMO_PAGE_X_FIX || type == MTR_MEMO_PAGE_SX_FIX)) {
&& (type & (MTR_MEMO_PAGE_X_FIX | MTR_MEMO_PAGE_SX_FIX))) {
m_made_dirty = is_block_dirtied(
reinterpret_cast<const buf_block_t*>(object));
......
......@@ -2949,7 +2949,13 @@ ATTRIBUTE_COLD void recv_sys_t::free_corrupted_page(page_id_t page_id)
p->second.log.clear();
pages.erase(p);
if (!srv_force_recovery)
{
set_corrupt_fs();
ib::error() << "Unable to apply log to corrupted page " << page_id
<< "; set innodb_force_recovery to ignore";
}
else
ib::warn() << "Discarding log for corrupted page " << page_id;
}
if (pages.empty())
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment