Skip to content

tests: isolate TiDB slow-query logs in next-gen tests - #5816

Open
tenfyzhong wants to merge 1 commit into
pingcap:masterfrom
tenfyzhong:fix/5814-unique-tidb-slow-logs
Open

tests: isolate TiDB slow-query logs in next-gen tests#5816
tenfyzhong wants to merge 1 commit into
pingcap:masterfrom
tenfyzhong:fix/5814-unique-tidb-slow-logs

Conversation

@tenfyzhong

@tenfyzhong tenfyzhong commented Jul 29, 2026

Copy link
Copy Markdown
Collaborator

What problem does this PR solve?

Issue Number: close #5814

The next-gen storage integration pipeline starts five TiDB processes in
parallel. Without explicit slow-query log paths, they all initialize the
default tidb-slow.log, which can make one process exit before TiCDC starts.

What is changed and how it works?

  • Configure every next-gen TiDB process with a slow-query log in its own log
    directory.
  • Add a regression test that verifies all five startup commands use the
    expected distinct paths.

Check List

Tests

  • Unit test
  • Manual test:
    • go test ./tests/integration_tests/_utils -count=1
    • bash -n tests/integration_tests/_utils/start_tidb_cluster_nextgen
    • make check

Questions

Will it cause performance regression or break compatibility?

No. The change only isolates TiDB slow-query log files in the integration test
environment.

Do you need to update user documentation, design documentation or monitoring documentation?

No.

Release note

None

Summary by CodeRabbit

  • Improvements

    • TiDB instances now record slow queries in dedicated log files, making performance troubleshooting easier.
    • Separate logs are maintained for upstream and downstream instances, including their different keyspaces.
  • Tests

    • Added coverage to verify that all TiDB instances use configured and unique slow-query log paths.

Configure each next-gen TiDB instance with its own slow-query log
to avoid the cross-process logger initialization race.

Add a regression test that checks all startup commands use distinct
slow-query log paths.

Closes pingcap#5814

Signed-off-by: tenfyzhong <tenfy@tenfy.cn>
@ti-chi-bot ti-chi-bot Bot added release-note-none Denotes a PR that doesn't merit a release note. do-not-merge/needs-triage-completed size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Jul 29, 2026
@tenfyzhong

Copy link
Copy Markdown
Collaborator Author

/run-check-issue-triage-complete

@coderabbitai

coderabbitai Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The next-gen TiDB startup script assigns unique tidb-slow.log paths to five TiDB instances. A regression test verifies every launch configures a distinct expected path.

Changes

TiDB slow-query log isolation

Layer / File(s) Summary
Startup configuration and regression coverage
tests/integration_tests/_utils/start_tidb_cluster_nextgen, tests/integration_tests/_utils/start_tidb_cluster_nextgen_test.go
All five TiDB launches receive instance-specific --log-slow-query paths, and the test validates their count, presence, uniqueness, and expected patterns.

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

Suggested reviewers: wlwilliamx

Poem

I’m a bunny with logs in a row,
Five paths where the slow queries go.
No files intertwine,
Each trail is unique and fine—
Hop safely, TiDB, through the flow!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: isolating TiDB slow-query logs in next-gen tests.
Description check ✅ Passed The description follows the template and includes the issue number, change summary, tests, questions, and release note.
Linked Issues check ✅ Passed The PR meets #5814 by assigning unique slow-query log paths to all TiDB instances and adding a regression test.
Out of Scope Changes check ✅ Passed The diff stays focused on the slow-query log fix and its regression test with no unrelated 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

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
Contributor

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 `@tests/integration_tests/_utils/start_tidb_cluster_nextgen_test.go`:
- Around line 57-59: Update the slow-query option validation around
slowQueryLogPattern to find all matches in each command, require exactly one
occurrence, and only then record that match’s log path in slowQueryLogs.
Preserve the existing failure message context and path recording behavior for
valid commands.
🪄 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: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: f217498a-bcd6-435a-a961-495916e13623

📥 Commits

Reviewing files that changed from the base of the PR and between 03f7767 and 611a13c.

📒 Files selected for processing (2)
  • tests/integration_tests/_utils/start_tidb_cluster_nextgen
  • tests/integration_tests/_utils/start_tidb_cluster_nextgen_test.go

Comment on lines +57 to +59
matches := slowQueryLogPattern.FindStringSubmatch(command)
require.Len(t, matches, 2, "TiDB command must configure a slow-query log:\n%s", command)
slowQueryLogs[matches[1]] = struct{}{}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Require exactly one slow-query-log option per command.

Line 57 only captures the first match, so a duplicate --log-slow-query option can evade this regression test. Match all occurrences and require one before recording its path.

Proposed fix
-		matches := slowQueryLogPattern.FindStringSubmatch(command)
-		require.Len(t, matches, 2, "TiDB command must configure a slow-query log:\n%s", command)
-		slowQueryLogs[matches[1]] = struct{}{}
+		matches := slowQueryLogPattern.FindAllStringSubmatch(command, -1)
+		require.Len(t, matches, 1, "TiDB command must configure exactly one slow-query log:\n%s", command)
+		slowQueryLogs[matches[0][1]] = struct{}{}
📝 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
matches := slowQueryLogPattern.FindStringSubmatch(command)
require.Len(t, matches, 2, "TiDB command must configure a slow-query log:\n%s", command)
slowQueryLogs[matches[1]] = struct{}{}
matches := slowQueryLogPattern.FindAllStringSubmatch(command, -1)
require.Len(t, matches, 1, "TiDB command must configure exactly one slow-query log:\n%s", command)
slowQueryLogs[matches[0][1]] = struct{}{}
🤖 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 `@tests/integration_tests/_utils/start_tidb_cluster_nextgen_test.go` around
lines 57 - 59, Update the slow-query option validation around
slowQueryLogPattern to find all matches in each command, require exactly one
occurrence, and only then record that match’s log path in slowQueryLogs.
Preserve the existing failure message context and path recording behavior for
valid commands.

@ti-chi-bot

ti-chi-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: wk989898

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

The pull request process is described 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

@ti-chi-bot ti-chi-bot Bot added needs-1-more-lgtm Indicates a PR needs 1 more LGTM. approved labels Jul 29, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 29, 2026

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2026-07-29 11:57:40.110564986 +0000 UTC m=+2010846.146660072: ☑️ agreed by wk989898.

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

Labels

approved needs-1-more-lgtm Indicates a PR needs 1 more LGTM. release-note-none Denotes a PR that doesn't merit a release note. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Next-gen integration tests race on shared TiDB slow log

2 participants