-
Notifications
You must be signed in to change notification settings - Fork 742
Cache all regions #125
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
Cache all regions #125
Conversation
…iddontang/cache-regions
} | ||
|
||
func cloneRegion(r *metapb.Region) *metapb.Region { | ||
if r == nil { |
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.
proto.Clone()
checks if it is nil
inside.
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.
Seems region should always be not nil? Do we really need to check this?
|
||
if startKey == searchStartKey && endKey == searchEndKey { | ||
// we are the same, must check epoch here. | ||
if err := checkStaleRegion(searchRegion, region); err != nil { |
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.
should we check if searchRegion.version == region.version
instead?
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.
no need now, because now the mechanism can guarantee that if range is same, the version is same.
But we may handle this later if we introduce merge. @qiuyesuifeng has added a comment here in another PR.
} | ||
|
||
return nil, nil | ||
return c.cachedCluster.regions.GetRegion(regionKey), nil |
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.
Need lock here.
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.
GetRegion locks inner.
Add more cluster cache test.
LGTM |
1 similar comment
LGTM |
@qiuyesuifeng @disksing