Skip to content

Commit 079e8a4

Browse files
committed
go/worker/storage/committee: Fix worker teardown
Previously the fetch pool was closed first, which caused doneCh to never be closed, which cause wg.Wait to never finish. Probably a better approach is to fix workerpool.Pool.
1 parent 4aca077 commit 079e8a4

1 file changed

Lines changed: 9 additions & 2 deletions

File tree

go/worker/storage/committee/worker.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -762,6 +762,14 @@ func (w *Worker) Serve(ctx context.Context) error { // nolint: gocyclo
762762
w.status = api.StatusStarting
763763
w.statusLock.Unlock()
764764

765+
var fetchPool *workerpool.Pool
766+
defer func() {
767+
if fetchPool == nil {
768+
return
769+
}
770+
fetchPool.Stop()
771+
}()
772+
765773
var wg sync.WaitGroup
766774
defer wg.Wait()
767775

@@ -1033,9 +1041,8 @@ func (w *Worker) Serve(ctx context.Context) error { // nolint: gocyclo
10331041
syncingRounds := make(map[uint64]*inFlight)
10341042
summaryCache := make(map[uint64]*blockSummary)
10351043

1036-
fetchPool := workerpool.New("storage_fetch/" + w.commonNode.Runtime.ID().String())
1044+
fetchPool = workerpool.New("storage_fetch/" + w.commonNode.Runtime.ID().String())
10371045
fetchPool.Resize(config.GlobalConfig.Storage.FetcherCount)
1038-
defer fetchPool.Stop()
10391046

10401047
triggerRoundFetches := func() {
10411048
for i := lastFullyAppliedRound + 1; i <= latestBlockRound; i++ {

0 commit comments

Comments
 (0)