diff --git a/tsdb/engine/tsm1/engine.go b/tsdb/engine/tsm1/engine.go index 5cb40784ee..e9abc5635d 100644 --- a/tsdb/engine/tsm1/engine.go +++ b/tsdb/engine/tsm1/engine.go @@ -949,7 +949,7 @@ func (e *Engine) writeSnapshotAndCommit(closedFiles []string, snapshot *Cache) ( // compactCache continually checks if the WAL cache should be written to disk. func (e *Engine) compactCache(quit <-chan struct{}) { - t := time.NewTimer(time.Second) + t := time.NewTicker(time.Second) defer t.Stop() for { select { @@ -971,7 +971,6 @@ func (e *Engine) compactCache(quit <-chan struct{}) { atomic.AddInt64(&e.stats.CacheCompactionDuration, time.Since(start).Nanoseconds()) } } - t.Reset(time.Second) } } @@ -989,7 +988,7 @@ func (e *Engine) ShouldCompactCache(lastWriteTime time.Time) bool { } func (e *Engine) compactTSMLevel(fast bool, level int, quit <-chan struct{}) { - t := time.NewTimer(time.Second) + t := time.NewTicker(time.Second) defer t.Stop() for { @@ -1003,12 +1002,11 @@ func (e *Engine) compactTSMLevel(fast bool, level int, quit <-chan struct{}) { s.Apply() } } - t.Reset(time.Second) } } func (e *Engine) compactTSMFull(quit <-chan struct{}) { - t := time.NewTimer(time.Second) + t := time.NewTicker(time.Second) defer t.Stop() for { @@ -1023,7 +1021,6 @@ func (e *Engine) compactTSMFull(quit <-chan struct{}) { } } - t.Reset(time.Second) } }