From f2b7c3e6f2e41f33221802438e3cc0590151134d Mon Sep 17 00:00:00 2001 From: vyzo Date: Thu, 22 Jul 2021 13:47:40 +0300 Subject: [PATCH] reduce scope of exclusive lock in badger markset --- blockstore/splitstore/markset_badger.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/blockstore/splitstore/markset_badger.go b/blockstore/splitstore/markset_badger.go index 5adaadd2e..388478a3e 100644 --- a/blockstore/splitstore/markset_badger.go +++ b/blockstore/splitstore/markset_badger.go @@ -82,24 +82,27 @@ func (e *BadgerMarkSetEnv) Close() error { func (s *BadgerMarkSet) Mark(c cid.Cid) error { s.mx.Lock() - defer s.mx.Unlock() if s.pend == nil { + s.mx.Unlock() return errMarkSetClosed } s.pend[string(c.Hash())] = struct{}{} if len(s.pend) < badgerMarkSetBatchSize { + s.mx.Unlock() return nil } pend := s.pend s.pend = make(map[string]struct{}) + db := s.db + s.mx.Unlock() empty := []byte{} // not nil - batch := s.db.NewWriteBatch() + batch := db.NewWriteBatch() defer batch.Cancel() for k := range pend {