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: fix the problem that the hot cache cannot be emptied when the interval is less than 60 (#4396) #4431

Conversation

ti-chi-bot
Copy link
Member

@ti-chi-bot ti-chi-bot commented Dec 7, 2021

This is an automated cherry-pick of #4396,wait for #4446

What problem does this PR solve?

close #4390

What is changed and how it works?

Our current heartbeat process looks like this.

If the interval is less than the default interval for heartbeats (60 seconds), then we will put it into the cache temporarily and wait until it has made up 60 seconds before considering whether it is hot enough.

For a peer that has just been reported, if the region is also in the hot cache, then there are three cases.

  1. the store is the same, then the old item is used directly
  2. the store is different, but there is a move peer or transfer leader in the previous round, then the inheritable item is directly used as the old item
  3. store is different, and there is no inheritable peer, then choose any peer as old item

The problem occurs in the third branch, if the old peer is used directly without clone, then the old item and the new item will be written at the same time. And when the new peer interval is less than 60 seconds, it means that it will be temporarily put into the cache.

If the old peer will be cooled down at this time, it will keep the peer in the hot cache for a long time and cannot be exited.

This pr does a clone for the third branch to avoid this problem, and changes the store and region heartbeats to configurable in another pr.

Check List

Tests

  • Unit test

Release note

fix the problem that the hot cache cannot be emptied when the interval is less than 60 

@ti-chi-bot
Copy link
Member Author

ti-chi-bot commented Dec 7, 2021

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • JmPotato

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.

Signed-off-by: lhy1024 <admin@liudos.us>
@lhy1024 lhy1024 force-pushed the cherry-pick-4396-to-release-4.0 branch from e46a4e5 to 1fafee4 Compare December 8, 2021 11:57
@codecov
Copy link

codecov bot commented Dec 8, 2021

Codecov Report

Merging #4431 (1fafee4) into release-4.0 (3a23716) will decrease coverage by 0.60%.
The diff coverage is 59.52%.

Impacted file tree graph

@@               Coverage Diff               @@
##           release-4.0    #4431      +/-   ##
===============================================
- Coverage        75.38%   74.78%   -0.61%     
===============================================
  Files              211      211              
  Lines            20090    20129      +39     
===============================================
- Hits             15145    15053      -92     
- Misses            3613     3739     +126     
- Partials          1332     1337       +5     
Flag Coverage Δ
unittests 74.78% <59.52%> (-0.61%) ⬇️

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

Impacted Files Coverage Δ
server/statistics/avg_over_time.go 65.78% <0.00%> (-20.42%) ⬇️
server/statistics/flowkind.go 0.00% <0.00%> (ø)
server/statistics/hot_peer.go 100.00% <ø> (ø)
server/statistics/hot_peer_cache.go 92.45% <100.00%> (+0.39%) ⬆️
server/statistics/queue.go 100.00% <100.00%> (ø)
server/statistics/util.go 100.00% <100.00%> (ø)
server/statistics/store_collection.go 58.53% <0.00%> (-34.96%) ⬇️
server/schedulers/shuffle_hot_region.go 57.14% <0.00%> (-12.50%) ⬇️
server/region_syncer/server.go 79.41% <0.00%> (-9.56%) ⬇️
server/kv/etcd_kv.go 78.26% <0.00%> (-7.25%) ⬇️
... and 12 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 3a23716...1fafee4. Read the comment docs.

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Dec 16, 2021
@ti-chi-bot
Copy link
Member Author

[FORMAT CHECKER NOTIFICATION]

Please provide the associated issue number in the commit messages, for example: close #12345, or ref #12345.

@lhy1024 lhy1024 added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Dec 17, 2021
@zhouqiang-cl zhouqiang-cl added the cherry-pick-approved Cherry pick PR approved by release team. label Dec 21, 2021
@VelocityLight
Copy link

This pull request is closed because it's related version has closed automatic cherry-picking.
If it's still needed, you can reopen it or just regenerate it using bot,
see:

You can find more details at:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cherry-pick-approved Cherry pick PR approved by release team. component/statistics Statistics for scheduling. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. do-not-merge/invalid-commit-message release-note Denotes a PR that will be considered when it comes time to generate release notes. status/LGT1 Indicates that a PR has LGTM 1. type/cherry-pick-for-release-4.0 The PR belongs to release-4.0 cherry pick.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants