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

executor: parallel cancel mpp query #36161

Merged
merged 12 commits into from
Jul 13, 2022
18 changes: 13 additions & 5 deletions store/copr/mpp.go
Original file line number Diff line number Diff line change
Expand Up @@ -341,13 +341,21 @@ func (m *mppIterator) cancelMppTasks() {
}

// send cancel cmd to all stores where tasks run
wg := new(sync.WaitGroup)
xhebox marked this conversation as resolved.
Show resolved Hide resolved
for addr := range usedStoreAddrs {
_, err := m.store.GetTiKVClient().SendRequest(context.Background(), addr, wrappedReq, tikv.ReadTimeoutShort)
logutil.BgLogger().Debug("cancel task ", zap.Uint64("query id ", m.startTs), zap.String(" on addr ", addr))
if err != nil {
logutil.BgLogger().Error("cancel task error: ", zap.Error(err), zap.Uint64(" for query id ", m.startTs), zap.String(" on addr ", addr))
}
wg.Add(1)
go func(storeAddr string) {
defer func() {
wg.Done()
}()
_, err := m.store.GetTiKVClient().SendRequest(context.Background(), storeAddr, wrappedReq, tikv.ReadTimeoutShort)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to limit the batch number?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, the max number will be the TiFlash nodes in the cluster. Considering that TiDB always dispatchMPPTask to TiFlash node parallelly without limit, I think here is ok to not limit the batch number

logutil.BgLogger().Debug("cancel task ", zap.Uint64("query id ", m.startTs), zap.String(" on addr ", storeAddr))
windtalker marked this conversation as resolved.
Show resolved Hide resolved
if err != nil {
logutil.BgLogger().Error("cancel task error: ", zap.Error(err), zap.Uint64(" for query id ", m.startTs), zap.String(" on addr ", storeAddr))
windtalker marked this conversation as resolved.
Show resolved Hide resolved
}
}(addr)
}
wg.Wait()
}

func (m *mppIterator) establishMPPConns(bo *Backoffer, req *kv.MPPDispatchRequest, taskMeta *mpp.TaskMeta) {
Expand Down