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) #4433

Merged

Conversation

ti-chi-bot
Copy link
Member

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

This is a cherry-pick of #4396, #4446, #4512

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 

Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
@ti-chi-bot
Copy link
Member Author

ti-chi-bot commented Dec 7, 2021

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • JmPotato
  • 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.

Signed-off-by: lhy1024 <admin@liudos.us>
Signed-off-by: lhy1024 <admin@liudos.us>
@codecov
Copy link

codecov bot commented Dec 7, 2021

Codecov Report

Merging #4433 (44e5b68) into release-5.1 (f4ed192) will decrease coverage by 0.14%.
The diff coverage is 95.38%.

Impacted file tree graph

@@               Coverage Diff               @@
##           release-5.1    #4433      +/-   ##
===============================================
- Coverage        75.31%   75.17%   -0.15%     
===============================================
  Files              245      245              
  Lines            24728    24771      +43     
===============================================
- Hits             18625    18621       -4     
- Misses            4482     4518      +36     
- Partials          1621     1632      +11     
Flag Coverage Δ
unittests 75.17% <95.38%> (-0.15%) ⬇️

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

Impacted Files Coverage Δ
server/statistics/hot_peer.go 96.66% <77.77%> (-3.34%) ⬇️
server/statistics/kind.go 15.62% <83.33%> (+15.62%) ⬆️
pkg/movingaverage/avg_over_time.go 100.00% <100.00%> (ø)
pkg/movingaverage/median_filter.go 100.00% <100.00%> (ø)
pkg/movingaverage/queue.go 100.00% <100.00%> (ø)
pkg/movingaverage/time_median.go 100.00% <100.00%> (ø)
server/statistics/hot_peer_cache.go 96.00% <100.00%> (+0.34%) ⬆️
server/statistics/topn.go 97.95% <100.00%> (ø)
server/tso/global_allocator.go 70.55% <100.00%> (ø)
server/id/id.go 76.19% <0.00%> (-4.77%) ⬇️
... and 13 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 f4ed192...44e5b68. Read the comment docs.

Signed-off-by: lhy1024 <admin@liudos.us>
@lhy1024
Copy link
Contributor

lhy1024 commented Dec 8, 2021

/rebuild

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Dec 16, 2021
@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
Signed-off-by: lhy1024 <admin@liudos.us>
Signed-off-by: lhy1024 <admin@liudos.us>
@lhy1024 lhy1024 removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 21, 2022
Signed-off-by: lhy1024 <admin@liudos.us>
@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jan 21, 2022
@nolouch
Copy link
Contributor

nolouch commented Jan 25, 2022

/merge

@ti-chi-bot
Copy link
Member Author

@nolouch: 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
Member Author

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

Commit hash: cf91b4d

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Jan 25, 2022
@JmPotato
Copy link
Member

/run-unit-test

@nolouch
Copy link
Contributor

nolouch commented Jan 26, 2022

/run-unit-tests

1 similar comment
@rleungx
Copy link
Member

rleungx commented Jan 26, 2022

/run-unit-tests

@nolouch
Copy link
Contributor

nolouch commented Jan 26, 2022

/rebuild

1 similar comment
@purelind
Copy link
Contributor

/rebuild

@nolouch
Copy link
Contributor

nolouch commented Jan 26, 2022

/run-unit-tests

1 similar comment
@nolouch
Copy link
Contributor

nolouch commented Jan 26, 2022

/run-unit-tests

@ti-chi-bot ti-chi-bot merged commit 6919bc7 into tikv:release-5.1 Jan 26, 2022
@zhouqiang-cl zhouqiang-cl added this to the v5.1.4 milestone Feb 10, 2022
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. release-note Denotes a PR that will be considered when it comes time to generate release notes. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. type/cherry-pick-for-release-5.1 The PR belongs to release-5.1 cherry pick.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants