mirror of
https://github.com/prometheus/prometheus.git
synced 2025-01-30 07:03:06 -08:00
Fix accidental publishing of memorySeries.firstTime()
This commit is contained in:
parent
ab80ced756
commit
d30a3c7c0f
|
@ -288,7 +288,7 @@ func (s *memorySeries) maybeCloseHeadChunk() bool {
|
||||||
func (s *memorySeries) evictChunkDescs(iOldestNotEvicted int) {
|
func (s *memorySeries) evictChunkDescs(iOldestNotEvicted int) {
|
||||||
lenToKeep := chunkDescEvictionFactor * (len(s.chunkDescs) - iOldestNotEvicted)
|
lenToKeep := chunkDescEvictionFactor * (len(s.chunkDescs) - iOldestNotEvicted)
|
||||||
if lenToKeep < len(s.chunkDescs) {
|
if lenToKeep < len(s.chunkDescs) {
|
||||||
s.savedFirstTime = s.FirstTime()
|
s.savedFirstTime = s.firstTime()
|
||||||
lenEvicted := len(s.chunkDescs) - lenToKeep
|
lenEvicted := len(s.chunkDescs) - lenToKeep
|
||||||
s.chunkDescsOffset += lenEvicted
|
s.chunkDescsOffset += lenEvicted
|
||||||
s.persistWatermark -= lenEvicted
|
s.persistWatermark -= lenEvicted
|
||||||
|
@ -514,7 +514,7 @@ func (s *memorySeries) head() *chunk.Desc {
|
||||||
// firstTime returns the timestamp of the first sample in the series.
|
// firstTime returns the timestamp of the first sample in the series.
|
||||||
//
|
//
|
||||||
// The caller must have locked the fingerprint of the memorySeries.
|
// The caller must have locked the fingerprint of the memorySeries.
|
||||||
func (s *memorySeries) FirstTime() model.Time {
|
func (s *memorySeries) firstTime() model.Time {
|
||||||
if s.chunkDescsOffset == 0 && len(s.chunkDescs) > 0 {
|
if s.chunkDescsOffset == 0 && len(s.chunkDescs) > 0 {
|
||||||
return s.chunkDescs[0].FirstTime()
|
return s.chunkDescs[0].FirstTime()
|
||||||
}
|
}
|
||||||
|
|
|
@ -657,7 +657,7 @@ func (s *MemorySeriesStorage) metricForRange(
|
||||||
) (model.Metric, *memorySeries, bool) {
|
) (model.Metric, *memorySeries, bool) {
|
||||||
series, ok := s.fpToSeries.get(fp)
|
series, ok := s.fpToSeries.get(fp)
|
||||||
if ok {
|
if ok {
|
||||||
if series.lastTime.Before(from) || series.FirstTime().After(through) {
|
if series.lastTime.Before(from) || series.firstTime().After(through) {
|
||||||
return nil, nil, false
|
return nil, nil, false
|
||||||
}
|
}
|
||||||
return series.metric, series, true
|
return series.metric, series, true
|
||||||
|
@ -1264,7 +1264,7 @@ func (s *MemorySeriesStorage) maintainMemorySeries(
|
||||||
if iOldestNotEvicted == -1 && model.Now().Sub(series.lastTime) > headChunkTimeout {
|
if iOldestNotEvicted == -1 && model.Now().Sub(series.lastTime) > headChunkTimeout {
|
||||||
s.fpToSeries.del(fp)
|
s.fpToSeries.del(fp)
|
||||||
s.numSeries.Dec()
|
s.numSeries.Dec()
|
||||||
s.persistence.archiveMetric(fp, series.metric, series.FirstTime(), series.lastTime)
|
s.persistence.archiveMetric(fp, series.metric, series.firstTime(), series.lastTime)
|
||||||
s.seriesOps.WithLabelValues(archive).Inc()
|
s.seriesOps.WithLabelValues(archive).Inc()
|
||||||
oldWatermark := atomic.LoadInt64((*int64)(&s.archiveHighWatermark))
|
oldWatermark := atomic.LoadInt64((*int64)(&s.archiveHighWatermark))
|
||||||
if oldWatermark < int64(series.lastTime) {
|
if oldWatermark < int64(series.lastTime) {
|
||||||
|
@ -1325,7 +1325,7 @@ func (s *MemorySeriesStorage) writeMemorySeries(
|
||||||
chunks[i] = cd.C
|
chunks[i] = cd.C
|
||||||
}
|
}
|
||||||
|
|
||||||
if !series.FirstTime().Before(beforeTime) {
|
if !series.firstTime().Before(beforeTime) {
|
||||||
// Oldest sample not old enough, just append chunks, if any.
|
// Oldest sample not old enough, just append chunks, if any.
|
||||||
if len(cds) == 0 {
|
if len(cds) == 0 {
|
||||||
return false
|
return false
|
||||||
|
|
|
@ -69,7 +69,7 @@ func TestMatches(t *testing.T) {
|
||||||
t.Fatal("could not retrieve series for fp", fp)
|
t.Fatal("could not retrieve series for fp", fp)
|
||||||
}
|
}
|
||||||
storage.fpLocker.Lock(fp)
|
storage.fpLocker.Lock(fp)
|
||||||
storage.persistence.archiveMetric(fp, s.metric, s.FirstTime(), s.lastTime)
|
storage.persistence.archiveMetric(fp, s.metric, s.firstTime(), s.lastTime)
|
||||||
storage.fpLocker.Unlock(fp)
|
storage.fpLocker.Unlock(fp)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1276,7 +1276,7 @@ func testEvictAndPurgeSeries(t *testing.T, encoding chunk.Encoding) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
s.persistence.archiveMetric(fp, series.metric, series.FirstTime(), lastTime)
|
s.persistence.archiveMetric(fp, series.metric, series.firstTime(), lastTime)
|
||||||
archived, _, _ := s.persistence.hasArchivedMetric(fp)
|
archived, _, _ := s.persistence.hasArchivedMetric(fp)
|
||||||
if !archived {
|
if !archived {
|
||||||
t.Fatal("not archived")
|
t.Fatal("not archived")
|
||||||
|
@ -1317,7 +1317,7 @@ func testEvictAndPurgeSeries(t *testing.T, encoding chunk.Encoding) {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
s.persistence.archiveMetric(fp, series.metric, series.FirstTime(), lastTime)
|
s.persistence.archiveMetric(fp, series.metric, series.firstTime(), lastTime)
|
||||||
archived, _, _ = s.persistence.hasArchivedMetric(fp)
|
archived, _, _ = s.persistence.hasArchivedMetric(fp)
|
||||||
if !archived {
|
if !archived {
|
||||||
t.Fatal("not archived")
|
t.Fatal("not archived")
|
||||||
|
|
Loading…
Reference in a new issue