Skip to content

Commit

Permalink
copr: fix data race in the mppIterator (#39772)
Browse files Browse the repository at this point in the history
close #39771
  • Loading branch information
hawkingrei authored Dec 9, 2022
1 parent f18be89 commit f681af5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions store/copr/mpp.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,8 @@ type mppIterator struct {

cancelFunc context.CancelFunc

wg sync.WaitGroup
wg sync.WaitGroup
wgDoneChan chan struct{}

closed uint32

Expand Down Expand Up @@ -188,6 +189,7 @@ func (m *mppIterator) run(ctx context.Context) {
}(task)
}
m.wg.Wait()
close(m.wgDoneChan)
close(m.respChan)
}

Expand Down Expand Up @@ -446,7 +448,7 @@ func (m *mppIterator) Close() error {
close(m.finishCh)
}
m.cancelFunc()
m.wg.Wait()
<-m.wgDoneChan
return nil
}

Expand Down Expand Up @@ -533,6 +535,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,
Expand Down

0 comments on commit f681af5

Please sign in to comment.