Skip to content

Commit 7a51a94

Browse files
committed
fix(cache): make updating the max cost of posting cache work again
1 parent 8c2875f commit 7a51a94

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

posting/lists.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,6 @@ func SetEnabledDetailedMetrics(enableMetrics bool) {
4646
EnableDetailedMetrics = enableMetrics
4747
}
4848

49-
func UpdateMaxCost(maxCost int64) {
50-
}
51-
5249
// Cleanup waits until the closer has finished processing.
5350
func Cleanup() {
5451
closer.SignalAndWait()

posting/mvcc.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,6 +405,13 @@ func (ml *MemoryLayer) del(key []byte) {
405405
ml.cache.del(key)
406406
}
407407

408+
func (ml *MemoryLayer) UpdateMaxCost(maxCost int64) {
409+
if ml.cache == nil || ml.cache.data == nil {
410+
return
411+
}
412+
ml.cache.data.UpdateMaxCost(maxCost)
413+
}
414+
408415
type IterateDiskArgs struct {
409416
Prefix []byte
410417
Prefetch bool

worker/worker.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,9 @@ func UpdateCacheMb(memoryMB int64) error {
150150
blockCacheSize := (cachePercent[1] * (memoryMB << 20)) / 100
151151
indexCacheSize := (cachePercent[2] * (memoryMB << 20)) / 100
152152

153-
posting.UpdateMaxCost(plCacheSize)
153+
if posting.MemLayerInstance != nil {
154+
posting.MemLayerInstance.UpdateMaxCost(plCacheSize)
155+
}
154156
if _, err := pstore.CacheMaxCost(badger.BlockCache, blockCacheSize); err != nil {
155157
return errors.Wrapf(err, "cannot update block cache size")
156158
}

0 commit comments

Comments
 (0)