mariadb/storage/innobase
Marko Mäkelä 169c00994b MDEV-12699 Improve crash recovery of corrupted data pages
InnoDB crash recovery used to read every data page for which
redo log exists. This is unnecessary for those pages that are
initialized by the redo log. If a newly created page is corrupted,
recovery could unnecessarily fail. It would suffice to reinitialize
the page based on the redo log records.

To add insult to injury, InnoDB crash recovery could hang if it
encountered a corrupted page. We will fix also that problem.
InnoDB would normally refuse to start up if it encounters a
corrupted page on recovery, but that can be overridden by
setting innodb_force_recovery=1.

Data pages are completely initialized by the records
MLOG_INIT_FILE_PAGE2 and MLOG_ZIP_PAGE_COMPRESS.
MariaDB 10.4 additionally recognizes MLOG_INIT_FREE_PAGE,
which notifies that a page has been freed and its contents
can be discarded (filled with zeroes).

The record MLOG_INDEX_LOAD notifies that redo logging has
been re-enabled after being disabled. We can avoid loading
the page if all buffered redo log records predate the
MLOG_INDEX_LOAD record.

For the internal tables of FULLTEXT INDEX, no MLOG_INDEX_LOAD
records were written before commit aa3f7a107c.
Hence, we will skip these optimizations for tables whose
name starts with FTS_.

This is joint work with Thirunarayanan Balathandayuthapani.

fil_space_t::enable_lsn, file_name_t::enable_lsn: The LSN of the
latest recovered MLOG_INDEX_LOAD record for a tablespace.

mlog_init: Page initialization operations discovered during
redo log scanning. FIXME: This really belongs in recv_sys->addr_hash,
and should be removed in MDEV-19176.

recv_addr_state: Add the new state RECV_WILL_NOT_READ to
indicate that according to mlog_init, the page will be
initialized based on redo log record contents.

recv_add_to_hash_table(): Set the RECV_WILL_NOT_READ state
if appropriate. For now, we do not treat MLOG_ZIP_PAGE_COMPRESS
as page initialization. This works around bugs in the crash
recovery of ROW_FORMAT=COMPRESSED tables.

recv_mark_log_index_load(): Process a MLOG_INDEX_LOAD record
by resetting the state to RECV_NOT_PROCESSED and by updating
the fil_name_t::enable_lsn.

recv_init_crash_recovery_spaces(): Copy fil_name_t::enable_lsn
to fil_space_t::enable_lsn.

recv_recover_page(): Add the parameter init_lsn, to ignore
any log records that precede the page initialization.
Add DBUG output about skipped operations.

buf_page_create(): Initialize FIL_PAGE_LSN, so that
recv_recover_page() will not wrongly skip applying
the page-initialization record due to the field containing
some newer LSN as a leftover from a different page.
Do not invoke ibuf_merge_or_delete_for_page() during
crash recovery.

recv_apply_hashed_log_recs(): Remove some unnecessary lookups.
Note if a corrupted page was found during recovery.
After invoking buf_page_create(), do invoke
ibuf_merge_or_delete_for_page() via mlog_init.ibuf_merge()
in the last recovery batch.

ibuf_merge_or_delete_for_page(): Relax a debug assertion.

innobase_start_or_create_for_mysql(): Abort startup if
a corrupted page was found during recovery. Corrupted pages
will not be flagged if innodb_force_recovery is set.
However, the recv_sys->found_corrupt_fs flag can be set
regardless of innodb_force_recovery if file names are found
to be incorrect (for example, multiple files with the same
tablespace ID).
2019-04-17 13:58:41 +03:00
..
btr MDEV-8139: Clean up the freeing of B-tree pages 2019-04-08 21:33:49 +03:00
buf MDEV-12699 Improve crash recovery of corrupted data pages 2019-04-17 13:58:41 +03:00
data Merge 10.1 into 10.2 2019-04-03 10:32:21 +03:00
dict MDEV-18309: Remove unused code 2019-04-07 12:05:12 +03:00
eval
fil MDEV-18309: Remove unused code 2019-04-07 12:05:12 +03:00
fsp MDEV-19212: Replace macros with type-safe inline functions 2019-04-08 21:33:49 +03:00
fts Merge 10.1 into 10.2 2019-04-02 09:14:15 +03:00
fut
gis Update InnoDB urls 2018-12-19 00:07:33 +04:00
ha Remove many redundant #include from InnoDB 2018-11-19 11:42:14 +02:00
handler MDEV-14239 Missing space: "innodb_open_files ... greaterthan" 2019-04-15 19:17:24 +03:00
ibuf MDEV-12699 Improve crash recovery of corrupted data pages 2019-04-17 13:58:41 +03:00
include MDEV-12699 Improve crash recovery of corrupted data pages 2019-04-17 13:58:41 +03:00
lock Revert MDEV-18464 and MDEV-12009 2019-03-28 12:39:50 +02:00
log MDEV-12699 Improve crash recovery of corrupted data pages 2019-04-17 13:58:41 +03:00
mach
mem Remove many redundant #include from InnoDB 2018-11-19 11:42:14 +02:00
mtr Remove many redundant #include from InnoDB 2018-11-19 11:42:14 +02:00
mysql-test/storage_engine
os MDEV-19212: Replace macros with type-safe inline functions 2019-04-08 21:33:49 +03:00
page MDEV-12699 preparation: Initialize the entire page on MLOG_ZIP_PAGE_COMPRESS 2019-04-06 21:25:43 +03:00
pars Fix integer type mismatch 2019-04-02 13:46:36 +03:00
que Remove many redundant #include from InnoDB 2018-11-19 11:42:14 +02:00
read
rem Merge 10.1 into 10.2 2019-04-03 10:32:21 +03:00
row MDEV-19241 InnoDB fails to write MLOG_INDEX_LOAD upon completing ALTER TABLE 2019-04-17 13:58:22 +03:00
srv MDEV-12699 Improve crash recovery of corrupted data pages 2019-04-17 13:58:41 +03:00
sync Remove some unnecessary InnoDB #include 2018-11-29 12:53:44 +02:00
trx Merge 10.1 into 10.2 2019-04-03 19:58:47 +03:00
ut Add appropriate #ifdef around a declaration 2019-03-21 09:30:03 +02:00
bzip2.cmake
CMakeLists.txt Merge 10.1 into 10.2 2019-03-27 12:26:11 +02:00
compile-innodb
COPYING.Google
COPYING.Percona
innodb.cmake Merge 10.1 into 10.2 2019-03-27 12:26:11 +02:00
lz4.cmake
lzma.cmake
lzo.cmake
plugin_exports
snappy.cmake