tests: isolate TiDB slow-query logs in next-gen tests - #5816
Conversation
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>
|
/run-check-issue-triage-complete |
📝 WalkthroughWalkthroughThe next-gen TiDB startup script assigns unique ChangesTiDB slow-query log isolation
Estimated code review effort: 2 (Simple) | ~10 minutes Suggested reviewers: Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (2)
tests/integration_tests/_utils/start_tidb_cluster_nextgentests/integration_tests/_utils/start_tidb_cluster_nextgen_test.go
| matches := slowQueryLogPattern.FindStringSubmatch(command) | ||
| require.Len(t, matches, 2, "TiDB command must configure a slow-query log:\n%s", command) | ||
| slowQueryLogs[matches[1]] = struct{}{} |
There was a problem hiding this comment.
🎯 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.
| 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.
|
[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 DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
[LGTM Timeline notifier]Timeline:
|
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?
directory.
expected distinct paths.
Check List
Tests
go test ./tests/integration_tests/_utils -count=1bash -n tests/integration_tests/_utils/start_tidb_cluster_nextgenmake checkQuestions
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
Summary by CodeRabbit
Improvements
Tests