[MDEV-29559] Recovery of INSERT_HEAP_DYNAMIC into secondary index fails Created: 2022-09-16 Updated: 2022-09-19 Resolved: 2022-09-19 |
|
| Status: | Closed |
| Project: | MariaDB Server |
| Component/s: | Storage Engine - InnoDB |
| Affects Version/s: | 10.5, 10.6, 10.7, 10.8, 10.9, 10.10 |
| Fix Version/s: | 10.5.18, 10.6.11, 10.7.7, 10.8.6, 10.9.4, 10.10.2 |
| Type: | Bug | Priority: | Major |
| Reporter: | Elena Stepanova | Assignee: | Marko Mäkelä |
| Resolution: | Fixed | Votes: | 1 |
| Labels: | None | ||
| Issue Links: |
|
||||||||
| Description |
|
10.6+ produces a bit more output
Reproducible on 10.5-10.10, including older minor releases. |
| Comments |
| Comment by Marko Mäkelä [ 2022-09-19 ] | ||||||||||||||||||||||||
|
Here is a slightly simpler test case. The important part is that the first byte of the record must be 0x69, matching the first byte of the infimum pseudo-record:
| ||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2022-09-19 ] | ||||||||||||||||||||||||
|
The recovery fails because the log record parser throws an error. The problematic mini-transaction log is as follows:
Parsing the INSERT_HEAP_DYNAMIC record fails because of an off-by-one error:
In this case, the secondary index record is (a)=(0x69), and all of the data will have been copied from the infimum record. The data_len=rlen-ll that will be passed to page_apply_insert_dynamic() will be 0. | ||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2022-09-19 ] | ||||||||||||||||||||||||
|
The reason why a variant of this test case with ROW_FORMAT=REDUNDANT does not fail is that the INSERT_HEAP_REDUNDANT record would include 1 literal byte of record header. I even tried a variant where the length of the field would match the infimum pseudo-record:
The reason why the header is not being copied from the infimum pseudo-record is that the following condition in page_cur_insert_rec_low() will not hold:
In other words, the following adjustment to the ROW_FORMAT=REDUNDANT parsing code is not strictly necessary, because some literal bytes will always be present in the log record:
| ||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2022-09-19 ] | ||||||||||||||||||||||||
|
An INSERT of a single record (not 2 records as in the test case) could fail like this:
| ||||||||||||||||||||||||
| Comment by Marko Mäkelä [ 2022-09-19 ] | ||||||||||||||||||||||||
|
I believe that this only affects secondary indexes where the keys are fixed length and the data encodes to a prefix of the string infimum and a NUL byte. This could affect the insert of the first record into any secondary index leaf page. |