From d89652db0ecaf5569ce419e4db5efb08dadc9a6b Mon Sep 17 00:00:00 2001 From: MyonKeminta Date: Wed, 8 Feb 2023 19:20:09 +0800 Subject: [PATCH] Add test Signed-off-by: MyonKeminta --- session/bootstrap.go | 8 ++++++++ sessiontxn/isolation/repeatable_read_test.go | 15 +++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/session/bootstrap.go b/session/bootstrap.go index a18947be5230c..9a9e96b4acd63 100644 --- a/session/bootstrap.go +++ b/session/bootstrap.go @@ -29,6 +29,7 @@ import ( "time" "github.com/pingcap/errors" + "github.com/pingcap/failpoint" "github.com/pingcap/tidb/bindinfo" "github.com/pingcap/tidb/config" "github.com/pingcap/tidb/domain" @@ -2490,6 +2491,13 @@ func doDMLWorks(s Session) { case variable.TiDBEnableMutationChecker: vVal = variable.On } + + failpoint.Inject("enableAggressiveLockingOnBootstrap", func() { + if v.Name == variable.TiDBPessimisticTransactionAggressiveLocking { + vVal = variable.On + } + }) + // sanitize k and vVal value := fmt.Sprintf(`("%s", "%s")`, sqlexec.EscapeString(k), sqlexec.EscapeString(vVal)) values = append(values, value) diff --git a/sessiontxn/isolation/repeatable_read_test.go b/sessiontxn/isolation/repeatable_read_test.go index 085b64c34cc38..a2c0641ff456a 100644 --- a/sessiontxn/isolation/repeatable_read_test.go +++ b/sessiontxn/isolation/repeatable_read_test.go @@ -700,3 +700,18 @@ func TestRRWaitTSTimeInSlowLog(t *testing.T) { require.NotEqual(t, waitTS1, waitTS3) require.NotEqual(t, waitTS2, waitTS3) } + +func TestIssue41194(t *testing.T) { + require.NoError(t, failpoint.Enable("github.com/pingcap/tidb/session/enableAggressiveLockingOnBootstrap", "return")) + defer func() { + require.NoError(t, failpoint.Disable("github.com/pingcap/tidb/session/enableAggressiveLockingOnBootstrap")) + }() + + store := testkit.CreateMockStore(t) + tk := testkit.NewTestKit(t, store) + + tk.MustExec("use test") + tk.MustExec("create table t (id int primary key, v int)") + tk.MustExec("insert into t values (1, 1), (2, 2), (3, 3)") + tk.MustExec("analyze table t") +}