[MDEV-8139] Fix scrubbing Created: 2015-05-11 Updated: 2023-09-12 Resolved: 2020-07-20 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Encryption, Storage Engine - InnoDB, Storage Engine - XtraDB |
| Affects Version/s: | 10.1.4, 10.2.0, 10.3.0, 10.4.0, 10.5.0 |
| Fix Version/s: | 10.5.5 |
| Type: | Bug | Priority: | Major |
| Reporter: | Sergei Golubchik | Assignee: | Thirunarayanan Balathandayuthapani |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | None | ||
| Issue Links: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Sprint: | 10.1.6-1, 10.1.6-2, 10.1.21 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Description |
|
Scrubbing tests somehow got encryption enabled in their opt files. After removing --innodb-encrypt-tables=ON and --innodb-encrypt-log=ON from innodb_scrub.opt, innodb_scrub_background.opt, innodb_scrub_compressed.opt, these tests start to fail. Now that the problematic ‘background scrubbing’ and all scrubbing code that incorrectly skipped redo logging has been removed from MariaDB Server 10.5.2, we should continue where
|
| Comments |
| Comment by Jan Lindström (Inactive) [ 2015-05-27 ] | |||||||||||||||||||||||||||||||||
|
innodb_scrub_background done. Not yet sure what is wrong with two others. | |||||||||||||||||||||||||||||||||
| Comment by Jan Lindström (Inactive) [ 2015-07-01 ] | |||||||||||||||||||||||||||||||||
|
I do not know, sometimes test passes for 5 times and then fails. Sometimes less. | |||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2017-01-04 ] | |||||||||||||||||||||||||||||||||
|
encryption.innodb_scrub fails to do a slow shutdown, and it unnecessarily does multiple shutdowns while it could easily test all combinations of row_format and operations with a single restart. | |||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2017-01-04 ] | |||||||||||||||||||||||||||||||||
|
While cleaning up encryption.innodb_scrub_background I noticed some problems with the background scrubbing itself:
| |||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2017-01-04 ] | |||||||||||||||||||||||||||||||||
|
bb-10.1-mdev-8139 | |||||||||||||||||||||||||||||||||
| Comment by Jan Lindström (Inactive) [ 2017-01-05 ] | |||||||||||||||||||||||||||||||||
|
ok to push | |||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2017-01-05 ] | |||||||||||||||||||||||||||||||||
|
The test encryption.innodb_scrub is now enabled in MariaDB 10.1.21. It is still disabled in MariaDB 10.2.4, because the end of page 2 (inode list page) of delete_3.ibd randomly gets corrupted with the string "repairmanun". That string should only have been written to B-tree pages, not to an allocation metadata page. This looks like a sign of a serious corruption bug in MariaDB 10.2. The test encryption.innodb_scrub_background demonstrates that more work is needed in the scrubbing. Clearly, undo pages are not being scrubbed as they should, and background scrubbing of data files does not work reliably. Even though I pushed some commits related to the tests, this issue must remain open until all unresolved issues have been addressed. | |||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2017-01-05 ] | |||||||||||||||||||||||||||||||||
|
The test below (reduced from encryption.innodb_scrub) demonstrates 2 problems in 10.2.4:
Note: Remember to copy encryption/t/innodb_scrub.opt if you write the above test into a new file. | |||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2017-01-05 ] | |||||||||||||||||||||||||||||||||
|
I am able to repeat the "repairmanun" problem on MariaDB 10.1.21. I can also see "infimum" and "supremum" strings in the file. FSP_SPACE_FLAGS contains 0x29 both in 10.1 and 10.2. | |||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2017-09-13 ] | |||||||||||||||||||||||||||||||||
|
I think that the scrubbing feature should be an integral part of the purge subsystem. Alas, as noted in We should redesign this in a later version (10.3 or 10.4) where | |||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2018-03-14 ] | |||||||||||||||||||||||||||||||||
|
I believe that the scrubbing as it is implemented in MariaDB 10.1 to 10.3 is incomplete and cannot be fixed easily. I think that the correct way to implement scrubbing would be to introduce a new redo log record MLOG_PAGE_FREE for marking a page freed. It would be written in the same mini-transaction that marks the page freed in the allocation bitmap. We’d then modify the page flushing logic so that it would (when scrubbing is enabled) write zeroes or (for page_compressed=1 files) punch holes for the freed pages. Additionally, we should consider getting rid of the mechanism that delays the deallocation and allocation of undo pages. Currently, there effectively is a separate page allocator for undo log pages, which does not zero out any preceding garbage on the pages when they are reused. | |||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2018-08-09 ] | |||||||||||||||||||||||||||||||||
|
I suspect that there could also be a race condition between log scrubbing and writing. Specifically, I do not see where log_scrub_thread() would ensure that it is only overwriting log until the latest checkpoint. The log scrubbing could be implemented better after In MariaDB Server 10.5.2, | |||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2019-04-08 ] | |||||||||||||||||||||||||||||||||
|
The function btr_page_free_low() was scrubbing pages in an inefficent and backup-unsafe way. Starting with MariaDB Server 10.2.24 and 10.3.15, it will write an appropriate redo log record for initializing the page.
| |||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2020-03-10 ] | |||||||||||||||||||||||||||||||||
|
The scope of | |||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2020-05-28 ] | |||||||||||||||||||||||||||||||||
|
The shrinking of a file by ftruncate() (when all last pages of the file are freed) might block all concurrent access to the file. I think that we must do the ftruncate() when scrubbing is enabled. When scrubbing is disabled, we may choose to not shrink files, depending on what benchmarks indicate. | |||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2020-06-03 ] | |||||||||||||||||||||||||||||||||
|
A quick review:
The interesting part of the patch is the call buf_flush_freed_pages(space, buf_flush_get_freed_pages(space)), which I would suggest to write as a single function. The preceding comment confused me, because it mentioned neighbor flushing, which was disabled on SSD by Also, we should invoke ftruncate() (after writing a TRIM_PAGES log record) when the last pages of a tablespace are freed. The recovery of TRIM_PAGES must be extended to cover all tablespaces, not only undo tablespaces. Related to this, a TODO comment about PUNCH_HOLE must be removed from trx_purge_truncate_history(). | |||||||||||||||||||||||||||||||||
| Comment by Matthias Leich [ 2020-06-11 ] | |||||||||||||||||||||||||||||||||
|
origin/bb-10.5- | |||||||||||||||||||||||||||||||||
| Comment by Thirunarayanan Balathandayuthapani [ 2020-06-12 ] | |||||||||||||||||||||||||||||||||
|
Pushed the patch in
| |||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2020-06-22 ] | |||||||||||||||||||||||||||||||||
|
The feature was disabled in the MariaDB 10.5.4 release due to concerns over data corruption ( | |||||||||||||||||||||||||||||||||
| Comment by Matthias Leich [ 2020-07-07 ] | |||||||||||||||||||||||||||||||||
|
Bad effect 3. from above replays on actual 10.5 too. | |||||||||||||||||||||||||||||||||
| Comment by Thirunarayanan Balathandayuthapani [ 2020-07-13 ] | |||||||||||||||||||||||||||||||||
|
Patch is in bb-10.5-thiru. Please take a look | |||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2020-07-17 ] | |||||||||||||||||||||||||||||||||
|
I posted some review comments. It looks OK, except that crash recovery fails to scrub freed pages in page_compressed tables when innodb_immediate_scrub_data_uncompressed=OFF (which is the default setting). OK to push after addressing my comments. | |||||||||||||||||||||||||||||||||
| Comment by Matthias Leich [ 2020-07-20 ] | |||||||||||||||||||||||||||||||||
|
|