From bcfe2e6a5752ed29ed5d7b0ede65760912b4043d Mon Sep 17 00:00:00 2001 From: Paul Bardea Date: Tue, 22 Dec 2020 18:20:56 -0500 Subject: [PATCH] storageccl: tolerate rewriting span keys ending in interleaved sentinel Some index span keys have been observed to end with the interleaved sentinel value. It is not yet clear how these types of keys are created but from the perspective of the key-rewriter it has rewritten the key. Release note (sql change): Fix a bug in RESTORE where some unusual range boundaries in interleaved tables caused an error. --- pkg/ccl/storageccl/key_rewriter.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/ccl/storageccl/key_rewriter.go b/pkg/ccl/storageccl/key_rewriter.go index 91ef9536b2d9..3e4574377805 100644 --- a/pkg/ccl/storageccl/key_rewriter.go +++ b/pkg/ccl/storageccl/key_rewriter.go @@ -223,6 +223,11 @@ func (kr *KeyRewriter) RewriteKey(key []byte, isFromSpan bool) ([]byte, bool, er if !ok { return key, true, nil } + if len(k) == 0 { + // We have seen some span keys end in an interleaved sentinel. + // Check if we ran out of key before getting to an interleave child? + return key, true, nil + } prefix := key[:len(key)-len(k)] k, ok, err = kr.RewriteKey(k, isFromSpan) if err != nil {