From f799e720f5aec32664c6910e47bad46e5c838b4f Mon Sep 17 00:00:00 2001 From: you06 Date: Fri, 2 Dec 2022 14:30:00 +0800 Subject: [PATCH] store/copr: disable batch store copr when paging is enabled (#39580) ref pingcap/tidb#39361 --- store/copr/copr_test/coprocessor_test.go | 22 ++++++++++++++++++++++ store/copr/coprocessor.go | 4 ++++ 2 files changed, 26 insertions(+) diff --git a/store/copr/copr_test/coprocessor_test.go b/store/copr/copr_test/coprocessor_test.go index 584de99b11a75..a54c5048e12cb 100644 --- a/store/copr/copr_test/coprocessor_test.go +++ b/store/copr/copr_test/coprocessor_test.go @@ -144,4 +144,26 @@ func TestBuildCopIteratorWithBatchStoreCopr(t *testing.T) { require.Equal(t, len(tasks), 1) require.Equal(t, len(tasks[0].ToPBBatchTasks()), 3) require.Equal(t, tasks[0].RowCountHint, 14) + + // paging will disable store batch. + req = &kv.Request{ + Tp: kv.ReqTypeDAG, + KeyRanges: kv.NewNonParitionedKeyRanges(copr.BuildKeyRanges("a", "c", "d", "e", "h", "x", "y", "z")), + FixedRowCountHint: []int{1, 1, 3, 3}, + Concurrency: 15, + StoreBatchSize: 3, + Paging: struct { + Enable bool + MinPagingSize uint64 + MaxPagingSize uint64 + }{ + Enable: true, + MinPagingSize: 1, + MaxPagingSize: 1024, + }, + } + it, errRes = copClient.BuildCopIterator(ctx, req, vars, opt) + require.Nil(t, errRes) + tasks = it.GetTasks() + require.Equal(t, len(tasks), 4) } diff --git a/store/copr/coprocessor.go b/store/copr/coprocessor.go index 3bf5cd89104db..a4cea914c3aa9 100644 --- a/store/copr/coprocessor.go +++ b/store/copr/coprocessor.go @@ -140,6 +140,10 @@ func (c *CopClient) BuildCopIterator(ctx context.Context, req *kv.Request, vars // disable batch copr for follower read req.StoreBatchSize = 0 } + // disable paging for batch copr + if req.Paging.Enable { + req.StoreBatchSize = 0 + } bo := backoff.NewBackofferWithVars(ctx, copBuildTaskMaxBackoff, vars) var (