diff --git a/blockstore/splitstore/splitstore_reify.go b/blockstore/splitstore/splitstore_reify.go index 652900747..85c4fa289 100644 --- a/blockstore/splitstore/splitstore_reify.go +++ b/blockstore/splitstore/splitstore_reify.go @@ -1,6 +1,7 @@ package splitstore import ( + "errors" "runtime" "sync/atomic" @@ -10,13 +11,12 @@ import ( cid "github.com/ipfs/go-cid" ) -var EnableReification = false +var ( + errReifyLimit = errors.New("reification limit reached") + ReifyLimit = 16384 +) func (s *SplitStore) reifyColdObject(c cid.Cid) { - if !EnableReification { - return - } - if !s.isWarm() { return } @@ -104,12 +104,18 @@ func (s *SplitStore) doReify(c cid.Cid) { s.txnLk.RLock() defer s.txnLk.RUnlock() + count := 0 err := s.walkObjectIncomplete(c, newTmpVisitor(), func(c cid.Cid) error { if isUnitaryObject(c) { return errStopWalk } + count++ + if count > ReifyLimit { + return errReifyLimit + } + s.reifyMx.Lock() _, inProgress := s.reifyInProgress[c] if !inProgress { @@ -150,6 +156,11 @@ func (s *SplitStore) doReify(c cid.Cid) { }) if err != nil { + if xerrors.Is(err, errReifyLimit) { + log.Debug("reification aborted; reify limit reached") + return + } + log.Warnf("error walking cold object for reification (cid: %s): %s", c, err) return }