Closed wshwsh12 closed 1 month ago
joinMatchedInnerRow2Chunk
if joinResult.chk.IsFull() {
select {
case iw.resultCh <- joinResult: // <- send to resultCh the first time.
case <-ctx.Done():
}
failpoint.InjectCall("joinMatchedInnerRow2Chunk")
joinResult, ok = iw.getNewJoinResult(ctx)
if !ok {
return false, joinResult
}
}
func (iw indexHashJoinInnerWorker) getNewJoinResult(ctx context.Context) (indexHashJoinResult, bool) { joinResult := &indexHashJoinResult{ src: iw.joinChkResourceCh, } ok := true select { // <- random select a path case joinResult.chk, ok = <-iw.joinChkResourceCh: case <-ctx.Done(): // <- choose this path return joinResult, false } return joinResult, ok }
2. doJoinUnordered return nil error.
``` go
ok, joinResult = iw.joinMatchedInnerRow2Chunk(ctx, row, task, joinResult, h, iw.joinKeyBuf)
if !ok {
return joinResult.err // nil
}
select { //<-random select a path
case <-ctx.Done():
return
case task, ok = <-iw.taskCh: // <- choose this path
}
if !ok {
break // exit this loop
}
...... ...... if resultCh == iw.resultCh { if joinResult.err != nil { resultCh <- joinResult return } if joinResult.chk != nil && joinResult.chk.NumRows() > 0 { select { // <- random select a path case resultCh <- joinResult: // <- choose this path, send to resultCh the second time. case <-ctx.Done(): return } } }
4. Next() try to get the two joinResult and give back chk to joinChkResourceCh(cap 1), and hang forever.
This issue can cause a single query to hang, but it won't result in a panic or similar problems. It is an intermittent issue and does not occur every time.
I will change the severity label from critical to major.
/report customer
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
Context canceled may occur at any time if the sql is interrupted during execution.
I try to inject context cancel to indexhashjoin, to reproduce the issue. Patch this diff to index_lookup_join.go
Run the UT
2. What did you expect to see? (Required)
Can run successfully.
3. What did you see instead (Required)
Hang forever. goroutine in master.
goroutine in v6.5.6
4. What is your TiDB version? (Required)
master, v6.5.6