Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 13 additions & 5 deletions pkg/server/conn_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2314,25 +2314,27 @@ func TestConnAddMetrics(t *testing.T) {

func TestIssue54335(t *testing.T) {
store, dom := testkit.CreateMockStoreAndDomain(t)
se, err := session.CreateSession4Test(store)
require.NoError(t, err)

// There is no underlying netCon, use failpoint to avoid panic
require.NoError(t, failpoint.Enable("github.com/pingcap/tidb/pkg/server/FakeClientConn", "return(1)"))
defer func() {
require.NoError(t, failpoint.Disable("github.com/pingcap/tidb/pkg/server/FakeClientConn"))
}()
tk := testkit.NewTestKit(t, store)

connID := uint64(1)
tk.Session().SetConnectionID(connID)
se.SetConnectionID(connID)
tc := &TiDBContext{
Session: tk.Session(),
Session: se,
stmts: make(map[int]*TiDBStatement),
}
cc := &clientConn{
connectionID: connID,
server: &Server{
capability: defaultCapability,
},
pkt: internal.NewPacketIOForTest(bufio.NewWriter(io.Discard)),
alloc: arena.NewAllocator(32 * 1024),
chunkAlloc: chunk.NewAllocator(),
}
Expand All @@ -2346,12 +2348,18 @@ func TestIssue54335(t *testing.T) {
handle := dom.ExpensiveQueryHandle().SetSessionManager(srv)
go handle.Run()

tk.MustExec("use test;")
tk.MustExec("CREATE TABLE testTable2 (id bigint, age int)")
session.MustExec(t, se, "use test;")
session.MustExec(t, se, "CREATE TABLE testTable2 (id bigint, age int)")
str := fmt.Sprintf("insert into testTable2 values(%d, %d)", 1, 1)
<<<<<<< HEAD
tk.MustExec(str)
for i := 0; i < 14; i++ {
tk.MustExec("insert into testTable2 select * from testTable2")
=======
session.MustExec(t, se, str)
for range 14 {
session.MustExec(t, se, "insert into testTable2 select * from testTable2")
>>>>>>> 56490d622d7 (pkg/server: stabilize flaky TestIssue54335 (#67888))
Comment on lines +2354 to +2362

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 Functional Correctness | 🔴 Critical | ⚡ Quick win

Resolve the merge conflict before merging.

The checked-in test still contains <<<<<<<, =======, and >>>>>>> markers. It also retains tk.MustExec, although tk is no longer declared. Keep the session.MustExec branch and remove the conflict markers and obsolete tk calls.

Proposed fix
-<<<<<<< HEAD
-	tk.MustExec(str)
-	for i := 0; i < 14; i++ {
-		tk.MustExec("insert into testTable2 select * from testTable2")
-=======
 	session.MustExec(t, se, str)
 	for range 14 {
 		session.MustExec(t, se, "insert into testTable2 select * from testTable2")
->>>>>>> 56490d622d7 (pkg/server: stabilize flaky TestIssue54335 (`#67888`))
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<<<<<<< HEAD
tk.MustExec(str)
for i := 0; i < 14; i++ {
tk.MustExec("insert into testTable2 select * from testTable2")
=======
session.MustExec(t, se, str)
for range 14 {
session.MustExec(t, se, "insert into testTable2 select * from testTable2")
>>>>>>> 56490d622d7 (pkg/server: stabilize flaky TestIssue54335 (#67888))
session.MustExec(t, se, str)
for range 14 {
session.MustExec(t, se, "insert into testTable2 select * from testTable2")
}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@pkg/server/conn_test.go` around lines 2354 - 2362, Resolve the conflict in
the test setup by keeping the session.MustExec calls with t and se, removing all
conflict markers, and deleting the obsolete tk.MustExec branch and references in
the affected test.

}

times := 100
Expand Down