2021-07-11 05:38:57 +00:00
|
|
|
package splitstore
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
bstore "github.com/filecoin-project/lotus/blockstore"
|
|
|
|
)
|
|
|
|
|
|
|
|
func (s *SplitStore) gcHotstore() {
|
2021-07-12 05:39:12 +00:00
|
|
|
// we only perform moving gc every 10 compactions as it can take a while
|
|
|
|
if s.compactionIndex%10 != 0 {
|
|
|
|
goto online_gc
|
|
|
|
}
|
|
|
|
|
2021-07-11 05:38:57 +00:00
|
|
|
// check if the hotstore is movable; if so, move it.
|
|
|
|
if mover, ok := s.hot.(bstore.BlockstoreMover); ok {
|
|
|
|
log.Info("moving hotstore")
|
|
|
|
startMove := time.Now()
|
|
|
|
err := mover.MoveTo("", nil)
|
|
|
|
if err != nil {
|
|
|
|
log.Warnf("error moving hotstore: %s", err)
|
2021-07-12 05:39:12 +00:00
|
|
|
// try online gc
|
|
|
|
goto online_gc
|
2021-07-11 05:38:57 +00:00
|
|
|
}
|
|
|
|
|
2021-07-12 05:39:12 +00:00
|
|
|
log.Infow("moving hotstore done", "took", time.Since(startMove))
|
2021-07-11 05:38:57 +00:00
|
|
|
return
|
|
|
|
}
|
|
|
|
|
2021-07-12 05:39:12 +00:00
|
|
|
online_gc:
|
2021-07-11 05:38:57 +00:00
|
|
|
// check if the hotstore supports online GC; if so, GC it.
|
|
|
|
if gc, ok := s.hot.(bstore.BlockstoreGC); ok {
|
|
|
|
log.Info("garbage collecting hotstore")
|
|
|
|
startGC := time.Now()
|
|
|
|
err := gc.CollectGarbage()
|
|
|
|
if err != nil {
|
|
|
|
log.Warnf("error garbage collecting hotstore: %s", err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
log.Infof("garbage collecting hotstore done", "took", time.Since(startGC))
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
return
|
|
|
|
}
|