Skip to content

Commit

Permalink
[pebble cache] close the iter when e.samples is blocked (#6908)
Browse files Browse the repository at this point in the history
  • Loading branch information
luluz66 authored and bduffany committed Jun 25, 2024
1 parent 4c07f97 commit a10c1f6
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions enterprise/server/backends/pebble_cache/pebble_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -2547,7 +2547,9 @@ func (e *partitionEvictor) generateSamplesForEviction(quitChan chan struct{}) er
// We update the iter variable later on, so we need to wrap the Close call
// in a func to operate on the correct iterator instance.
defer func() {
iter.Close()
if iter != nil {
iter.Close()
}
}()

totalCount := 0
Expand Down Expand Up @@ -2593,7 +2595,9 @@ func (e *partitionEvictor) generateSamplesForEviction(quitChan chan struct{}) er
if err != nil {
return err
}
iter.Close()
if iter != nil {
iter.Close()
}
iter = newIter
}
totalCount += 1
Expand Down Expand Up @@ -2650,9 +2654,22 @@ func (e *partitionEvictor) generateSamplesForEviction(quitChan chan struct{}) er
case e.samples <- sample:
case <-quitChan:
return nil
default:
// e.samples is full. Let's close the iter first, so that zombie
// tables can be cleaned up by pebble.
iter.Close()
shouldCreateNewIter = true
iter = nil
select {
case e.samples <- sample:
case <-quitChan:
return nil
}
}
}
iter.Next()
if iter != nil {
iter.Next()
}
fileMetadata.ResetVT()
}
}
Expand Down

0 comments on commit a10c1f6

Please sign in to comment.