MCPcopy
hub / github.com/prometheus/prometheus / resetInMemoryState

Method resetInMemoryState

tsdb/head.go:346–390  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

344}
345
346func (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
392func (h *Head) resetWLReplayResources() {
393 h.wlReplaySeriesPool = zeropool.Pool[[]record.RefSeries]{}

Callers 3

NewHeadFunction · 0.95
InitMethod · 0.95

Calls 11

NewUnorderedMemPostingsFunction · 0.92
NewMemTombstonesFunction · 0.92
NewExemplarMetricsFunction · 0.85
newIsolationFunction · 0.85
newOOOIsolationFunction · 0.85
iterForDeletionMethod · 0.80
newStripeSeriesFunction · 0.70
LoadMethod · 0.65
AddMethod · 0.65
StoreMethod · 0.65

Tested by

no test coverage detected