-
Notifications
You must be signed in to change notification settings - Fork 729
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
core: separate region lock #5720
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
Codecov ReportBase: 75.58% // Head: 75.60% // Increases project coverage by
Additional details and impacted files@@ Coverage Diff @@
## master #5720 +/- ##
==========================================
+ Coverage 75.58% 75.60% +0.01%
==========================================
Files 330 330
Lines 32895 32927 +32
==========================================
+ Hits 24864 24894 +30
- Misses 5880 5885 +5
+ Partials 2151 2148 -3
Flags with carried forward coverage won't be shown. Click here to find out more.
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. ☔ View full report at Codecov. |
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.
we can remove RWMutex
in Regions
@@ -565,6 +566,7 @@ func TestStoreVersionChange(t *testing.T) { | |||
|
|||
func TestConcurrentHandleRegion(t *testing.T) { | |||
re := require.New(t) | |||
deadlock.Opts.DeadlockTimeout = time.Minute |
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.
Why 1min?
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.
The default value is 30s, which will report potential deadlock when running the concurrent region heartbeat test since the deadlock detection will cost much time.
checkRegion(re, cache.GetRegion(i), newRegion) | ||
checkRegion(re, cache.GetRegionByKey(regionKey), newRegion) | ||
checkRegions(re, cache, regions[0:(i+1)]) | ||
|
||
cache.RemoveRegion(region) | ||
cache.RemoveRegionFromSubTree(region) |
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.
Why split it?
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.
It is intended to split region lock into region tree lock and subtree lock.
server/core/basic_cluster.go
Outdated
mu syncutil.RWMutex | ||
*RegionsInfo | ||
} | ||
Regions *RegionsInfo |
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.
How about *RegionsInfo
? It can reduce the repeated definition of many functions.
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.
make sense
server/core/basic_cluster.go
Outdated
bc.Regions.RemoveRegion(region) | ||
bc.Regions.RemoveRegionFromSubTree(region) |
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.
Is it possible for temporary Tree
and SubTree
inconsistencies to introduce risks?
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 kind of risk? I think subtree is used for scheduling mostly.
server/schedule/range_cluster.go
Outdated
@@ -31,7 +31,8 @@ type RangeCluster struct { | |||
func GenRangeCluster(cluster Cluster, startKey, endKey []byte) *RangeCluster { | |||
subCluster := core.NewBasicCluster() | |||
for _, r := range cluster.ScanRegions(startKey, endKey, -1) { | |||
subCluster.Regions.SetRegion(r) | |||
origin, _, toRemove, rangeChanged := subCluster.Regions.SetRegionWithUpdate(r) | |||
subCluster.Regions.UpdateSubTree(r, origin, toRemove, rangeChanged) |
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.
ditto
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.
rest LGTM
t syncutil.RWMutex | ||
tree *regionTree | ||
regions map[uint64]*regionItem // regionID -> regionInfo | ||
st syncutil.RWMutex | ||
subRegions map[uint64]*regionItem // regionID -> regionInfo |
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.
Use code like this to identify the scope:
regionTree struct {
syncutil.RWMutex
*regionTree
}
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.
The map also needs to be locked, so maybe wrap them later?
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
Signed-off-by: Ryan Leung <[email protected]>
/hold |
/hold cancel |
/merge |
@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. |
This pull request has been accepted and is ready to merge. Commit hash: 9931950
|
@rleungx: Your PR was out of date, I have automatically updated it for you. At the same time I will also trigger all tests for you: /run-all-tests If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes. 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. |
Signed-off-by: Ryan Leung [email protected]
What problem does this PR solve?
Issue Number: Ref #5712, #5586, #5648.
What is changed and how does it work?
master:
this branch:
Check List
Tests
Release note