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 3d1b855
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 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
12 changes: 6 additions & 6 deletions blockstore/splitstore/splitstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
}

Expand Down 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 3d1b855

Please sign in to comment.