Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix handling of consecutive sentinel values
Summary: For partial indexes, it is possible to have consecutive sentinel values, and the code to skip over sentinel values during iteration does not handle this correctly. eg. If we have have the following data: ``` a b 1 1 (sentinel) 1 2 (sentinel) 1 2 1 1 2 2 ``` `get_prefix_from_start` returns `(1, 2)` as the group we expect to see (since `(1, 1)` group is empty on the primary key). A seek to `a >=1` on the secondary key would land on `(1, 1)`, but we skip this key since we detect that it's a sentinel value. The cursor is then on `(1, 2)` which matches the expected prefix, and we start reading from the SK from that position. However, this is also a sentinel value, and will not decode correctly. This leads to these errors: ``` ERROR 1296 (HY000): Got error 505 'Found data corruption.' from ROCKSDB ``` The fix is to use a while loop to skip over sentinel values. There are two other places where we skip over sentinel values, but they are not problematic since they are used for iterating over a non-empty groups (so consecutive sentinel values are not possible). I decided not to add while loops defensively in the other places, so that we fail loudly if something unexpected happens. Ideally, we should just seek directly to the first group that we got from the PK (which guarantees a non-empty group, similar to other cases), but this is a more involved change for later. Differential Revision: D46352747
- Loading branch information