release-8.5: backport #66290 | tidb-test=release-8.5-20251125-v8.5.4#68590
Conversation
Signed-off-by: yibin87 <huyibin@pingcap.com>
…ic auto-commit retries - inject unistore failpoint in auto-commit branch - protect audit result collection with a mutex to avoid concurrent append races - switch concurrent UPDATE to and close each - test-only change in , no production logic touched Signed-off-by: yibin87 <huyibin@pingcap.com>
|
Hi @yibin87. Thanks for your PR. PRs from untrusted users cannot be marked as trusted with 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. |
📝 WalkthroughWalkthroughThis PR instruments per-session packet byte accounting and integrates it into TopSQL statement profiling. Packet bytes are tracked at the network level, threaded through the TopSQL observer API, and used by the reporter to prioritize high-network-usage statements. Supporting changes include audit test concurrency safety improvements and a tipb dependency upgrade. ChangesTopSQL Network Byte Profiling
Audit Plugin Retry Test Concurrency Safety
tipb Dependency Upgrade
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (1 warning, 1 inconclusive)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ 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: 3
🤖 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.go`:
- Around line 1285-1286: The counters InPacketBytes and OutPacketBytes are only
reset once in dispatch, so multi-statement COM_QUERYs will have later statements
see bytes from earlier ones; modify the dispatch/COM_QUERY handling so
per-statement metrics use a per-statement baseline or are reset before each
statement execution: either move the
cc.ctx.GetSessionVars().InPacketBytes.Store(0) and OutPacketBytes.Store(0) into
the loop that executes each parsed statement, or record a baseline via
cc.ctx.GetSessionVars().InPacketBytes.Load()/OutPacketBytes.Load() before each
statement and compute deltas when you record digest/network metrics (refer to
dispatch and the COM_QUERY execution loop and the symbols InPacketBytes,
OutPacketBytes, and any per-statement metric recording code).
- Around line 502-504: The outbound byte counter is incremented before the
packet write, so failed writes still increase OutPacketBytes; change the logic
in conn.go to call WritePacket (or the method that performs the socket write)
first, check its returned error, and only if err == nil and cc.getCtx() != nil
call cc.ctx.GetSessionVars().OutPacketBytes.Add(uint64(len(data))) to update the
counter; ensure the nil check uses cc.getCtx() and that the increment is moved
after a successful write.
In `@pkg/util/topsql/reporter/reporter_test.go`:
- Line 691: The test mixes fields from different records: currently it sums
data.DataRecords[1].Items[0].StmtNetworkInBytes with
data.DataRecords[0].Items[0].StmtNetworkOutBytes; change the assertion to sum
both StmtNetworkInBytes and StmtNetworkOutBytes from the same record (e.g.,
data.DataRecords[1].Items[0].StmtNetworkInBytes +
data.DataRecords[1].Items[0].StmtNetworkOutBytes) so the comparison uses values
from the same DataRecords index.
🪄 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: bb55d828-8e10-4827-9b75-0669e286ae39
⛔ Files ignored due to path filters (1)
go.sumis excluded by!**/*.sum
📒 Files selected for processing (16)
go.modpkg/executor/adapter.gopkg/planner/core/find_best_task.gopkg/planner/core/plan_to_pb.gopkg/server/conn.gopkg/server/tests/commontest/tidb_test.gopkg/sessionctx/variable/session.gopkg/util/execdetails/execdetails.gopkg/util/topsql/reporter/BUILD.bazelpkg/util/topsql/reporter/datamodel.gopkg/util/topsql/reporter/reporter.gopkg/util/topsql/reporter/reporter_test.gopkg/util/topsql/stmtstats/BUILD.bazelpkg/util/topsql/stmtstats/aggregator_test.gopkg/util/topsql/stmtstats/stmtstats.gopkg/util/topsql/stmtstats/stmtstats_test.go
Signed-off-by: yibin87 <huyibin@pingcap.com>
ea0da1b to
2b965f7
Compare
2b965f7 to
332baf7
Compare
Signed-off-by: yibin87 <huyibin@pingcap.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## release-8.5-20251125-v8.5.4 #68590 +/- ##
================================================================
Coverage ? 57.1321%
================================================================
Files ? 1784
Lines ? 637041
Branches ? 0
================================================================
Hits ? 363955
Misses ? 248624
Partials ? 24462
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
|
/retest |
|
@yibin87: PRs from untrusted users cannot be marked as trusted with DetailsIn response to this:
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. |
Signed-off-by: yibin87 <huyibin@pingcap.com>
|
/test mysql-test |
|
@yibin87: PRs from untrusted users cannot be marked as trusted with DetailsIn response to this:
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. |
|
/test mysql-test |
|
@yibin87: PRs from untrusted users cannot be marked as trusted with DetailsIn response to this:
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. |
|
/test mysql-test |
|
@yibin87: PRs from untrusted users cannot be marked as trusted with DetailsIn response to this:
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. |
|
/test mysql-test |
|
/test unit-test |
|
@yibin87: PRs from untrusted users cannot be marked as trusted with DetailsIn response to this:
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. |
|
@yibin87: PRs from untrusted users cannot be marked as trusted with DetailsIn response to this:
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. |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: XuHuaiyu, yudongusa, zimulala 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 |
1519add
into
pingcap:release-8.5-20251125-v8.5.4
This is a backport of #66290 to release-8.5-20251125-v8.5.4.
What problem does this PR solve?
Issue Number: ref #62920
Problem Summary:
Add client network in/out stats in TopSQL. And record topN network usage SQLs alongside current topN CPU usage SQLs. Note one SQL will be added at most once.
What changed and how does it work?
InPacketBytesandOutPacketBytesto record the network traffic from/to clients.github.com/pingcap/tipbtov0.0.0-20260522023117-6ceadabb61de(merge commit ofpingcap/tipb#411) to include the TopSQL network fields protocol.Check List
Tests
Side effects
Documentation
Release note
Please refer to Release Notes Language Style Guide to write a quality release note.
Summary by CodeRabbit
Release Notes
New Features
Chores