mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2025-02-19 15:30:17 +00:00
lib/mergeset: properly update lastAccesstime
in indexBlockCache entries
This is a follow-up for 6665f10e7b
This commit is contained in:
parent
170c1c3a4e
commit
cb2a2f281f
1 changed files with 5 additions and 5 deletions
|
@ -172,7 +172,7 @@ type indexBlockCache struct {
|
||||||
requests uint64
|
requests uint64
|
||||||
misses uint64
|
misses uint64
|
||||||
|
|
||||||
m map[uint64]indexBlockCacheEntry
|
m map[uint64]*indexBlockCacheEntry
|
||||||
mu sync.RWMutex
|
mu sync.RWMutex
|
||||||
|
|
||||||
cleanerStopCh chan struct{}
|
cleanerStopCh chan struct{}
|
||||||
|
@ -190,7 +190,7 @@ type indexBlockCacheEntry struct {
|
||||||
|
|
||||||
func newIndexBlockCache() *indexBlockCache {
|
func newIndexBlockCache() *indexBlockCache {
|
||||||
var idxbc indexBlockCache
|
var idxbc indexBlockCache
|
||||||
idxbc.m = make(map[uint64]indexBlockCacheEntry)
|
idxbc.m = make(map[uint64]*indexBlockCacheEntry)
|
||||||
idxbc.cleanerStopCh = make(chan struct{})
|
idxbc.cleanerStopCh = make(chan struct{})
|
||||||
idxbc.cleanerWG.Add(1)
|
idxbc.cleanerWG.Add(1)
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -248,10 +248,10 @@ var (
|
||||||
func (idxbc *indexBlockCache) Get(k uint64) *indexBlock {
|
func (idxbc *indexBlockCache) Get(k uint64) *indexBlock {
|
||||||
atomic.AddUint64(&idxbc.requests, 1)
|
atomic.AddUint64(&idxbc.requests, 1)
|
||||||
idxbc.mu.RLock()
|
idxbc.mu.RLock()
|
||||||
idxbe, ok := idxbc.m[k]
|
idxbe := idxbc.m[k]
|
||||||
idxbc.mu.RUnlock()
|
idxbc.mu.RUnlock()
|
||||||
|
|
||||||
if ok {
|
if idxbe != nil {
|
||||||
currentTime := atomic.LoadUint64(¤tTimestamp)
|
currentTime := atomic.LoadUint64(¤tTimestamp)
|
||||||
if atomic.LoadUint64(&idxbe.lastAccessTime) != currentTime {
|
if atomic.LoadUint64(&idxbe.lastAccessTime) != currentTime {
|
||||||
atomic.StoreUint64(&idxbe.lastAccessTime, currentTime)
|
atomic.StoreUint64(&idxbe.lastAccessTime, currentTime)
|
||||||
|
@ -284,7 +284,7 @@ func (idxbc *indexBlockCache) Put(k uint64, idxb *indexBlock) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Store idxb in the cache.
|
// Store idxb in the cache.
|
||||||
idxbe := indexBlockCacheEntry{
|
idxbe := &indexBlockCacheEntry{
|
||||||
lastAccessTime: atomic.LoadUint64(¤tTimestamp),
|
lastAccessTime: atomic.LoadUint64(¤tTimestamp),
|
||||||
idxb: idxb,
|
idxb: idxb,
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue