Skip to content

Commit 9663948

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. There is no need for the doneCh as fetchPool.Stop already ensures all worker threads have stopped, and the queue of pending tasks is emptied. In other words we are guranteed no side effects.
1 parent 90f4aa9 commit 9663948

2 files changed

Lines changed: 5 additions & 5 deletions

File tree

.changelog/6444.bugfix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
go/worker/storage/committee: Fix worker teardown

go/worker/storage/committee/worker.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,6 +1046,8 @@ func (w *Worker) Serve(ctx context.Context) error { // nolint: gocyclo
10461046
fetchPool := workerpool.New("storage_fetch/" + w.commonNode.Runtime.ID().String())
10471047
fetchPool.Resize(config.GlobalConfig.Storage.FetcherCount)
10481048
defer fetchPool.Stop()
1049+
poolCtx, cancel := context.WithCancel(ctx)
1050+
defer cancel()
10491051

10501052
triggerRoundFetches := func() {
10511053
for i := lastFullyAppliedRound + 1; i <= latestBlockRound; i++ {
@@ -1096,11 +1098,8 @@ func (w *Worker) Serve(ctx context.Context) error { // nolint: gocyclo
10961098
rootType := prevRoots[i].Type
10971099
if !syncing.outstanding.contains(rootType) && syncing.awaitingRetry.contains(rootType) {
10981100
syncing.scheduleDiff(rootType)
1099-
doneCh := fetchPool.Submit(func() {
1100-
w.fetchDiff(ctx, this.Round, prevRoots[i], this.Roots[i])
1101-
})
1102-
wg.Go(func() {
1103-
<-doneCh
1101+
_ = fetchPool.Submit(func() {
1102+
w.fetchDiff(poolCtx, this.Round, prevRoots[i], this.Roots[i])
11041103
})
11051104
}
11061105
}

0 commit comments

Comments
 (0)