-
Notifications
You must be signed in to change notification settings - Fork 6k
Closed
Labels
affects-6.5This bug affects the 6.5.x(LTS) versions.This bug affects the 6.5.x(LTS) versions.affects-7.1This bug affects the 7.1.x(LTS) versions.This bug affects the 7.1.x(LTS) versions.affects-7.5This bug affects the 7.5.x(LTS) versions.This bug affects the 7.5.x(LTS) versions.affects-7.6affects-8.0affects-8.1This bug affects the 8.1.x(LTS) versions.This bug affects the 8.1.x(LTS) versions.may-affects-5.4This bug maybe affects 5.4.x versions.This bug maybe affects 5.4.x versions.may-affects-6.1severity/moderatesig/executionSIG executionSIG executiontype/bugThe issue is confirmed as a bug.The issue is confirmed as a bug.
Description
Bug Report
Please answer these questions before submitting your issue. Thanks!
1. Minimal reproduce step (Required)
suppose we have this patch added to help reproduce
diff --git a/pkg/executor/table_reader.go b/pkg/executor/table_reader.go
index 4d87861c95..fddbfe284a 100644
--- a/pkg/executor/table_reader.go
+++ b/pkg/executor/table_reader.go
@@ -250,6 +250,9 @@ func (e *TableReaderExecutor) Next(ctx context.Context, req *chunk.Chunk) error
}
return tableName
}), e.ranges)
+ if e.columns[0].Name.L == "a" {
+ time.Sleep(5 * time.Second)
+ }
if err := e.resultHandler.nextChunk(ctx, req); err != nil {
return err
}
then run this test
func TestIncorrectQuery(t *testing.T) {
store := testkit.CreateMockStore(t)
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("create table t(a int)")
tk.MustExec("insert into t values(1)")
ctx, cancelFunc := context.WithTimeout(context.Background(), 2*time.Second)
defer cancelFunc()
ctx = util.WithInternalSourceType(ctx, "scheduler")
rs, err := tk.Session().ExecuteInternal(ctx, "select * from test.t")
rows, err2 := session.ResultSetToStringSlice(ctx, tk.Session(), rs)
t.Log("result&err: ", len(rows), err, err2)
}
might need to run it for a few times
scheduler_test.go:720: result&err: 0 <nil> <nil>
here we don't return context error, if context cancelled in the middle the query returns incorrect result.
Query from normal client don't have issue, as we don't cancel context except when kill where it's handled.
tidb/pkg/store/copr/coprocessor.go
Lines 945 to 951 in e8861cf
case <-ctx.Done(): | |
// We select the ctx.Done() in the thread of `Next` instead of in the worker to avoid the cost of `WithCancel`. | |
if atomic.CompareAndSwapUint32(&it.closed, 0, 1) { | |
close(it.finishCh) | |
} | |
exit = true | |
return |
2. What did you expect to see? (Required)
got err: context deadline exceed
3. What did you see instead (Required)
no error, result set is empty
4. What is your TiDB version? (Required)
Metadata
Metadata
Assignees
Labels
affects-6.5This bug affects the 6.5.x(LTS) versions.This bug affects the 6.5.x(LTS) versions.affects-7.1This bug affects the 7.1.x(LTS) versions.This bug affects the 7.1.x(LTS) versions.affects-7.5This bug affects the 7.5.x(LTS) versions.This bug affects the 7.5.x(LTS) versions.affects-7.6affects-8.0affects-8.1This bug affects the 8.1.x(LTS) versions.This bug affects the 8.1.x(LTS) versions.may-affects-5.4This bug maybe affects 5.4.x versions.This bug maybe affects 5.4.x versions.may-affects-6.1severity/moderatesig/executionSIG executionSIG executiontype/bugThe issue is confirmed as a bug.The issue is confirmed as a bug.