[MDEV-21109] Table corruption not detected with CHECK TABLE or innochecksum, only with mariabackup Created: 2019-11-21 Updated: 2022-11-03 Resolved: 2022-01-06 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | mariabackup |
| Affects Version/s: | 10.3.17, 10.3.21, 10.3.23 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Critical |
| Reporter: | suresh ramagiri | Assignee: | Marko Mäkelä |
| Resolution: | Incomplete | Votes: | 4 |
| Labels: | corruption | ||
| Attachments: |
|
||||||||||||||||||||||||||||||||
| Issue Links: |
|
||||||||||||||||||||||||||||||||
| Description |
|
It is observed that, while taking the backup using mariabackup(10.3.17) it's keep failing with following error: Backup command used:
mariabackup output:
Did tried, fixing the table (pointed as corrupted) with following, but the same issue is occurring. set OLD_ALTER_TABLE=1 |
| Comments |
| Comment by Marko Mäkelä [ 2020-06-10 ] |
|
In break_down_rate.ddl This suggests that page 5 coudd be unused garbage, and CHECK TABLE does not read such pages. It is only reading pages that are reachable from the index tree root pages. Furthermore, CHECK TABLE (more specifically, btr_validate_index()) does not seem to fetch any BLOB pages. They would be reachable from clustered index (PRIMARY KEY) leaf pages. Because page 5 (starting at 0x14000) does contain the B-tree page identifiers "infimum" and "supremum", and because FIL_PAGE_TYPE is FIL_PAGE_INDEX, it should not be a BLOB page. So, CHECK TABLE seems to be working as designed. Both index root pages 3 and 4 are empty: the bytes 0x000d right before the "infimum" point straight to the "supremum". So, there cannot be any references to BLOB pages. The file appears to contain two ‘extra’ pages: the allegedly corrupted page 5 and an all-zero page 6. One last thing that we can check is the page allocation bitmap in page 0, which should describe pages 0 to 16383. The FSP_SIZE at offset 0x2e is 7, which does match the file size (page 6 is the last page). It is normal to have a few extra empty pages at the end of the data file. The allocation bitmap seems to start at byte offset 0xae, and according to it, only pages 0,1,2,3,4 are marked as allocated. The corrupted page 5 is marked as free. This is a border case, but apart from failing to read and check BLOB pages, I do not see any wrongdoing by CHECK TABLE. I would tend to suspect a problem in Mariabackup. The page at byte offset 0x14000 (page 5) looks unrelated to the rest of the data file. vlad.lesin, did you notice that the tablespace ID at byte offset 0x14022 is 0x431 instead of 0x4ec? I remember diagnosing a similar issue with the same support customer about a year ago, but we failed to reach a conclusion then. On July 1, 2019, we added a debug check to InnoDB in I would request that a repeatable test case for this be created. Because the failure is likely to be nondeterministic, I would suggest the following approach with https://rr-project.org/:
I am proposing frequent server restarts, so that the rr replay traces would be smaller. Note that rr replay traces are not portable between computers in practice. For analysis, remote access to the system would be needed. This approach was successfully used when fixing crash recovery bugs in code that was rewritten in MariaDB 10.5, for example |
| Comment by Marko Mäkelä [ 2020-06-17 ] |
|
vlad.lesin, I think that you must reproduce the scenario that leads to mariabackup --prepare creating a backup that contains a page for the wrong tablespace. I do not want to add non-debug code to the server in main branches. I also think that we should check that the page number in the page frame matches the block, when we read pages into the buffer pool. We did provide a custom non-debug build (with an if statement) in the support case that was associated with |
| Comment by Vladislav Lesin [ 2020-06-18 ] |
|
marko > You can provide another custom build with more extensive check. Maybe you should also add such a check to the mariabackup --backup code. I already did it, and created several custom builds for different server versions(they can be found by "git branch -a | grep 21109") and instructions similar to yours instruction above, how to use such builds, but, as I know, non of those builds were tried following the instructions. > Vladislav Lesin, I think that you must reproduce the scenario that leads to mariabackup --prepare creating a backup that contains a page for the wrong tablespace. "mariabackup --prepare" does not take part in the bug reproduction on the customer's side. I have some assumption I am working on. The assumption is based on your analysis above and our discussion in slack. Mariabackup fails on freed page. Innodb recovery does not read "freed" pages. Read-ahead algorithm reads pages which are in the chain of B-tree leaf pages. So the assumption is that mariabackup must not check freed pages, but it does. The weakness of this assumption is that our tests would more likely catch such error. |
| Comment by Vladislav Lesin [ 2020-06-18 ] |
|
According to os_file_set_size(), when tablespace is extended, all extra pages must be filled with zero's. But we have two pages at the end of "break_down_rate.ibd", the last page 6 is zeroed, while allegedly corrupted page 5 is not zeroed. |
| Comment by Vladislav Lesin [ 2020-07-22 ] |
|
BTW, there might also be the sense to implement something like online check mode from innochecksum, to have ability to detect such errors with this tool, but not only with mariabackup. What do you think, marko? |
| Comment by Marko Mäkelä [ 2020-07-23 ] |
|
I think that it could be easier to extend CHECK TABLE in the server than to duplicate the functionality in an external tool. If there is a concern that CHECK TABLE would crash the server due to |
| Comment by Marko Mäkelä [ 2020-10-02 ] |
|
vlad.lesin, as part of I have a further idea: What if we extend the innochecksum tool with an option that will zero out (or optionally punch holes) over any pages that are marked as freed in the page allocation bitmap pages? An even further idea (if such an extended innochecksum tool is proved to help) would be to improve mariabackup --prepare in such a way that it will remember which pages were corrupted (maybe getting this information from mariabackup --backup via some configuration file) and then check if all those pages happen to be marked as freed. If so, zero out the pages and issue diagnostic messages (NOTE). If some corrupted pages are not marked as freed in the allocation bitmap, then we would issue WARNING or ERROR messages. |
| Comment by Vladislav Lesin [ 2020-10-05 ] |
|
marko Yes, the "corruption" can be detected by innochecksum with 1. innochecksum is the tool which is supposed to check tablespaces and does not modify them. We have option to rewrite checksum algorithm. But it modifies only checksums. Should we turn the tool for checksums check to the tool for corruptions fixing? 2. "mariabackup --prepare" could fix such pages. But, as I understood, there must not be non-zero non-allocated pages. And we need to understand what is the source of such pages. And when we understand it, the code to fix such pages will be useless. There will be one more option which is rarely used, and which we have to maintain until some major version. |
| Comment by Marko Mäkelä [ 2021-09-14 ] |
|
One change that we should be able to implement rather easily in mariabackup --prepare if it has not been already done, is what I think that we need an executable test case that does not involve any pre-corrupted .ibd files but only depends on a newly reinitialized server, to demonstrate what actually is not working as expected. While waiting for a test case, I think that we should fix reproducible backup bugs, such as The MariaDB Server 10.6 release fixed the last known InnoDB violations of the write-ahead logging protocol that I was aware of: |
| Comment by Valerii Kravchuk [ 2021-09-14 ] |
|
Isn't this bug report about CHECK TABLE (and innochecksum) behavior, a request to find problems that affect mariabackup at earlier stages? OK, in new version 10.6 mariabackup should work in a more robust way, but what about 10.2 - 10.5? |
| Comment by Marko Mäkelä [ 2021-09-17 ] |
|
In the original customer case that prompted us to file valerii, it is not clear to me whether there are any "problems that affect mariabackup at earlier stages" anymore. I believe that my comment in this ticket from 2020-06-10 was actually addressed in
What is the exact problem that we want to detect and where? |
| Comment by Marko Mäkelä [ 2021-10-26 ] |
|
I was hoping that this could be closed as a duplicate of However, we were not able to repeat this. Hence, I am closing this as "Cannot Reproduce". We can reopen and fix this if someone provides something for repeating this bug. |