Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "kvstreamer: reuse incomplete Get requests on resume batches" #84143

Merged
merged 1 commit into from
Jul 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions pkg/kv/kvclient/kvstreamer/streamer.go
Original file line number Diff line number Diff line change
Expand Up @@ -1567,6 +1567,14 @@ func buildResumeSingleRangeBatch(
// requests with the ResumeSpans.
resumeReq.reqsReservedBytes = fp.resumeReqsMemUsage
resumeReq.overheadAccountedFor = req.overheadAccountedFor
// Note that due to limitations of the KV layer (#75452) we cannot reuse
// original requests because the KV doesn't allow mutability (and all
// requests are modified by txnSeqNumAllocator, even if they are not
// evaluated due to TargetBytes limit).
gets := make([]struct {
req roachpb.GetRequest
union roachpb.RequestUnion_Get
}, fp.numIncompleteGets)
scans := make([]struct {
req roachpb.ScanRequest
union roachpb.RequestUnion_Scan
Expand All @@ -1583,18 +1591,14 @@ func buildResumeSingleRangeBatch(
emptyResponse = false
continue
}
// This Get wasn't completed - include it into the batch again (we
// can just reuse the original request since it hasn't been
// modified which is also asserted below).
if buildutil.CrdbTestBuild {
if origSpan := req.reqs[i].GetInner().Header().Span(); !get.ResumeSpan.Equal(origSpan) {
panic(errors.AssertionFailedf(
"unexpectedly the ResumeSpan %s on the GetResponse is different from the original span %s",
get.ResumeSpan, origSpan,
))
}
}
resumeReq.reqs[resumeReqIdx] = req.reqs[i]
// This Get wasn't completed - create a new request according to the
// ResumeSpan and include it into the batch.
newGet := gets[0]
gets = gets[1:]
newGet.req.SetSpan(*get.ResumeSpan)
newGet.req.KeyLocking = s.keyLocking
newGet.union.Get = &newGet.req
resumeReq.reqs[resumeReqIdx].Value = &newGet.union
resumeReq.positions = append(resumeReq.positions, position)
if req.subRequestIdx != nil {
resumeReq.subRequestIdx = append(resumeReq.subRequestIdx, req.subRequestIdx[i])
Expand Down