Skip to content

server: add logging for profiling requests (#69897)#69945

Open
ti-chi-bot wants to merge 2 commits into
pingcap:release-8.5from
ti-chi-bot:cherry-pick-69897-to-release-8.5
Open

server: add logging for profiling requests (#69897)#69945
ti-chi-bot wants to merge 2 commits into
pingcap:release-8.5from
ti-chi-bot:cherry-pick-69897-to-release-8.5

Conversation

@ti-chi-bot

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

Copy link
Copy Markdown
Member

This is an automated cherry-pick of #69897

What problem does this PR solve?

Issue Number: close #69896

Problem Summary:
See #69896

What changed and how does it work?

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)

[2026/07/17 10:46:34.892 +08:00] [INFO] [http_status.go:230] ["profiling request received"] [method=GET] [path=/debug/pprof/mutex] [remote-addr=127.0.0.1:53315] [debug=1]
[2026/07/17 10:46:34.892 +08:00] [INFO] [http_status.go:230] ["profiling request received"] [method=GET] [path=/debug/pprof/profile] [remote-addr=127.0.0.1:53314] [seconds=30]
[2026/07/17 10:46:34.892 +08:00] [INFO] [http_status.go:230] ["profiling request received"] [method=GET] [path=/debug/pprof/heap] [remote-addr=127.0.0.1:53311]
[2026/07/17 10:46:34.892 +08:00] [INFO] [http_status.go:230] ["profiling request received"] [method=GET] [path=/debug/pprof/goroutine] [remote-addr=127.0.0.1:53312] [debug=1]

[2026/07/20 11:53:09.809 +08:00] [INFO] [http_status.go:230] ["profiling request received"] [method=GET] [path=/debug/zip] [remote-addr=127.0.0.1:63746] [seconds=1]

[2026/07/20 11:48:56.409 +08:00] [INFO] [tables.go:254] ["profiling request received"] [table=performance_schema.tidb_profile_goroutines] [conn=2631925766] [user=root@127.0.0.1] [client-ip=127.0.0.1]
[2026/07/20 11:50:03.338 +08:00] [INFO] [tables.go:254] ["profiling request received"] [table=performance_schema.tidb_profile_cpu] [conn=2631925766] [user=root@127.0.0.1] [client-ip=127.0.0.1]
  • 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

Summary by CodeRabbit

  • New Features

    • Added logging for profiling requests from HTTP debug endpoints and performance schema profiling tables.
    • Profiling logs include request method, path, remote address, and relevant query parameters.
  • Tests

    • Expanded coverage to verify profiling logs for debug routes, ZIP dumps, and performance schema profiling requests.
    • Added validation for expected profiling request details and counts.

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. sig/planner SIG: Planner size/L Denotes a PR that changes 100-499 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 20, 2026
@ti-chi-bot

ti-chi-bot Bot commented Jul 20, 2026

Copy link
Copy Markdown

This cherry pick PR is for a release branch and has not yet been approved by triage owners.
Adding the do-not-merge/cherry-pick-not-approved label.

To merge this cherry pick:

  1. It must be LGTMed and approved by the reviewers firstly.
  2. For pull requests to TiDB-x branches, it must have no failed tests.
  3. AFTER it has lgtm and approved labels, please wait for the cherry-pick merging approval from triage owners.
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.

@ti-chi-bot

Copy link
Copy Markdown
Member Author

@gengliqi This PR has conflicts, I have hold it.
Please resolve them or ask others to resolve them, then comment /unhold to remove the hold label.

@ti-chi-bot

ti-chi-bot Bot commented Jul 20, 2026

Copy link
Copy Markdown

@ti-chi-bot: ## If you want to know how to resolve it, please read the guide in TiDB Dev Guide.

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 ti-community-infra/tichi repository.

@ti-chi-bot ti-chi-bot Bot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jul 20, 2026
@coderabbitai

coderabbitai Bot commented Jul 20, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: bccc4508-3feb-47d0-9f9b-a4f9c75db3e6

📥 Commits

Reviewing files that changed from the base of the PR and between 35a2a46 and 78afdaf.

📒 Files selected for processing (1)
  • pkg/server/http_status.go
💤 Files with no reviewable changes (1)
  • pkg/server/http_status.go

📝 Walkthrough

Walkthrough

Profiling requests through HTTP debug routes and performance_schema.tidb_profile_* tables now emit structured logs containing request context. Server and profile tests capture Zap output and verify expected messages and fields.

Changes

Profiling request logging

Layer / File(s) Summary
Performance schema profiling logs
pkg/infoschema/perfschema/tables.go, pkg/infoschema/perfschema/BUILD.bazel
TiDB profile table reads log connection ID plus optional user and client IP before collecting CPU, heap, mutex, allocation, block, or goroutine profiles.
HTTP profiling request wrapper
pkg/server/http_status.go
pprof and debug ZIP routes log method, path, remote address, and selected query parameters before invoking their handlers.
Observer-based profiling log tests
pkg/server/handler/tests/*, pkg/util/profile/*
Tests capture Zap logs and verify profiling request counts, messages, paths, query parameters, and request context fields.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client
  participant HTTPRouter
  participant withProfilingRequestLog
  participant ProfilingHandler
  participant ZapLogger
  Client->>HTTPRouter: Request profiling endpoint
  HTTPRouter->>withProfilingRequestLog: Dispatch request
  withProfilingRequestLog->>ZapLogger: Record request fields
  withProfilingRequestLog->>ProfilingHandler: Invoke handler
  ProfilingHandler-->>Client: Return profiling response
Loading

Possibly related PRs

  • pingcap/tidb#69897: Implements the same HTTP profiling request logging and observer-based handler tests.
  • pingcap/tidb#69946: Implements the same HTTP and performance schema profiling logging behavior.

Suggested reviewers: windtalker, bb7133, wjhuang2016

Poem

I’m a rabbit with logs in my burrow tonight,
Pprof paths sparkle in structured moonlight.
CPU and heap leave footprints behind,
With method and address neatly aligned.
Tests hop through each record with cheer—
“Profiling request received!” loud and clear.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Description check ⚠️ Warning The required "What changed and how does it work?" section is effectively empty, so the PR description is incomplete. Add a brief summary of the code changes and how the new profiling-request logging works, plus any key implementation details.
Docstring Coverage ⚠️ Warning Docstring coverage is 11.11% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding profiling request logging on the server.
Linked Issues check ✅ Passed The changes add logging for /debug/pprof/, /debug/zip, and performance_schema.tidb_profile_ as requested by issue #69896.
Out of Scope Changes check ✅ Passed The changes are limited to profiling-request logging plus related tests and build deps, with no unrelated scope apparent.
✨ 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

Choose a reason for hiding this comment

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

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 @.agents/skills/tidb-test-guidelines/references/server-case-map.md:
- Line 7: Update the server case map overview to include a Testdata section
documenting the ownership of the `testdata/optimizer_suite` data loaded by
`pkg/server/main_test.go` through `LoadTestSuiteData`. Alternatively, remove the
overview’s promise of testdata mappings, but keep the documentation consistent
with the chosen behavior.

In @.agents/skills/tidb-test-guidelines/references/util-case-map.md:
- Line 208: The util-case test-description mappings in the referenced entries
contain mechanically split acronyms; update the descriptions for the symbols
around “is ti flash h t t p resp,” “s e m methods,” “get o s version,” and “get
t z name” to use readable “TiFlash HTTP response,” “SEM methods,” “OS version,”
and “TZ name” wording while preserving the existing mapping structure.

In `@pkg/server/http_status.go`:
- Around line 329-407: Resolve the conflict in the HTTP route registration block
by removing all conflict markers and retaining only branch-compatible changes.
Keep the profiling request logging wrappers and existing intended routes, but
verify that StandbyController, traceeventHandler, and coverage support symbols
exist; otherwise remove or implement those additions consistently. If
/debug/traceevent and /covdata remain, update the HTTP API documentation and
document their StandbyController and TIDB_GOCOVERDIR conditions.
🪄 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: 3cd2e998-6d6d-4027-83e1-d96faf731830

📥 Commits

Reviewing files that changed from the base of the PR and between b69c871 and 35a2a46.

📒 Files selected for processing (10)
  • .agents/skills/tidb-test-guidelines/references/server-case-map.md
  • .agents/skills/tidb-test-guidelines/references/util-case-map.md
  • pkg/infoschema/perfschema/BUILD.bazel
  • pkg/infoschema/perfschema/tables.go
  • pkg/server/handler/tests/BUILD.bazel
  • pkg/server/handler/tests/http_handler_serial_test.go
  • pkg/server/handler/tests/http_handler_test.go
  • pkg/server/http_status.go
  • pkg/util/profile/BUILD.bazel
  • pkg/util/profile/profile_test.go

Comment thread .agents/skills/tidb-test-guidelines/references/server-case-map.md Outdated
## pkg/util/engine

### Tests
- `pkg/util/engine/engine_test.go` - util/engine: Tests is ti flash h t t p resp.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Fix mechanically split acronyms in test descriptions.

Descriptions such as is ti flash h t t p resp, s e m methods, get o s version, and get t z name are not readable. Preserve the intended acronyms and use clear descriptions such as “TiFlash HTTP response,” “SEM methods,” “OS version,” and “TZ name.”

Also applies to: 492-492, 559-559, 601-601

🤖 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 @.agents/skills/tidb-test-guidelines/references/util-case-map.md at line 208,
The util-case test-description mappings in the referenced entries contain
mechanically split acronyms; update the descriptions for the symbols around “is
ti flash h t t p resp,” “s e m methods,” “get o s version,” and “get t z name”
to use readable “TiFlash HTTP response,” “SEM methods,” “OS version,” and “TZ
name” wording while preserving the existing mapping structure.

Comment thread pkg/server/http_status.go Outdated
u
Signed-off-by: gengliqi <gengliqiii@gmail.com>
@ti-chi-bot ti-chi-bot Bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jul 20, 2026
@ti-chi-bot

Copy link
Copy Markdown
Member Author

Cherry-pick conflicts appear resolved; removing the do-not-merge/hold label.

@ti-chi-bot ti-chi-bot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jul 20, 2026
@codecov

codecov Bot commented Jul 20, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 84.61538% with 6 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (release-8.5@b69c871). Learn more about missing BASE report.

Additional details and impacted files
@@               Coverage Diff                @@
##             release-8.5     #69945   +/-   ##
================================================
  Coverage               ?   55.6684%           
================================================
  Files                  ?       1849           
  Lines                  ?     666286           
  Branches               ?          0           
================================================
  Hits                   ?     370911           
  Misses                 ?     267786           
  Partials               ?      27589           
Flag Coverage Δ
integration 39.0995% <15.3846%> (?)
unit 65.2201% <84.6153%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
dumpling 55.3108% <0.0000%> (?)
parser ∅ <0.0000%> (?)
br 63.0279% <0.0000%> (?)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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

ti-chi-bot Bot commented Jul 20, 2026

Copy link
Copy Markdown

[LGTM Timeline notifier]

Timeline:

  • 2026-07-20 08:04:33.514294274 +0000 UTC m=+1219259.550389329: ☑️ agreed by gengliqi.
  • 2026-07-20 08:18:31.696734814 +0000 UTC m=+1220097.732829869: ☑️ agreed by YangKeao.

@ti-chi-bot

ti-chi-bot Bot commented Jul 20, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: gengliqi, wjhuang2016, YangKeao

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 the approved label Jul 20, 2026
@gengliqi

Copy link
Copy Markdown
Contributor

/retest

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

Labels

approved do-not-merge/cherry-pick-not-approved lgtm release-note-none Denotes a PR that doesn't merit a release note. sig/planner SIG: Planner size/L Denotes a PR that changes 100-499 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.

4 participants