jldb/lib/rep/replicator-walgc.go

29 lines
502 B
Go
Raw Permalink Normal View History

2023-10-13 09:43:27 +00:00
package rep
import (
"log"
"time"
)
func (rep *Replicator) runWALGC() {
defer rep.done.Done()
ticker := time.NewTicker(time.Minute)
defer ticker.Stop()
for {
select {
case <-ticker.C:
state := rep.getState()
2023-12-05 08:54:41 +00:00
before := time.Now().Unix() - rep.conf.WALSegGCAgeSec
2023-10-13 09:43:27 +00:00
if err := rep.wal.DeleteBefore(before, state.SeqNum); err != nil {
log.Printf("[WAL-GC] failed to delete wal segments: %v", err)
}
// OK
case <-rep.stop:
log.Print("[WAL-GC] Stopped")
return
}
}
}