Skip to content

Commit

Permalink
kvserver: remove the assertion on not exceeding MaxSpanRequestKeys
Browse files Browse the repository at this point in the history
This commit fixes the bug in a recently merged commit where we allowed
to exceed `MaxSpanRequestKeys` in some cases - we forgot to update the
remaining limit to be "exhausted". Furthermore, this commit removes the
assertion altogether.

Epic: None

Release note: None
  • Loading branch information
yuzefovich committed Dec 2, 2022
1 parent a475947 commit 002c75e
Showing 1 changed file with 5 additions and 13 deletions.
18 changes: 5 additions & 13 deletions pkg/kv/kvserver/replica_evaluate.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"github.com/cockroachdb/cockroach/pkg/util/hlc"
"github.com/cockroachdb/cockroach/pkg/util/log"
"github.com/cockroachdb/errors"
"github.com/cockroachdb/redact"
"github.com/kr/pretty"
)

Expand Down Expand Up @@ -404,20 +403,13 @@ func evaluateBatch(
// the batch, but with limit-aware operations returning no data.
h := reply.Header()
if limit, retResults := baHeader.MaxSpanRequestKeys, h.NumKeys; limit != 0 && retResults > 0 {
if retResults > limit {
exceedingAllowed := baHeader.WholeRowsOfSize != 0 && !baHeader.AllowEmpty
if !exceedingAllowed {
index, retResults, limit := index, retResults, limit // don't alloc unless branch taken
return nil, mergedResult, roachpb.NewError(errors.AssertionFailedf(
"received %d results, limit was %d (original limit: %d, batch=%s idx=%d)",
retResults, limit, ba.Header.MaxSpanRequestKeys,
redact.Safe(ba.Summary()), index))
}
} else if retResults < limit {
if retResults < limit {
baHeader.MaxSpanRequestKeys -= retResults
} else {
// They were equal, so drop to -1 instead of zero (which would
// mean "no limit").
// The limit was either exceeded (which is allowed in some cases
// like when WholeRowsOfSize is set and AllowEmpty is false) or
// was exactly used up, so drop to -1 instead of zero (which
// would mean "no limit").
baHeader.MaxSpanRequestKeys = -1
}
}
Expand Down

0 comments on commit 002c75e

Please sign in to comment.