diff --git a/tsdb/head.go b/tsdb/head.go index 47f85d7713..4fbb4b5710 100644 --- a/tsdb/head.go +++ b/tsdb/head.go @@ -1730,6 +1730,11 @@ func (h *Head) getOrCreateWithID(id chunks.HeadSeriesRef, hash uint64, lset labe h.numSeries.Inc() h.postings.Add(storage.SeriesRef(id), lset) + + // Adding the series in the postings marks the creation of series + // as any further calls to this and the read methods would return that series. + h.series.postCreation(lset) + return s, true, nil } @@ -2037,9 +2042,6 @@ func (s *stripeSeries) getOrSet(hash uint64, lset labels.Labels, createSeries fu // The callback prevented creation of series. return nil, false, preCreationErr } - // Setting the series in the s.hashes marks the creation of series - // as any further calls to this methods would return that series. - s.seriesLifecycleCallback.PostCreation(series.labels()) i = uint64(series.ref) & uint64(s.size-1) @@ -2050,6 +2052,10 @@ func (s *stripeSeries) getOrSet(hash uint64, lset labels.Labels, createSeries fu return series, true, nil } +func (s *stripeSeries) postCreation(lset labels.Labels) { + s.seriesLifecycleCallback.PostCreation(lset) +} + type sample struct { t int64 f float64