lib/storage: properly update link for entry at dateMetricID cache (#4258)

previously during sync for mutable and immutable cache parts, link for hotEntry with current date may be not properly updated
it corrupts cache for backfilling metrics and increased cpu load
This commit is contained in:
Nikolay 2023-05-06 06:45:47 +02:00 committed by Aliaksandr Valialkin
parent 370a421ef4
commit 8c9dc837b9
No known key found for this signature in database
GPG key ID: A72BEC6CD3D0DED1

View file

@ -2288,10 +2288,14 @@ func (dmc *dateMetricIDCache) syncLocked() {
}
v = v.Clone()
v.Union(&e.v)
byDateMutable.m[date] = &byDateMetricIDEntry{
dme := &byDateMetricIDEntry{
date: date,
v: *v,
}
if date == byDateMutable.hotEntry.Load().(*byDateMetricIDEntry).date {
byDateMutable.hotEntry.Store(dme)
}
byDateMutable.m[date] = dme
}
for date, e := range byDate.m {
v := byDateMutable.get(date)