Skip to content

Commit

Permalink
Merge #32397
Browse files Browse the repository at this point in the history
32397: storage/tscache: improve debug info in panic msg for inverted range r=nvanbenschoten a=nvanbenschoten

Closes #32149 as unactionable past this point.

Release note: None

Co-authored-by: Nathan VanBenschoten <[email protected]>
  • Loading branch information
craig[bot] and nvanbenschoten committed Nov 15, 2018
2 parents 60fc55f + 40c378d commit 3b256be
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions pkg/storage/tscache/interval_skl.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import (

"github.com/cockroachdb/cockroach/pkg/util"
"github.com/cockroachdb/cockroach/pkg/util/hlc"
"github.com/cockroachdb/cockroach/pkg/util/interval"
"github.com/cockroachdb/cockroach/pkg/util/log"
"github.com/cockroachdb/cockroach/pkg/util/syncutil"
"github.com/cockroachdb/cockroach/pkg/util/uuid"
)
Expand Down Expand Up @@ -239,8 +239,17 @@ func (s *intervalSkl) AddRange(from, to []byte, opt rangeOptions, val cacheValue

switch {
case cmp > 0:
// Starting key is after ending key. This shouldn't happen.
panic(interval.ErrInvertedRange)
// Starting key is after ending key. This shouldn't happen. Determine
// the index where the keys diverged and panic.
d := 0
for d < len(from) && d < len(to) {
if from[d] != to[d] {
break
}
d++
}
panic(log.Safe(fmt.Sprintf("inverted range: key lens = [%d,%d), diff @ index %d",
len(from), len(to), d)))
case cmp == 0:
// Starting key is same as ending key, so just add single node.
if opt == (excludeFrom | excludeTo) {
Expand Down

0 comments on commit 3b256be

Please sign in to comment.