From 20490aee9b1312c52ee81057343266c770d0163e Mon Sep 17 00:00:00 2001 From: yibin Date: Thu, 3 Aug 2023 11:13:08 +0800 Subject: [PATCH] store,server: Reduce TiFlashFallBack test time (#45778) close pingcap/tidb#45773 --- server/BUILD.bazel | 2 +- server/conn_test.go | 2 ++ store/copr/coprocessor.go | 8 +++++++- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/server/BUILD.bazel b/server/BUILD.bazel index 5acc6f481ad21..590485e673fe1 100644 --- a/server/BUILD.bazel +++ b/server/BUILD.bazel @@ -121,7 +121,7 @@ go_library( go_test( name = "server_test", - timeout = "moderate", + timeout = "short", srcs = [ "conn_stmt_test.go", "conn_test.go", diff --git a/server/conn_test.go b/server/conn_test.go index 260dd8074fa6f..3dfd916693e47 100644 --- a/server/conn_test.go +++ b/server/conn_test.go @@ -1000,8 +1000,10 @@ func TestTiFlashFallback(t *testing.T) { tk.MustQuery("select count(*) from t").Check(testkit.Rows("50")) require.NoError(t, failpoint.Enable("github.com/pingcap/tidb/executor/internal/mpp/ReduceCopNextMaxBackoff", `return(true)`)) + require.NoError(t, failpoint.Enable("github.com/pingcap/tidb/store/copr/ReduceCopNextMaxBackoff", `return(true)`)) defer func() { require.NoError(t, failpoint.Disable("github.com/pingcap/tidb/executor/internal/mpp/ReduceCopNextMaxBackoff")) + require.NoError(t, failpoint.Disable("github.com/pingcap/tidb/store/copr/ReduceCopNextMaxBackoff")) }() require.NoError(t, failpoint.Enable("github.com/pingcap/tidb/store/mockstore/unistore/BatchCopRpcErrtiflash0", "return(\"tiflash0\")")) diff --git a/store/copr/coprocessor.go b/store/copr/coprocessor.go index fec9f9e4084f5..eba21cfe1a499 100644 --- a/store/copr/coprocessor.go +++ b/store/copr/coprocessor.go @@ -1087,7 +1087,13 @@ func chooseBackoffer(ctx context.Context, backoffermap map[uint64]*Backoffer, ta if ok { return bo } - newbo := backoff.NewBackofferWithVars(ctx, CopNextMaxBackoff, worker.vars) + boMaxSleep := CopNextMaxBackoff + failpoint.Inject("ReduceCopNextMaxBackoff", func(value failpoint.Value) { + if value.(bool) { + boMaxSleep = 2 + } + }) + newbo := backoff.NewBackofferWithVars(ctx, boMaxSleep, worker.vars) backoffermap[task.region.GetID()] = newbo return newbo }