Skip to content

Commit

Permalink
rename GC to CollectGarbage, ignore badger.ErrNoRewrite
Browse files Browse the repository at this point in the history
  • Loading branch information
vyzo committed Mar 8, 2021
1 parent 52de95d commit fe5461e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
12 changes: 9 additions & 3 deletions blockstore/badger/blockstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions blockstore/splitstore/splitstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

Expand Down

0 comments on commit fe5461e

Please sign in to comment.