Skip to content

Commit

Permalink
executor: stop fetch handles after closing. (pingcap#3365)
Browse files Browse the repository at this point in the history
  • Loading branch information
hanfei1991 authored and XuHuaiyu committed Jun 1, 2017
1 parent f453b19 commit 1183792
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions executor/distsql.go
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,8 @@ type XSelectIndexExec struct {
taskCurr *lookupTableTask
handleCount uint64 // returned handle count in double read.

closeCh chan struct{}

where *tipb.Expr
startTS uint64
returnedRows uint64 // returned row count
Expand Down Expand Up @@ -398,6 +400,7 @@ type XSelectIndexExec struct {
func (e *XSelectIndexExec) Open() error {
e.returnedRows = 0
e.partialCount = 0
e.closeCh = make(chan struct{})
return nil
}

Expand All @@ -414,6 +417,7 @@ func (e *XSelectIndexExec) Close() error {

e.taskCurr = nil
if e.taskChan != nil {
close(e.closeCh)
// Consume the task channel in case channel is full.
for range e.taskChan {
}
Expand Down Expand Up @@ -616,6 +620,8 @@ func (e *XSelectIndexExec) fetchHandles(idxResult distsql.SelectResult, ch chan<
select {
case <-txnCtx.Done():
return
case <-e.closeCh:
return
case workCh <- task:
default:
e.addWorker(workCh, &concurrency, lookupConcurrencyLimit)
Expand Down

0 comments on commit 1183792

Please sign in to comment.