Call PostCreation callback only after the new series is added to the mempotings (#15579)

Signed-off-by: alanprot <alanprot@gmail.com>
This commit is contained in:
Alan Protasio 2025-01-28 03:11:58 -08:00 committed by GitHub
parent 6823f58e59
commit 9d1abbb9ed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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