Skip to content

Commit

Permalink
This is an automated cherry-pick of pingcap#42972
Browse files Browse the repository at this point in the history
Signed-off-by: ti-chi-bot <[email protected]>
  • Loading branch information
YuJuncen authored and ti-chi-bot committed Apr 18, 2023
1 parent 6ee75cd commit 1a0db58
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
5 changes: 5 additions & 0 deletions br/pkg/restore/split.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,6 +509,11 @@ func (b *scanRegionBackoffer) Attempt() int {
func getSplitKeys(rewriteRules *RewriteRules, ranges []rtree.Range, regions []*RegionInfo, isRawKv bool) map[uint64][][]byte {
splitKeyMap := make(map[uint64][][]byte)
checkKeys := make([][]byte, 0)
if rewriteRules != nil && len(rewriteRules.NewKeyspace) == 0 {
for _, rule := range rewriteRules.Data {
checkKeys = append(checkKeys, rule.NewKeyPrefix)
}
}
for _, rg := range ranges {
checkKeys = append(checkKeys, rg.EndKey)
}
Expand Down
14 changes: 14 additions & 0 deletions br/pkg/restore/split_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -450,11 +450,25 @@ func initRewriteRules() *restore.RewriteRules {

// expected regions after split:
//
<<<<<<< HEAD
// [, aay), [aay, bba), [bba, bbf), [bbf, bbh), [bbh, bbj),
// [bbj, cca), [cca, xxe), [xxe, xxz), [xxz, )
func validateRegions(regions map[uint64]*restore.RegionInfo) bool {
keys := [...]string{"", "aay", "bba", "bbf", "bbh", "bbj", "cca", "xxe", "xxz", ""}
if len(regions) != len(keys)-1 {
=======
// [aa, aay), [aay, bba), [bba, bbf), [bbf, bbh), [bbh, bbj),
// [bbj, cca), [cca, xx), [xx, xxe), [xxe, xxz), [xxz, )
//
// Please note that "aa" has been rewritten to "xx", so the "bb" rewrite rule split point won't be included.
func validateRegions(regions map[uint64]*split.RegionInfo) bool {
keys := [...]string{"", "aay", "bba", "bbf", "bbh", "bbj", "cca", "xx", "xxe", "xxz", ""}
return validateRegionsExt(regions, keys[:], false)
}

func validateRegionsExt(regions map[uint64]*split.RegionInfo, expectedKeys []string, isRawKv bool) bool {
if len(regions) != len(expectedKeys)-1 {
>>>>>>> 36c59c75620 (restore: split between tables (#42972))
return false
}
FindRegion:
Expand Down

0 comments on commit 1a0db58

Please sign in to comment.