diff --git a/tsdb/head_wal.go b/tsdb/head_wal.go index f6990d8bf..277410ad1 100644 --- a/tsdb/head_wal.go +++ b/tsdb/head_wal.go @@ -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