Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
84048: row: only store the accounted for memory if the reservation is approved r=yuzefovich a=yuzefovich

Previously, we would update the counter about the reserved memory before
doing the reservation. If that reservation is denied, then later on, in
`txnKVFetcher.close` we could try to release more memory than we
registered. This is now fixed.

Addresses: cockroachdb#83935.

Release note: None

Co-authored-by: Yahor Yuzefovich <[email protected]>
  • Loading branch information
craig[bot] and yuzefovich committed Jul 9, 2022
2 parents ddb5c3d + bc21b0a commit 6374bd8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pkg/sql/row/kv_batch_fetcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -356,10 +356,11 @@ func (f *txnKVFetcher) SetupNextFetch(

// Account for the memory of the spans that we're taking the ownership of.
if f.acc != nil {
f.spansAccountedFor = spans.MemUsage()
if err := f.acc.Grow(ctx, f.spansAccountedFor); err != nil {
newSpansAccountedFor := spans.MemUsage()
if err := f.acc.Grow(ctx, newSpansAccountedFor); err != nil {
return err
}
f.spansAccountedFor = newSpansAccountedFor
}

if spanIDs != nil && len(spans) != len(spanIDs) {
Expand Down

0 comments on commit 6374bd8

Please sign in to comment.