wait for reify workers to finish when closing
This commit is contained in:
parent
6c7ababd3f
commit
4524fbe936
@ -162,6 +162,7 @@ type SplitStore struct {
|
|||||||
txnSync bool
|
txnSync bool
|
||||||
|
|
||||||
// background cold object reification
|
// background cold object reification
|
||||||
|
reifyWorkers sync.WaitGroup
|
||||||
reifyMx sync.Mutex
|
reifyMx sync.Mutex
|
||||||
reifyCond sync.Cond
|
reifyCond sync.Cond
|
||||||
reifyPend map[cid.Cid]struct{}
|
reifyPend map[cid.Cid]struct{}
|
||||||
@ -707,6 +708,7 @@ func (s *SplitStore) Close() error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
s.reifyCond.Broadcast()
|
s.reifyCond.Broadcast()
|
||||||
|
s.reifyWorkers.Wait()
|
||||||
s.cancel()
|
s.cancel()
|
||||||
return multierr.Combine(s.markSetEnv.Close(), s.debug.Close())
|
return multierr.Combine(s.markSetEnv.Close(), s.debug.Close())
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,7 @@ func (s *SplitStore) reifyOrchestrator() {
|
|||||||
defer close(workch)
|
defer close(workch)
|
||||||
|
|
||||||
for i := 0; i < workers; i++ {
|
for i := 0; i < workers; i++ {
|
||||||
|
s.reifyWorkers.Add(1)
|
||||||
go s.reifyWorker(workch)
|
go s.reifyWorker(workch)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -70,6 +71,7 @@ func (s *SplitStore) reifyOrchestrator() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (s *SplitStore) reifyWorker(workch chan cid.Cid) {
|
func (s *SplitStore) reifyWorker(workch chan cid.Cid) {
|
||||||
|
defer s.reifyWorkers.Done()
|
||||||
for c := range workch {
|
for c := range workch {
|
||||||
s.doReify(c)
|
s.doReify(c)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user