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

client: fix pd client panic #6441

Merged
merged 1 commit into from
May 12, 2023
Merged

client: fix pd client panic #6441

merged 1 commit into from
May 12, 2023

Conversation

zeminzhou
Copy link

@zeminzhou zeminzhou commented May 11, 2023

What problem does this PR solve?

Issue Number: Close #6440

What is changed and how does it work?

Initialize metrics, but do not register

Check List

Tests

  • Unit test
  • Integration test
  • Manual test (add detailed scripts or steps below)
  1. change tidb code: call WithInitMetrics(false) when creating pd client.
  2. start tidb cluster
  3. curl http://127.0.0.1:10080/metrics
    image

Code changes

Side effects

  • Possible performance regression
  • Increased code complexity
  • Breaking backward compatibility

Related changes

Release note

None.

Signed-off-by: zeminzhou <zhouzemin@pingcap.com>
@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented May 11, 2023

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • binshi-bing
  • rleungx

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

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

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

Copy link
Contributor

@binshi-bing binshi-bing left a comment

Choose a reason for hiding this comment

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

LGTM

@ti-chi-bot ti-chi-bot bot added the status/LGT1 Indicates that a PR has LGTM 1. label May 11, 2023
@codecov
Copy link

codecov bot commented May 11, 2023

Codecov Report

Patch coverage: 100.00% and project coverage change: +0.08 🎉

Comparison is base (b159dd2) 74.97% compared to head (dc6b5f8) 75.05%.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #6441      +/-   ##
==========================================
+ Coverage   74.97%   75.05%   +0.08%     
==========================================
  Files         409      409              
  Lines       41491    41493       +2     
==========================================
+ Hits        31107    31144      +37     
+ Misses       7676     7647      -29     
+ Partials     2708     2702       -6     
Flag Coverage Δ
unittests 75.05% <100.00%> (+0.08%) ⬆️

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

Impacted Files Coverage Δ
client/metrics.go 100.00% <100.00%> (ø)

... and 36 files with indirect coverage changes

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

@@ -23,6 +23,11 @@ import (
// make sure register metrics only once
var initialized int32

func init() {
initMetrics(prometheus.Labels{})
initCmdDurations()
Copy link
Member

Choose a reason for hiding this comment

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

Do we still need to call it inside initAndRegisterMetrics?

Copy link
Author

@zeminzhou zeminzhou May 11, 2023

Choose a reason for hiding this comment

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

yesh, if callers want to add const labels, we should reinitialize variables with const labels.

@ti-chi-bot ti-chi-bot bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels May 12, 2023
@rleungx
Copy link
Member

rleungx commented May 12, 2023

/run-check-issue-triage-complete

@rleungx
Copy link
Member

rleungx commented May 12, 2023

/merge

@ti-chi-bot
Copy link
Contributor

ti-chi-bot bot commented May 12, 2023

@rleungx: It seems you want to merge this PR, I will help you trigger all the tests:

/run-all-tests

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
Copy link
Contributor

ti-chi-bot bot commented May 12, 2023

This pull request has been accepted and is ready to merge.

Commit hash: dc6b5f8

@ti-chi-bot ti-chi-bot bot added the status/can-merge Indicates a PR has been approved by a committer. label May 12, 2023
@ti-chi-bot ti-chi-bot bot merged commit 0b40c3f into tikv:master May 12, 2023
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
release-note-none status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

PD client panic if turnsing off c.option.initMetrics when creating a pd client?
3 participants