Fix compactions sometimes getting stuck
I ran into an issue where the cache snapshotting seemed to stop completely causing the cache to fill up and never recover. I believe this is due to the the Timer being reused incorrectly. Instead, use a Ticker that will fire more regularly and not require the resetting logic (which was wrong).pull/7830/head
parent
40b017f4a4
commit
1e56b5416b
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue