-
Notifications
You must be signed in to change notification settings - Fork 66
backend/local: add encode for retry scan region keys #531
Conversation
9920914
to
dff08f3
Compare
regionMap := make(map[uint64]*split.RegionInfo) | ||
for _, region := range regions { | ||
regionMap[region.Region.GetId()] = region | ||
} | ||
|
||
var splitKeyMap map[uint64][][]byte | ||
if len(retryKeys) > 0 { | ||
firstKeyEnc := codec.EncodeBytes([]byte{}, retryKeys[0]) | ||
lastKeyEnc := codec.EncodeBytes([]byte{}, retryKeys[len(retryKeys)-1]) | ||
if bytes.Compare(firstKeyEnc, regions[0].Region.StartKey) < 0 || !beforeEnd(lastKeyEnc, regions[len(regions)-1].Region.EndKey) { |
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 compare firstKey and regions[0]?
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.
fistKey is the smallest key, so it should be included in region[0]; and lastKey in region[-1]
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 seems that region.StartKey without encode can not compare to other encoded key directly?
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.
/run-all-tests |
Signed-off-by: glorv <glorvs@163.com>
dff08f3
to
372ad80
Compare
/run-all-tests |
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
@Little-Wallace, Thanks for your review. The bot only counts LGTMs from Reviewers and higher roles, but you're still welcome to leave your comments. See the corresponding SIG page for more information. Related SIG: migrate(slack). |
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
Signed-off-by: glorv <glorvs@163.com>
What problem does this PR solve?
Fix the bug that the retry split key is not encoded, which causes scanned regions are incorrect.
What is changed and how it works?
Check List
Tests
Side effects
Related changes
Release Note