From b69bdfb4d11a8684b1eb0666f0d95a187b84f41a Mon Sep 17 00:00:00 2001 From: Callum Styan Date: Mon, 18 Feb 2019 22:46:52 -0800 Subject: [PATCH] Store the checkpoint we read last, so that we don't keep reading the same checkpoint on each tick. Signed-off-by: Callum Styan --- storage/remote/wal_watcher.go | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/storage/remote/wal_watcher.go b/storage/remote/wal_watcher.go index 399338045..4dbcaddef 100644 --- a/storage/remote/wal_watcher.go +++ b/storage/remote/wal_watcher.go @@ -95,10 +95,11 @@ type writeTo interface { // WALWatcher watches the TSDB WAL for a given WriteTo. type WALWatcher struct { - name string - writer writeTo - logger log.Logger - walDir string + name string + writer writeTo + logger log.Logger + walDir string + lastCheckpoint string startTime int64 @@ -183,6 +184,7 @@ func (w *WALWatcher) run() error { return errors.Wrap(err, "readCheckpoint") } } + w.lastCheckpoint = lastCheckpoint currentSegment, err := w.findSegmentForIndex(nextIndex) if err != nil { @@ -342,9 +344,10 @@ func (w *WALWatcher) garbageCollectSeries(segmentNum int) error { return errors.Wrap(err, "tsdb.LastCheckpoint") } - if dir == "" { + if dir == "" || dir == w.lastCheckpoint { return nil } + w.lastCheckpoint = dir index, err := checkpointNum(dir) if err != nil {