-
Notifications
You must be signed in to change notification settings - Fork 728
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
server, core: implement the query region gRPC server #8979
Conversation
d272713
to
16341ff
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #8979 +/- ##
==========================================
- Coverage 76.28% 76.25% -0.04%
==========================================
Files 465 465
Lines 70512 70659 +147
==========================================
+ Hits 53792 53880 +88
- Misses 13372 13428 +56
- Partials 3348 3351 +3
Flags with carried forward coverage won't be shown. Click here to find out more. |
regions := r.getRegionsByKeys(keys) | ||
// Assert the returned regions count matches the input keys. | ||
if len(regions) != len(keys) { | ||
panic("returned regions count mismatch with the input keys") |
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.
Shall we return an error instead of panic?
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.
My idea is to set such panics at the initial stage of implementing this feature to help with testing. Once the feature needs to be released, I will change them to regular errors.
@@ -1464,6 +1464,97 @@ func (r *RegionsInfo) GetStoreRegions(storeID uint64) []*RegionInfo { | |||
return regions | |||
} | |||
|
|||
// TODO: benchmark the performance of `QueryRegions`. | |||
// QueryRegions searches RegionInfo from regionTree by keys and IDs in batch. | |||
func (r *RegionsInfo) QueryRegions( |
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.
Will we pass both keys and prevKeys at the same time?
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.
Yes, if the GetRegion
and GetPrevRegion
are batched in the same request.
server/grpc_service.go
Outdated
|
||
// TODO: add forwarding logic. | ||
|
||
if s.IsClosed() { |
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.
Do we need to check if cluster is started?
regionsByID[id] = regionResp | ||
} | ||
} | ||
return keyIDMap, prevKeyIDMap, regionsByID |
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 are those maps used for?
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 helps the client map the keys passed in with their corresponding region IDs.
pkg/core/region.go
Outdated
func (r *RegionsInfo) getRegionsByKeys(keys [][]byte) []*RegionInfo { | ||
r.t.RLock() | ||
defer r.t.RUnlock() | ||
return r.tree.searchByKeys(keys) |
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.
I wonder if having too many keys will affect the lock's performance. we could implement it by dividing it into multiple batch search methods.
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.
Batch parallel search is an optimization within the plan, and I want to implement it after completing an MVP.
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 need to prevent the behavior of holding the lock for too long.
1118cec
to
0f00072
Compare
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.
lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: nolouch, rleungx The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
/hold |
Signed-off-by: JmPotato <[email protected]>
Signed-off-by: JmPotato <[email protected]>
4ed9deb
to
f50d09d
Compare
/unhold |
Signed-off-by: JmPotato <[email protected]>
f50d09d
to
54b9646
Compare
/test pull-integration-realcluster-test |
1 similar comment
/test pull-integration-realcluster-test |
What problem does this PR solve?
Issue Number: ref #8690.
What is changed and how does it work?
Check List
Tests
Release note