Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

server: add initial status server to provide debug functionalities before starting server #59122

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

YangKeao
Copy link
Member

@YangKeao YangKeao commented Jan 22, 2025

What problem does this PR solve?

Issue Number: close #59087

Problem Summary:

The /debug/pprof/xxx endpoints in status server and the signal handler of SIGUSR1 are very helpful for the developers to debug running tidb-server. However, they are only available after starting the server. If the TiDB server is somehow blocked before starting successfully (like loading InfoSchema for a very long time), it'll be hard for us to investigate the issue.

What changed and how does it work?

  1. Set the signal handler before most of the bootstrap logic.
  2. Start an initial status server which only handles several /debug/pprof/xxx interface and /metrics interface.
  3. Stop the initial status server before starting the real fully functional status server.

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  • 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

None

@ti-chi-bot ti-chi-bot bot added the release-note-none Denotes a PR that doesn't merit a release note. label Jan 22, 2025
Copy link

ti-chi-bot bot commented Jan 22, 2025

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please ask for approval from yangkeao, ensuring that each of them provides their approval before proceeding. For more information see the Code Review Process.

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

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 size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Jan 22, 2025
Copy link

codecov bot commented Jan 22, 2025

Codecov Report

Attention: Patch coverage is 66.66667% with 22 lines in your changes missing coverage. Please review.

Project coverage is 73.4910%. Comparing base (837b1f5) to head (d973c99).
Report is 9 commits behind head on master.

Additional details and impacted files
@@               Coverage Diff                @@
##             master     #59122        +/-   ##
================================================
+ Coverage   73.0925%   73.4910%   +0.3985%     
================================================
  Files          1684       1684                
  Lines        466350     467408      +1058     
================================================
+ Hits         340867     343503      +2636     
+ Misses       104548     102952      -1596     
- Partials      20935      20953        +18     
Flag Coverage Δ
integration 42.7968% <66.6666%> (?)

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

Components Coverage Δ
dumpling 52.6910% <ø> (ø)
parser ∅ <ø> (∅)
br 45.3290% <ø> (+0.0086%) ⬆️

@ti-chi-bot ti-chi-bot bot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Jan 22, 2025
ctx, cancel := context.WithTimeout(context.Background(), stopInitialStatusServerTimeout)
defer cancel()

err := initialStatusServer.Shutdown(ctx)
Copy link
Member Author

Choose a reason for hiding this comment

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

The only concern is that the requests to /debug/pprof/profile will block the Shutdown for a long time (so I gave it a 5s timeout).

It's also fine to Close directly IMO, but I'm not sure which one is better.

@YangKeao YangKeao force-pushed the fix-59087 branch 3 times, most recently from 9757729 to 60e76e6 Compare January 22, 2025 10:29
Signed-off-by: Yang Keao <[email protected]>
Copy link

ti-chi-bot bot commented Jan 23, 2025

@YangKeao: The following tests failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
idc-jenkins-ci-tidb/build d973c99 link true /test build
idc-jenkins-ci-tidb/unit-test d973c99 link true /test unit-test

Full PR test history. Your PR dashboard.

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. I understand the commands that are listed here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none Denotes a PR that doesn't merit a release note. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Enable the profiling, goroutines, metrics endpoints and signal handler as soon as possible
1 participant