Skip to content

Conversation

inikep
Copy link
Collaborator

@inikep inikep commented Sep 24, 2025

Index fields consist of many Rdb_field_packing records.
Each record consist of:

    (1) [ index flags (opt) ]
    (2) [ tag (1 byte) ]
    (3) [ length (2 bytes, if tag==DATA_TAG) ]
    (4) [ covered bitmap (2 bytes, opt) ]
    (5) [ per-field metadata ]
    (6) [ checksum section (opt) ]

Rdb_key_field_iterator::next() calls Rdb_convert_to_record_key_decoder::skip() when
iterating thru index fields. For data created with make_unpack_unknown_varlength() the
skip function moves forward only a key slice reader but an unpack information reader
should also be moved forward (per-field metadata (5) should be consumed).

The solution is based on unpack_unknown_varlength at https://github.com/percona/percona-server/blob/4f842346452d/storage/rocksdb/rdb_datadic.cc#L3571-L3588
It simulates unpacking and skips unpacked data.

…or index

`unpack_info` consist of:
```
(1) [ index flags (opt) ]
(2) [ tag (1 byte) ]
(3) [ length (2 bytes, if tag==DATA_TAG) ]
(4) [ covered bitmap (2 bytes, opt) ]
(5) [ per-field metadata ]
(6) [ checksum section (opt) ]
```
`unp_reader` in `Rdb_key_def::unpack_record` consumes an `unpack_info` header ((1) to (4))
but for some data types and lenghts per-field metadata (5) is not be consumed and
`Rdb_key_def::unpack_record` tries to read checksum section (6) still pointing at (5) what
causes the checksum mismatch error.

To fix the issue we may:
a) skip per-field metadata (5) and move to checksum section (6) but it requires
   implementation for each data type that doesn't consume it's metadata
b) check if `unp_reader` is already moved to checksum section (6) and skip checksum
   checking in other cases
Copy link
Collaborator

@percona-ysorokin percona-ysorokin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

…d_key_decoder::skip`

Index fields consist of many `Rdb_field_packing` records.
Each record consist of:

```
(1) [ index flags (opt) ]
(2) [ tag (1 byte) ]
(3) [ length (2 bytes, if tag==DATA_TAG) ]
(4) [ covered bitmap (2 bytes, opt) ]
(5) [ per-field metadata ]
(6) [ checksum section (opt) ]
```

`Rdb_key_field_iterator::next()` calls `Rdb_convert_to_record_key_decoder::skip()` when
iterating thru index fields. For data created with `make_unpack_unknown_varlength()` the
skip function moves forward only a key slice reader but an unpack information reader
should also be moved forward (per-field metadata (5) should be consumed).

The solution is based on `unpack_unknown_varlength` at https://github.com/percona/percona-server/blob/4f842346452d/storage/rocksdb/rdb_datadic.cc#L3571-L3588
It simulates unpacking and skips unpacked data.
@inikep inikep merged commit b2109a4 into percona:8.0 Sep 25, 2025
20 of 23 checks passed
@inikep inikep deleted the PS-10075-8.0 branch September 25, 2025 09:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants