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

statistics: make hotPeerCache concurrency safe #3460

Closed
wants to merge 3 commits into from

Conversation

Yisaer
Copy link
Contributor

@Yisaer Yisaer commented Mar 10, 2021

Signed-off-by: Song Gao disxiaofei@163.com

What problem does this PR solve?

In some cases, pd might update the same region and dimension at the same time which will cause the concurrent problem which may let pd panic.

ref #3461

What is changed and how it works?

This request made dimStat concurrency safe.

Check List

Tests

  • Unit test

Release note

  • No release note

Signed-off-by: Song Gao <disxiaofei@163.com>
@ti-chi-bot
Copy link
Member

[REVIEW NOTIFICATION]

This pull request has not been approved.

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 writing /lgtm in a comment.
Reviewer can cancel approval by writing /lgtm cancel in a comment.

@lhy1024
Copy link
Contributor

lhy1024 commented Mar 10, 2021

It should be met only when handling some heartbeats from the same region at the same time.
Maybe we also need to learn why there is this case.

Copy link
Contributor

@lhy1024 lhy1024 left a comment

Choose a reason for hiding this comment

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

the rest LGTM

server/statistics/region_collection_test.go Outdated Show resolved Hide resolved
Signed-off-by: Song Gao <disxiaofei@163.com>
@codecov
Copy link

codecov bot commented Mar 10, 2021

Codecov Report

Merging #3460 (f27397b) into master (722a665) will decrease coverage by 0.13%.
The diff coverage is 95.83%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #3460      +/-   ##
==========================================
- Coverage   75.14%   75.00%   -0.14%     
==========================================
  Files         244      244              
  Lines       23557    23571      +14     
==========================================
- Hits        17702    17680      -22     
- Misses       4287     4311      +24     
- Partials     1568     1580      +12     
Flag Coverage Δ
unittests 75.00% <95.83%> (-0.14%) ⬇️

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

Impacted Files Coverage Δ
server/statistics/hot_peer_cache.go 93.42% <95.65%> (+0.36%) ⬆️
server/core/region_option.go 83.33% <100.00%> (+0.40%) ⬆️
pkg/metricutil/metricutil.go 82.75% <0.00%> (-10.35%) ⬇️
server/tso/global_allocator.go 70.14% <0.00%> (-6.72%) ⬇️
server/member/member.go 70.10% <0.00%> (-2.72%) ⬇️
server/server.go 71.98% <0.00%> (-1.86%) ⬇️
server/schedule/operator/step.go 67.44% <0.00%> (-1.67%) ⬇️
server/tso/allocator_manager.go 76.07% <0.00%> (-1.33%) ⬇️
server/config/persist_options.go 91.33% <0.00%> (-0.79%) ⬇️
client/client.go 67.01% <0.00%> (-0.18%) ⬇️
... and 2 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 722a665...f27397b. Read the comment docs.

@Yisaer Yisaer changed the title statistics: make dimStat concurrency safe statistics: make hotPeerCache concurrency safe Mar 10, 2021
peersOfStore map[uint64]*TopN // storeID -> hot peers
storesOfRegion map[uint64]map[uint64]struct{} // regionID -> storeIDs
mu struct {
sync.RWMutex
Copy link
Member

Choose a reason for hiding this comment

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

Will it have a performance problem?

server/statistics/region_collection_test.go Outdated Show resolved Hide resolved
server/statistics/hot_peer.go Outdated Show resolved Hide resolved
server/statistics/hot_peer_cache.go Show resolved Hide resolved
Signed-off-by: Song Gao <disxiaofei@163.com>
@Yisaer Yisaer force-pushed the fix_process_region_beat_race branch from 9d205f6 to f27397b Compare March 11, 2021 07:54
@HunDunDM
Copy link
Member

/hold

@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. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Mar 11, 2021
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Mar 24, 2021
@Yisaer Yisaer closed this Apr 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants