()
| 344 | } |
| 345 | |
| 346 | func (h *Head) resetInMemoryState() error { |
| 347 | var err error |
| 348 | var em *ExemplarMetrics |
| 349 | if h.exemplars != nil { |
| 350 | ce, ok := h.exemplars.(*CircularExemplarStorage) |
| 351 | if ok { |
| 352 | em = ce.metrics |
| 353 | } |
| 354 | } |
| 355 | if em == nil { |
| 356 | em = NewExemplarMetrics(h.reg) |
| 357 | } |
| 358 | es, err := NewCircularExemplarStorage(h.opts.MaxExemplars.Load(), em, h.opts.OutOfOrderTimeWindow.Load()) |
| 359 | if err != nil { |
| 360 | return err |
| 361 | } |
| 362 | |
| 363 | if h.series != nil { |
| 364 | // reset the existing series to make sure we call the appropriated hooks |
| 365 | // and increment the series removed metrics |
| 366 | fs := h.series.iterForDeletion(func(_ int, _ uint64, s *memSeries, flushedForCallback map[chunks.HeadSeriesRef]labels.Labels) { |
| 367 | // All series should be flushed |
| 368 | flushedForCallback[s.ref] = s.lset |
| 369 | }) |
| 370 | h.metrics.seriesRemoved.Add(float64(fs)) |
| 371 | } |
| 372 | |
| 373 | h.series = newStripeSeries(h.opts.StripeSize, h.opts.SeriesCallback) |
| 374 | h.iso = newIsolation(h.opts.IsolationDisabled) |
| 375 | h.oooIso = newOOOIsolation() |
| 376 | h.numSeries.Store(0) |
| 377 | h.exemplarMetrics = em |
| 378 | h.exemplars = es |
| 379 | h.postings = index.NewUnorderedMemPostings() |
| 380 | h.tombstones = tombstones.NewMemTombstones() |
| 381 | h.walExpiries = map[chunks.HeadSeriesRef]int64{} |
| 382 | h.chunkRange.Store(h.opts.ChunkRange) |
| 383 | h.minTime.Store(math.MaxInt64) |
| 384 | h.maxTime.Store(math.MinInt64) |
| 385 | h.minOOOTime.Store(math.MaxInt64) |
| 386 | h.maxOOOTime.Store(math.MinInt64) |
| 387 | h.lastWALTruncationTime.Store(math.MinInt64) |
| 388 | h.lastMemoryTruncationTime.Store(math.MinInt64) |
| 389 | return nil |
| 390 | } |
| 391 | |
| 392 | func (h *Head) resetWLReplayResources() { |
| 393 | h.wlReplaySeriesPool = zeropool.Pool[[]record.RefSeries]{} |
no test coverage detected