@ -296,8 +296,7 @@ func TestPlanStatsLoadTimeout(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestPlanStatsStatusRecord(t *testing.T) {
|
||||
restore := config.RestoreFunc()
|
||||
defer restore()
|
||||
defer config.RestoreFunc()()
|
||||
config.UpdateGlobal(func(conf *config.Config) {
|
||||
conf.Performance.EnableStatsCacheMemQuota = true
|
||||
})
|
||||
|
||||
@ -117,6 +117,11 @@ func DropEvicted(item statistics.TableCacheItem) {
|
||||
}
|
||||
|
||||
func (s *LFU) onEvict(item *ristretto.Item) {
|
||||
if item.Value == nil {
|
||||
// Sometimes the same key may be passed to the "onEvict/onExit" function twice,
|
||||
// and in the second invocation, the value is empty, so it should not be processed.
|
||||
return
|
||||
}
|
||||
// We do not need to calculate the cost during onEvict, because the onexit function
|
||||
// is also called when the evict event occurs.
|
||||
metrics.EvictCounter.Inc()
|
||||
@ -135,6 +140,11 @@ func (s *LFU) onEvict(item *ristretto.Item) {
|
||||
}
|
||||
|
||||
func (s *LFU) onExit(val interface{}) {
|
||||
if val == nil {
|
||||
// Sometimes the same key may be passed to the "onEvict/onExit" function twice,
|
||||
// and in the second invocation, the value is empty, so it should not be processed.
|
||||
return
|
||||
}
|
||||
s.cost.Add(-1 * val.(*statistics.Table).MemoryUsage().TotalTrackingMemUsage())
|
||||
metrics.CostGauge.Set(float64(s.cost.Load()))
|
||||
}
|
||||
|
||||
1
statistics/handle/cache/statscacheinner.go
vendored
1
statistics/handle/cache/statscacheinner.go
vendored
@ -161,6 +161,7 @@ func (sc *StatsCache) SetCapacity(c int64) {
|
||||
// Close stops the cache.
|
||||
func (sc *StatsCache) Close() {
|
||||
sc.c.Close()
|
||||
logutil.BgLogger().Info("closed LFU cache")
|
||||
}
|
||||
|
||||
// Version returns the version of the current cache, which is defined as
|
||||
|
||||
Reference in New Issue
Block a user