From 3aabb0314aa96d5f15a0d0f9bf875dfce05e4a8f Mon Sep 17 00:00:00 2001 From: vyzo Date: Tue, 1 Feb 2022 09:07:14 +0200 Subject: [PATCH] synchronously mark live refs on put/putmany --- blockstore/splitstore/splitstore.go | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/blockstore/splitstore/splitstore.go b/blockstore/splitstore/splitstore.go index 8f09da37f..6a83b8146 100644 --- a/blockstore/splitstore/splitstore.go +++ b/blockstore/splitstore/splitstore.go @@ -370,10 +370,10 @@ func (s *SplitStore) Put(ctx context.Context, blk blocks.Block) error { } s.txnLk.RLock() + defer s.txnLk.RUnlock() err := s.hot.Put(ctx, blk) if err != nil { - s.txnLk.RUnlock() return err } @@ -381,13 +381,9 @@ func (s *SplitStore) Put(ctx context.Context, blk blocks.Block) error { // critical section if s.txnMarkSet != nil { - go func() { - defer s.txnLk.RUnlock() - s.markLiveRefs([]cid.Cid{blk.Cid()}) - }() + s.markLiveRefs([]cid.Cid{blk.Cid()}) return nil } - defer s.txnLk.RUnlock() s.trackTxnRef(blk.Cid()) return nil @@ -425,10 +421,10 @@ func (s *SplitStore) PutMany(ctx context.Context, blks []blocks.Block) error { } s.txnLk.RLock() + defer s.txnLk.RUnlock() err := s.hot.PutMany(ctx, blks) if err != nil { - s.txnLk.RUnlock() return err } @@ -436,13 +432,9 @@ func (s *SplitStore) PutMany(ctx context.Context, blks []blocks.Block) error { // critical section if s.txnMarkSet != nil { - go func() { - defer s.txnLk.RUnlock() - s.markLiveRefs(batch) - }() + s.markLiveRefs(batch) return nil } - defer s.txnLk.RUnlock() s.trackTxnRefMany(batch) return nil