[MDEV-12699] Improve crash recovery of corrupted data pages Created: 2017-05-05 Updated: 2023-11-27 Resolved: 2019-04-17 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - InnoDB |
| Affects Version/s: | 5.5, 10.0, 10.1, 10.2, 10.3, 10.4, 10.5 |
| Fix Version/s: | 10.2.24, 10.3.15, 10.4.5 |
| Type: | Bug | Priority: | Major |
| Reporter: | Marko Mäkelä | Assignee: | Marko Mäkelä |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | affects-tests | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Sprint: | 10.2.11 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Description |
|
If a page cannot be decrypted (or read) during crash recovery, InnoDB should cleanly abort the startup. If innodb_force_recovery is specified, we should ignore the problematic page and apply redo log to other pages. If there is a MLOG_INIT_FILE_PAGE or MLOG_ZIP_PAGE_COMPRESS record for a corrupted page, we can always safely ignore the previous page contents and apply the redo log. There is no need to read a page from the data file when applying MLOG_INIT_FILE_PAGE or MLOG_ZIP_PAGE_COMPRESS. Currently in 10.2, the test encryption.innodb-redo-badkey randomly fails, possibly because of this. Also, the test innodb.innodb_bug14147491 needs to be extended. |
| Comments |
| Comment by Marko Mäkelä [ 2017-09-07 ] | ||||||||||||||||||||||||||||||||||||||||
|
On a related note, if there is unencrypted redo log for an encrypted page, and encryption has not been set up, the crash recovery will hang. This can be demonstrated by modifying a test (tested in 10.2 and 10.3):
The startup will get stuck in recv_apply_hashed_log_recs(last_batch=true):
The flag recv_sys->found_corrupt_fs holds here. | ||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2017-09-18 ] | ||||||||||||||||||||||||||||||||||||||||
|
The test innodb.log_data_file_size can be used to repeat the problem, as noted in my follow-up fix to | ||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2017-10-12 ] | ||||||||||||||||||||||||||||||||||||||||
|
Once the recovery has been made robust, we could also disable the doublewrite buffering for pages that were recently (re)initialized. We must guarantee that at all times, the doublewrite buffer will be used during a page flush unless a MLOG_INIT_FILE_PAGE or MLOG_ZIP_PAGE_COMPRESS record was written for the page after the latest checkpoint. The fuzzy checkpoint mechanism could make this challenging. | ||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2018-11-20 ] | ||||||||||||||||||||||||||||||||||||||||
|
While fixing | ||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2018-12-04 ] | ||||||||||||||||||||||||||||||||||||||||
|
Testing the fix should include running ./mtr encryption.innodb-redo-badkey, which is currently disabled due to | ||||||||||||||||||||||||||||||||||||||||
| Comment by Thirunarayanan Balathandayuthapani [ 2018-12-13 ] | ||||||||||||||||||||||||||||||||||||||||
|
The above test case will make the server recovery hang because the read page is corrupted and it fails to decrypt. | ||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2019-02-08 ] | ||||||||||||||||||||||||||||||||||||||||
|
The | ||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2019-04-04 ] | ||||||||||||||||||||||||||||||||||||||||
|
I fixed some concurrency issues that caused intermittent recovery failures, and cleaned up both the existing and new code. I pushed to buildbot for final testing, and expect to push to 10.2 tomorrow. | ||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2019-04-07 ] | ||||||||||||||||||||||||||||||||||||||||
|
I have pushed preparatory refactoring and cleanup to 10.2 and merged to 10.3. A merge to 10.4 along with a test of MLOG_INIT_FREE_PAGE revealed corruption, which I think we must fix before pushing the actual fix to main trees. Also, some corruption became more frequent in mariabackup tests. Hopefully these corruptions are related. |