Skip to content

Commit

Permalink
kv: shallow copy {,Reverse}ScanResponse.{BatchResponses,ColBatches} w…
Browse files Browse the repository at this point in the history
…hen pipelining

Fixes #121759.

This commit updates ScanResponse and ReverseScanResponse's ShallowCopy
implementations to perform a shallow copy of the BatchResponses and
ColBatches slices. These are both slices of data array slices which can
be mutated by `popBatch`, even though the underlying data slices are
immutable.

Release note: None
  • Loading branch information
nvanbenschoten committed Apr 4, 2024
1 parent 81bbed6 commit f0ad5e3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/kv/kvpb/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1358,12 +1358,16 @@ func (crr *RevertRangeResponse) ShallowCopy() Response {
// ShallowCopy implements the Response interface.
func (sr *ScanResponse) ShallowCopy() Response {
shallowCopy := *sr
shallowCopy.BatchResponses = append([][]byte(nil), sr.BatchResponses...)
shallowCopy.ColBatches.ColBatches = append([]coldata.Batch(nil), sr.ColBatches.ColBatches...)
return &shallowCopy
}

// ShallowCopy implements the Response interface.
func (rsr *ReverseScanResponse) ShallowCopy() Response {
shallowCopy := *rsr
shallowCopy.BatchResponses = append([][]byte(nil), rsr.BatchResponses...)
shallowCopy.ColBatches.ColBatches = append([]coldata.Batch(nil), rsr.ColBatches.ColBatches...)
return &shallowCopy
}

Expand Down

0 comments on commit f0ad5e3

Please sign in to comment.