sstable: audit and clean up instances of improper key comparisons in the presence of synthetic prefixes/suffixes #4136
Labels
A-storage
C-bug
Something isn't working
O-testcluster
Issues found as part of DRT testing
P-3
Issues/test failures with no fix SLA
T-storage
Currently, a lot of the code around synthetic prefixes assumes that the comparer holds the property of
Compare(x+a, x+b) == Compare(a, b)
for any prefixx
and arbitrary bytesa,b
. This is true for the metamorphic test's comparer, but not for the Cockroach comparer where if the bytes immediately afterx
denote a local or range-local key, they'll sort before all other keys and break this property.Here's an example of CopySpan being called with the prefix trimmed away:
pebble/compaction.go
Line 2440 in 1af22dc
And here we call the comparer with the trimmed key, which is invalid:
pebble/sstable/copier.go
Line 253 in 1af22dc
In the rowblk (and probably also colblk) iterator code, we also do a similar trimming of synthetic prefixes from seek keys before calling the comparer on the remainder, which is invalid:
pebble/sstable/rowblk/rowblk_iter.go
Line 542 in 1af22dc
For this reason, in the presence of synthetic prefixes and prefixless sstables, we should materialize the full key before calling the comparer anywhere.
Cockroach companion issue: cockroachdb/cockroach#134168
Jira issue: PEBBLE-296
The text was updated successfully, but these errors were encountered: