mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Fix handling of empty chunkDescs while preloading chunks.
Change-Id: I73ce89fe0ef90c6eda78218e5be2cbfa0207c364
This commit is contained in:
parent
ecee5d8281
commit
427c8d53a5
|
@ -431,24 +431,23 @@ func (s *memorySeries) preloadChunksAtTime(t clientmodel.Timestamp, p *persisten
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// loadChunkDescs is an internal helper method.
|
// preloadChunksForRange loads chunks for the given range from the persistence.
|
||||||
func (s *memorySeries) loadChunkDescs(p *persistence) error {
|
// The caller must have locked the fingerprint of the series.
|
||||||
cds, err := p.loadChunkDescs(s.metric.Fingerprint(), s.chunkDescs[0].firstTime())
|
func (s *memorySeries) preloadChunksForRange(
|
||||||
|
from clientmodel.Timestamp, through clientmodel.Timestamp,
|
||||||
|
fp clientmodel.Fingerprint, p *persistence,
|
||||||
|
) (chunkDescs, error) {
|
||||||
|
firstChunkDescTime := through
|
||||||
|
if len(s.chunkDescs) > 0 {
|
||||||
|
firstChunkDescTime = s.chunkDescs[0].firstTime()
|
||||||
|
}
|
||||||
|
if !s.chunkDescsLoaded && from.Before(firstChunkDescTime) {
|
||||||
|
cds, err := p.loadChunkDescs(fp, firstChunkDescTime)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return nil, err
|
||||||
}
|
}
|
||||||
s.chunkDescs = append(cds, s.chunkDescs...)
|
s.chunkDescs = append(cds, s.chunkDescs...)
|
||||||
s.chunkDescsLoaded = true
|
s.chunkDescsLoaded = true
|
||||||
return nil
|
|
||||||
}
|
|
||||||
|
|
||||||
// preloadChunksForRange loads chunks for the given range from the persistence.
|
|
||||||
// The caller must have locked the fingerprint of the series.
|
|
||||||
func (s *memorySeries) preloadChunksForRange(from clientmodel.Timestamp, through clientmodel.Timestamp, p *persistence) (chunkDescs, error) {
|
|
||||||
if !s.chunkDescsLoaded && (len(s.chunkDescs) == 0 || from.Before(s.chunkDescs[0].firstTime())) {
|
|
||||||
if err := s.loadChunkDescs(p); err != nil {
|
|
||||||
return nil, err
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(s.chunkDescs) == 0 {
|
if len(s.chunkDescs) == 0 {
|
||||||
|
|
|
@ -175,7 +175,7 @@ func (s *memorySeriesStorage) preloadChunksForRange(fp clientmodel.Fingerprint,
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return series.preloadChunksForRange(from, through, s.persistence)
|
return series.preloadChunksForRange(from, through, fp, s.persistence)
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewIterator implements storage.
|
// NewIterator implements storage.
|
||||||
|
|
Loading…
Reference in a new issue