mirror of
https://github.com/prometheus/prometheus.git
synced 2025-03-05 20:59:13 -08:00
Store the checkpoint we read last, so that we don't keep reading the same checkpoint on each tick.
Signed-off-by: Callum Styan <callumstyan@gmail.com>
This commit is contained in:
parent
efbd9559f4
commit
b69bdfb4d1
|
@ -95,10 +95,11 @@ type writeTo interface {
|
||||||
|
|
||||||
// WALWatcher watches the TSDB WAL for a given WriteTo.
|
// WALWatcher watches the TSDB WAL for a given WriteTo.
|
||||||
type WALWatcher struct {
|
type WALWatcher struct {
|
||||||
name string
|
name string
|
||||||
writer writeTo
|
writer writeTo
|
||||||
logger log.Logger
|
logger log.Logger
|
||||||
walDir string
|
walDir string
|
||||||
|
lastCheckpoint string
|
||||||
|
|
||||||
startTime int64
|
startTime int64
|
||||||
|
|
||||||
|
@ -183,6 +184,7 @@ func (w *WALWatcher) run() error {
|
||||||
return errors.Wrap(err, "readCheckpoint")
|
return errors.Wrap(err, "readCheckpoint")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
w.lastCheckpoint = lastCheckpoint
|
||||||
|
|
||||||
currentSegment, err := w.findSegmentForIndex(nextIndex)
|
currentSegment, err := w.findSegmentForIndex(nextIndex)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -342,9 +344,10 @@ func (w *WALWatcher) garbageCollectSeries(segmentNum int) error {
|
||||||
return errors.Wrap(err, "tsdb.LastCheckpoint")
|
return errors.Wrap(err, "tsdb.LastCheckpoint")
|
||||||
}
|
}
|
||||||
|
|
||||||
if dir == "" {
|
if dir == "" || dir == w.lastCheckpoint {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
w.lastCheckpoint = dir
|
||||||
|
|
||||||
index, err := checkpointNum(dir)
|
index, err := checkpointNum(dir)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in a new issue