Skip to content

Commit

Permalink
wait for reify workers to finish when closing
Browse files Browse the repository at this point in the history
  • Loading branch information
vyzo committed Feb 14, 2022
1 parent 6c7abab commit 4524fbe
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions blockstore/splitstore/splitstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ type SplitStore struct {
txnSync bool

// background cold object reification
reifyWorkers sync.WaitGroup
reifyMx sync.Mutex
reifyCond sync.Cond
reifyPend map[cid.Cid]struct{}
Expand Down Expand Up @@ -707,6 +708,7 @@ func (s *SplitStore) Close() error {
}

s.reifyCond.Broadcast()
s.reifyWorkers.Wait()
s.cancel()
return multierr.Combine(s.markSetEnv.Close(), s.debug.Close())
}
Expand Down
2 changes: 2 additions & 0 deletions blockstore/splitstore/splitstore_reify.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ func (s *SplitStore) reifyOrchestrator() {
defer close(workch)

for i := 0; i < workers; i++ {
s.reifyWorkers.Add(1)
go s.reifyWorker(workch)
}

Expand Down Expand Up @@ -70,6 +71,7 @@ func (s *SplitStore) reifyOrchestrator() {
}

func (s *SplitStore) reifyWorker(workch chan cid.Cid) {
defer s.reifyWorkers.Done()
for c := range workch {
s.doReify(c)
}
Expand Down

0 comments on commit 4524fbe

Please sign in to comment.