Skip to content

Commit

Permalink
sstable: assert invariant when range key is added to Writer
Browse files Browse the repository at this point in the history
This pr adds an invariant check behing the invariants.Enabled
flag to confirm that the start/end bounds of the range keys
added to the Writer are not the same.
  • Loading branch information
bananabrick committed Nov 9, 2022
1 parent 6189b5c commit 7b30bd8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions sstable/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -970,6 +970,11 @@ func (w *Writer) AddRangeKey(key InternalKey, value []byte) error {
}

func (w *Writer) addRangeKeySpan(span keyspan.Span) error {
if w.compare(span.Start, span.End) >= 0 {
return errors.Errorf(
"pebble: start key must be strictly less than end key",
)
}
if w.fragmenter.Start() != nil && w.compare(w.fragmenter.Start(), span.Start) > 0 {
return errors.Errorf("pebble: spans must be added in order: %s > %s",
w.formatKey(w.fragmenter.Start()), w.formatKey(span.Start))
Expand Down

0 comments on commit 7b30bd8

Please sign in to comment.