Skip to content

Commit

Permalink
kv/bulk: ensure initial splits are safe split keys
Browse files Browse the repository at this point in the history
Release note: none.

Release justification: bug fix in new functionality.
  • Loading branch information
dt committed Mar 8, 2022
1 parent ea35476 commit 2a4f519
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/kv/bulk/buffering_adder.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import (
"strings"
"time"

"github.com/cockroachdb/cockroach/pkg/keys"
"github.com/cockroachdb/cockroach/pkg/kv"
"github.com/cockroachdb/cockroach/pkg/kv/kvclient/rangecache"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/kvserverbase"
Expand Down Expand Up @@ -392,7 +393,11 @@ func (b *BufferingAdder) createInitialSplits(ctx context.Context) error {
}
predicateAt = next
}
splitKey := b.curBuf.Key(splitAt)
splitKey, err := keys.EnsureSafeSplitKey(b.curBuf.Key(splitAt))
if err != nil {
log.Warningf(ctx, "failed to generate pre-split key for key %s", b.curBuf.Key(splitAt))
continue
}
predicateKey := b.curBuf.Key(predicateAt)
log.VEventf(ctx, 1, "pre-splitting span %d of %d at %s", i, b.initialSplits, splitKey)
resp, err := b.sink.db.SplitAndScatter(ctx, splitKey, expire, predicateKey)
Expand Down

0 comments on commit 2a4f519

Please sign in to comment.