-
Notifications
You must be signed in to change notification settings - Fork 728
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 metrics registration #8994
base: master
Are you sure you want to change the base?
Conversation
Signed-off-by: artem_danilov <[email protected]>
[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.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
Hi @Tema. Thanks for your PR. I'm waiting for a tikv 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. 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. |
Now you can start all CI jobs with |
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #8994 +/- ##
==========================================
- Coverage 76.33% 76.30% -0.04%
==========================================
Files 465 465
Lines 70565 70582 +17
==========================================
- Hits 53867 53856 -11
- Misses 13355 13376 +21
- Partials 3343 3350 +7
Flags with carried forward coverage won't be shown. Click here to find out more. |
var mutex sync.Mutex | ||
var consumersInitializers []func() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about using an atomic.Value
to store []func()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just storing reference to []func()
won't be enough as array append is not atomic operation in golang (it might trigger races in the resize flow). Or am I missing something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your consideration is thorough. My initial intention was to merge the lock on line 33 with line 34 into one structure, making it look more elegant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My initial intention was to merge the lock on line 33 with line 34 into one structure, making it look more elegant.
Do you still insist on the change? If so, could you please show me how you propose to make it work with atomic.Value
which will be atomic and race free?
What problem does this PR solve?
Issue Number: ref #8678
What is changed and how does it work?
@JmPotato if there is a code referencing metrics from the global context like in tikv/client-go#1543 (comment) then they could consume metrics created in the
metrics.init()
method. However, when latter the global metrics are recreated, reinitialized and registered withmetrics.InitAndRegisterMetrics()
the metrics consumed before are abandoned and not reported to prometheus. This PR allows to register metrics consumers, so that if they are consumed beforemetrics.InitAndRegisterMetrics()
in invoked, they are reinitilized and registered later.cc: @rleungx
Check List
Tests
Code changes
Side effects
Related changes
pingcap/docs
/pingcap/docs-cn
:pingcap/tiup
:Release note