garbage collect hotstore after compaction

This commit is contained in:
vyzo 2021-03-08 18:12:09 +02:00
parent e85391b46c
commit 8562a9bb82
2 changed files with 20 additions and 0 deletions

View File

@ -131,6 +131,15 @@ func (b *Blockstore) Close() error {
return b.DB.Close() return b.DB.Close()
} }
// GC runs garbage collection on the value log
func (b *Blockstore) GC() error {
if atomic.LoadInt64(&b.state) != stateOpen {
return ErrBlockstoreClosed
}
return b.DB.RunValueLogGC(0.125)
}
// View implements blockstore.Viewer, which leverages zero-copy read-only // View implements blockstore.Viewer, which leverages zero-copy read-only
// access to values. // access to values.
func (b *Blockstore) View(cid cid.Cid, fn func([]byte) error) error { func (b *Blockstore) View(cid cid.Cid, fn func([]byte) error) error {

View File

@ -710,6 +710,17 @@ func (s *SplitStore) compactSimple(curTs *types.TipSet) error {
return xerrors.Errorf("error syncing tracker: %w", err) return xerrors.Errorf("error syncing tracker: %w", err)
} }
if gc, ok := s.hot.(interface{ GC() error }); ok {
log.Infof("garbage collecting hotstore")
startGC := time.Now()
err = gc.GC()
if err != nil {
log.Warnf("error garbage collecting hotstore: %s", err)
} else {
log.Infow("garbage collecting done", "took", time.Since(startGC))
}
}
err = s.setBaseEpoch(coldEpoch) err = s.setBaseEpoch(coldEpoch)
if err != nil { if err != nil {
return xerrors.Errorf("error saving base epoch: %w", err) return xerrors.Errorf("error saving base epoch: %w", err)