Fix race condition when updating lastSeriesID during loading chunk snapshot (#11099)

Signed-off-by: Xiaochao Dong (@damnever) <the.xcdong@gmail.com>
pull/11117/head
Xiaochao Dong 2 years ago committed by GitHub
parent 4035b38c59
commit 1078081aec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -921,8 +921,12 @@ func (h *Head) loadChunkSnapshot() (int, int, map[chunks.HeadSeriesRef]*memSerie
return
}
localRefSeries[csr.ref] = series
if chunks.HeadSeriesRef(h.lastSeriesID.Load()) < series.ref {
h.lastSeriesID.Store(uint64(series.ref))
for {
seriesID := uint64(series.ref)
lastSeriesID := h.lastSeriesID.Load()
if lastSeriesID >= seriesID || h.lastSeriesID.CAS(lastSeriesID, seriesID) {
break
}
}
series.chunkRange = csr.chunkRange

Loading…
Cancel
Save