Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

copr: fix data race in the mppIterator (#39772) #39795

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -428,7 +430,7 @@ func (m *mppIterator) Close() error {
close(m.finishCh)
}
m.cancelFunc()
m.wg.Wait()
<-m.wgDoneChan
return nil
}

Expand Down Expand Up @@ -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,
Expand Down