Skip to content

pkg/server: stabilize flaky TestIssue54335 (#67888)#70014

Open
ti-chi-bot wants to merge 1 commit into
pingcap:release-8.5from
ti-chi-bot:cherry-pick-67888-to-release-8.5
Open

pkg/server: stabilize flaky TestIssue54335 (#67888)#70014
ti-chi-bot wants to merge 1 commit into
pingcap:release-8.5from
ti-chi-bot:cherry-pick-67888-to-release-8.5

Conversation

@ti-chi-bot

@ti-chi-bot ti-chi-bot commented Jul 24, 2026

Copy link
Copy Markdown
Member

This is an automated cherry-pick of #67888

What problem does this PR solve?

Issue Number: close #67558

Problem Summary:
Flaky test TestIssue54335 in pkg/server intermittently fails, so this PR stabilizes that path.

What changed and how does it work?

Root Cause

TestIssue54335 constructed a client connection with nil pkt and relied on failpoint behavior; when the query reached result writing, writePacket dereferenced nil and panicked.

Fix

Initializing cc.pkt in the flaky test removes the nil dereference window without changing product behavior.

Verification

Spec:

  • target: pkg/server :: TestIssue54335
  • strategy: tidb.go_flaky.default
  • plan mode: BASELINE_ONLY
  • requirements: required case must execute; no skip; repeat count = 1
  • baseline gates: required_flaky_gate, build_safety_gate, intent_guard_gate

Observed result:

  • status: passed
  • required case executed: yes
  • submission decision: ALLOWED
  • scope debt present: yes

Gate checklist:

  • Required flaky gate: PASS
  • Build safety gate: PASS
  • Intent guard gate: PASS
  • Repo-wide advisory gate: SKIPPED
  • Feedback specific gate: SKIPPED

Commands:

  • go test -json ./pkg/server -run '^TestIssue54335$' -count=1
  • go test -json ./pkg/server -count=1
  • make build

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • No need to test
    • I checked and no code files have been changed.

Side effects

  • Performance regression: Consumes more CPU
  • Performance regression: Consumes more Memory
  • Breaking backward compatibility

Documentation

  • Affects user behaviors
  • Contains syntax changes
  • Contains variable changes
  • Contains experimental features
  • Changes MySQL compatibility

Release note

Please refer to Release Notes Language Style Guide to write a quality release note.

None

Fixes #67558

Summary by CodeRabbit

  • Tests
    • Improved the reliability of a connection-related test by using a more direct SQL execution path.
    • Updated test output handling to avoid unnecessary connection and buffer interactions.

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot ti-chi-bot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. type/cherry-pick-for-release-8.5 This PR is cherry-picked to release-8.5 from a source PR. labels Jul 24, 2026
@ti-chi-bot ti-chi-bot Bot added cherry-pick-approved Cherry pick PR approved by release team. and removed do-not-merge/cherry-pick-not-approved labels Jul 24, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 24, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign xuyifangreeneyes for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai

coderabbitai Bot commented Jul 24, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

TestIssue54335 now creates and wires a direct test session, discards packet output, and executes the existing SQL scenario through session.MustExec, including a simplified repetition loop.

Changes

TestIssue54335 stabilization

Layer / File(s) Summary
Direct session test execution
pkg/server/conn_test.go
The test uses session.CreateSession4Test, assigns its connection ID, wires it into TiDBContext and clientConn, writes packet output to io.Discard, and runs the existing SQL setup through session.MustExec.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested labels: approved, lgtm

Suggested reviewers: ailinkid

Poem

A rabbit hops through tests anew,
With sessions wired and packets few.
SQL loops tidy, flakes take flight,
Discarded bytes fade out of sight.
“Stable burrows!” cheers the crew.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title is concise and accurately describes the main change: stabilizing flaky TestIssue54335 in pkg/server.
Description check ✅ Passed The description includes the problem summary, change details, tests, side effects, and release note, matching the template well enough.
Linked Issues check ✅ Passed The changes address #67558 by removing the nil pkt panic path and stabilizing TestIssue54335 as requested.
Out of Scope Changes check ✅ Passed The edits stay focused on the flaky test fix and related test harness adjustments, with no unrelated code changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 golangci-lint (2.12.2)

Error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions
The command is terminated due to an error: can't load config: unsupported version of the configuration: "" See https://golangci-lint.run/docs/product/migration-guide for migration instructions


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with 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.

Inline comments:
In `@pkg/server/conn_test.go`:
- Around line 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.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 71f482de-5730-4ed1-8e68-0c141250cfc3

📥 Commits

Reviewing files that changed from the base of the PR and between 10431d8 and 1098dcc.

📒 Files selected for processing (1)
  • pkg/server/conn_test.go

Comment thread pkg/server/conn_test.go
Comment on lines +2354 to +2362
<<<<<<< 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))

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.

@ti-chi-bot

ti-chi-bot Bot commented Jul 24, 2026

Copy link
Copy Markdown

@ti-chi-bot: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
idc-jenkins-ci-tidb/unit-test 1098dcc link true /test unit-test
idc-jenkins-ci-tidb/check_dev 1098dcc link true /test check-dev
idc-jenkins-ci-tidb/build 1098dcc link true /test build
idc-jenkins-ci-tidb/check_dev_2 1098dcc link true /test check-dev2

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cherry-pick-approved Cherry pick PR approved by release team. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. release-note-none Denotes a PR that doesn't merit a release note. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. type/cherry-pick-for-release-8.5 This PR is cherry-picked to release-8.5 from a source PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants