server, session: fix load data slow log recording#69552
Conversation
|
Hi @Meowooh. Thanks for your PR. I'm waiting for a pingcap member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions 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. |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThis PR adds a ChangesSlow log test re-enablement and file-transfer dispatch cleanup
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant Session
participant Conn as ClientConn
participant Executor as executor.FileTransInConnHandlers
Session->>Conn: hasFileTransInConn()
Conn->>Executor: iterate handler keys
Note over Conn,Executor: handleFileTransInConn()
Conn->>Executor: for each key, check cc.ctx.Value(key)
Executor-->>Conn: handler(ctx, value, getDataFromPath)
Conn->>Conn: clear cc.ctx key, return on error
Possibly related issues
Suggested labels: 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 `@pkg/server/internal/testserverclient/server_client.go`:
- Around line 445-449: The deferred cleanup in server_client.go restores only
config, but the process-global logger set by logutil.InitLogger still points at
the temp slow-log sink when os.Remove deletes it. Update the same defer in the
test setup to restore the original logger state before removing
newCfg.Log.SlowQueryFile, using the existing logger/config setup around
logutil.InitLogger and config.StoreGlobalConfig so later tests do not keep
writing to a deleted file.
🪄 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
Run ID: 083d385e-3005-4566-aae8-719e5b6712fb
📒 Files selected for processing (2)
pkg/server/internal/testserverclient/server_client.gopkg/session/session.go
💤 Files with no reviewable changes (1)
- pkg/session/session.go
| defer func() { | ||
| config.StoreGlobalConfig(originCfg) | ||
| require.NoError(t, os.Remove(newCfg.Log.SlowQueryFile)) | ||
| }() | ||
| require.NoError(t, logutil.InitLogger(newCfg.Log.ToLogConfig())) |
There was a problem hiding this comment.
🩺 Stability & Availability | 🟠 Major | ⚡ Quick win
Restore the global logger before deleting the temp slow log.
logutil.InitLogger changes process-global logging state, but the defer only restores config; later tests can keep using the temp slow-log sink after Line 447 removes it. Reinitialize the original logger in the same defer, before removing the file.
Suggested fix
defer func() {
config.StoreGlobalConfig(originCfg)
+ require.NoError(t, logutil.InitLogger(originCfg.Log.ToLogConfig()))
require.NoError(t, os.Remove(newCfg.Log.SlowQueryFile))
}()As per coding guidelines, Go error handling should be actionable and contextual; this keeps the global test process state consistent after the test.
📝 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.
| defer func() { | |
| config.StoreGlobalConfig(originCfg) | |
| require.NoError(t, os.Remove(newCfg.Log.SlowQueryFile)) | |
| }() | |
| require.NoError(t, logutil.InitLogger(newCfg.Log.ToLogConfig())) | |
| defer func() { | |
| config.StoreGlobalConfig(originCfg) | |
| require.NoError(t, logutil.InitLogger(originCfg.Log.ToLogConfig())) | |
| require.NoError(t, os.Remove(newCfg.Log.SlowQueryFile)) | |
| }() | |
| require.NoError(t, logutil.InitLogger(newCfg.Log.ToLogConfig())) |
🤖 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/internal/testserverclient/server_client.go` around lines 445 -
449, The deferred cleanup in server_client.go restores only config, but the
process-global logger set by logutil.InitLogger still points at the temp
slow-log sink when os.Remove deletes it. Update the same defer in the test setup
to restore the original logger state before removing newCfg.Log.SlowQueryFile,
using the existing logger/config setup around logutil.InitLogger and
config.StoreGlobalConfig so later tests do not keep writing to a deleted file.
Source: Coding guidelines
|
/ok-to-test |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #69552 +/- ##
================================================
- Coverage 76.3270% 74.2872% -2.0399%
================================================
Files 2041 2050 +9
Lines 561007 581598 +20591
================================================
+ Hits 428200 432053 +3853
- Misses 131906 148634 +16728
- Partials 901 911 +10
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
/retest |
|
/retest |
What problem does this PR solve?
Issue Number: close #32034
Problem Summary:
RunTestLoadDataForSlowLogwas skipped because transactionalLOAD DATA LOCALstill keptLoadDataVarKeyin the session file-transfer bypass list. That maderunStmtskip normal statement finalization, while the connection no longer handled LOAD DATA throughhandleFileTransInConn, so the slow log and statement summary were not recorded.What changed and how does it work?
Remove
LoadDataVarKeyfromfileTransInConnKeysso transactionalLOAD DATA LOCALfinishes through the normal statement path and records slow log / statement summary data.Re-enable
RunTestLoadDataForSlowLogwith an isolated slow log file and update the LoadData plan assertion to match the current runtime fields.Check List
Tests
Commands run:
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.
Summary by CodeRabbit
New Features
Bug Fixes