rename GC to CollectGarbage, ignore badger.ErrNoRewrite

This commit is contained in:
vyzo 2021-03-08 19:22:53 +02:00
parent 52de95d344
commit 3d1b855f20
2 changed files with 15 additions and 9 deletions
blockstore

View File

@ -131,13 +131,19 @@ func (b *Blockstore) Close() error {
return b.DB.Close()
}
// GC runs garbage collection on the value log
func (b *Blockstore) GC() error {
// CollectGarbage runs garbage collection on the value log
func (b *Blockstore) CollectGarbage() error {
if atomic.LoadInt64(&b.state) != stateOpen {
return ErrBlockstoreClosed
}
return b.DB.RunValueLogGC(0.125)
err := b.DB.RunValueLogGC(0.125)
if err == badger.ErrNoRewrite {
// not really an error in this case
return nil
}
return err
}
// View implements blockstore.Viewer, which leverages zero-copy read-only

View File

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