Skip to content

Commit

Permalink
row: only store the accounted for memory if the reservation is approved
Browse files Browse the repository at this point in the history
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.

Release note: None
  • Loading branch information
yuzefovich committed Jul 8, 2022
1 parent 2dd8e76 commit bc21b0a
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 bc21b0a

Please sign in to comment.