diff --git a/store/copr/mpp.go b/store/copr/mpp.go index b75594e49177f..8fd8af22f442c 100644 --- a/store/copr/mpp.go +++ b/store/copr/mpp.go @@ -149,7 +149,8 @@ type mppIterator struct { cancelFunc context.CancelFunc - wg sync.WaitGroup + wg sync.WaitGroup + wgDoneChan chan struct{} closed uint32 @@ -188,6 +189,7 @@ func (m *mppIterator) run(ctx context.Context) { }(task) } m.wg.Wait() + close(m.wgDoneChan) close(m.respChan) } @@ -428,7 +430,7 @@ func (m *mppIterator) Close() error { close(m.finishCh) } m.cancelFunc() - m.wg.Wait() + <-m.wgDoneChan return nil } @@ -515,6 +517,7 @@ func (c *MPPClient) DispatchMPPTasks(ctx context.Context, variables interface{}, store: c.store, tasks: dispatchReqs, finishCh: make(chan struct{}), + wgDoneChan: make(chan struct{}), cancelFunc: cancelFunc, respChan: make(chan *mppResponse), startTs: startTs,