Skip to content

Commit

Permalink
sstable: reconcile out-of-order key error messages
Browse files Browse the repository at this point in the history
When keys are written to a sstable writer out-of-order, the writer returns an
error message. The error messages returned from the row-based and column-based
writers varied, in part because the columnar writer did not readily have the
previous key at hand. This commit adapts the column writer to synthesize the
previous user key for the purpose of embedding it within the returned error
message.
  • Loading branch information
jbowens committed Nov 9, 2024
1 parent af08671 commit b3c73d8
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
7 changes: 6 additions & 1 deletion sstable/colblk_writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -536,8 +536,13 @@ func (w *RawColumnWriter) evaluatePoint(

if !w.disableKeyOrderChecks && (eval.kcmp.UserKeyComparison < 0 ||
(eval.kcmp.UserKeyComparison == 0 && w.prevPointKey.trailer <= key.Trailer)) {
previousKey := base.InternalKey{
UserKey: w.dataBlock.MaterializeLastUserKey(nil),
Trailer: w.prevPointKey.trailer,
}
return eval, errors.Errorf(
"pebble: keys must be added in strictly increasing order: %s",
"pebble: keys must be added in strictly increasing order: %s, %s",
previousKey.Pretty(w.comparer.FormatKey),
key.Pretty(w.comparer.FormatKey))
}

Expand Down
4 changes: 2 additions & 2 deletions sstable/testdata/writer_v5
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,13 @@ build
a.SET.1:b
a.SET.2:c
----
pebble: keys must be added in strictly increasing order: a#2,SET
pebble: keys must be added in strictly increasing order: a#1,SET, a#2,SET

build
b.SET.1:a
a.SET.2:b
----
pebble: keys must be added in strictly increasing order: a#2,SET
pebble: keys must be added in strictly increasing order: b#1,SET, a#2,SET

build
b.RANGEDEL.1:c
Expand Down

0 comments on commit b3c73d8

Please sign in to comment.