[MDEV-30725] Assertion `mach_read_from_8(b->page.frame + 16U) <= m_commit_lsn' failed in mtr_t::commit on failed crash recovery Created: 2023-02-25 Updated: 2023-03-04 Resolved: 2023-03-04 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - InnoDB |
| Affects Version/s: | 11.0 |
| Fix Version/s: | N/A |
| Type: | Bug | Priority: | Major |
| Reporter: | Roel Van de Paar | Assignee: | Unassigned |
| Resolution: | Cannot Reproduce | Votes: | 0 |
| Labels: | crash-recovery | ||
| Description |
|
Test setup:
A full copy of the data dir is available in this ticket, allowing 'first startup after the crash' to be attempted as often as necessary to locate the bug |
| Comments |
| Comment by Roel Van de Paar [ 2023-02-25 ] | |||||||||||||||||||||||||||||||||||||||||||
|
The xz archive contains the following files:
Note that the data directory may contain additional relevant/helpful files. To debug any issues, (repeat as necessary): First, change BASEDIR in start_recovery. Then: | |||||||||||||||||||||||||||||||||||||||||||
| Comment by Roel Van de Paar [ 2023-02-25 ] | |||||||||||||||||||||||||||||||||||||||||||
|
Based on the SQL trace, it looks like the server may have been processing a large CREATE TABLE t6(c1 ENUM('a','abcdefghija.... statement. | |||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2023-02-25 ] | |||||||||||||||||||||||||||||||||||||||||||
|
By far it is easiest to troubleshoot recovery failures if the killed server was traced by rr record. If we do not have an exact trace of what happened before the recovery failed, it is very difficult to say what is causing the error. The circular write-ahead log file ib_logfile0 is 96MiB in size. The two checkpoint blocks in the file are as follows:
The second block starting at 0x2000 corresponds to the checkpoint LSN that was chosen for recovery, 989138 (0xf17d2). When I tried to recover from a copy of the data directory, recv_sys.lsn advanced up to 0x14f284. If we assume that the log file was never rebuilt (by backup or log resizing) and that the log had never wrapped around, the log file offsets should be equal to file offsets. The log file has not yet wrapped around, as we can see from the end of the output of od -Ax -t x1 ib_logfile0:
In the
The log payload area starts at 0x3000, and the header indicates that the first LSN corresponding to that offset is 0x3000. The last non-zero byte in the ib_logfile0 is right before 0x14f400 (1373184). The 5 bytes immediately before that look like the end of a mini-transaction. But, the error log mentions larger "LSN in the future" than that:
Okay, the last error message should be adjusted for The final recovered mini-transaction starts at LSN=1370507 (0x14e98b) and ends at 1372804 (0x14f284). Here is its log:
After the end-of-mini-transaction marker at 0x14f27f we have a CRC-32C of the mini-transaction. The byte at 0x14f284 is 0, which is not a valid first byte for a mini-transaction. The parsing of the log looks entirely correct to me. The log got somehow corrupted. How did you copy it? Could the mariadbd process still have been running while you already started copying files? Please note that killing a process is not instantaneous. See Please reproduce this bug with an rr record of the server process that was killed before the failed recovery. Only in that way we can know what went wrong when writing the log or the too-new data pages. As far as I can tell, there is nothing wrong with the recovery side. I would recommend building with cmake -DWITH_PMEM=ON and placing the ib_logfile0 somewhere under /dev/shm. In that way, the log writing can be much more conveniently debugged by setting data watchpoints on the log_sys.buf, which would be memory-mapped in that case. | |||||||||||||||||||||||||||||||||||||||||||
| Comment by Roel Van de Paar [ 2023-02-27 ] | |||||||||||||||||||||||||||||||||||||||||||
|
Thank you Marko for checking and debugging this. This was the first attempt at creating a quality ticket for some crash recovery issues I am seeing. Thank you also for the input, I am actioning this as suggested. | |||||||||||||||||||||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2023-02-27 ] | |||||||||||||||||||||||||||||||||||||||||||
|
Roel, my initial impression is that the server process had not been killed at the time when the data files were already being copied. With things like O_DIRECT ( | |||||||||||||||||||||||||||||||||||||||||||
| Comment by Roel Van de Paar [ 2023-02-27 ] | |||||||||||||||||||||||||||||||||||||||||||
|
marko Understood & thank you. After the kill -9 I added a wait, as well as a sync, and a further small delay of 2 seconds before copying. I trust that should suffice to cover any grounds. All runs are in /dev/shm. | |||||||||||||||||||||||||||||||||||||||||||
| Comment by Roel Van de Paar [ 2023-03-01 ] | |||||||||||||||||||||||||||||||||||||||||||
|
The issue did not reproduce on trunk (though other/different issues were observed, for which separate tickets will be created). | |||||||||||||||||||||||||||||||||||||||||||
| Comment by Roel Van de Paar [ 2023-03-04 ] | |||||||||||||||||||||||||||||||||||||||||||
|
Further testing against bb-11.0-oalter did not reproduce this issue. The time spend here was still very valuable as it sorted out the kinks in the crash recovery testing setup, and many other crash recovery issues were observed since. |