Skip to content

Commit

Permalink
fix bug
Browse files Browse the repository at this point in the history
Signed-off-by: you06 <[email protected]>

fix bug

Signed-off-by: you06 <[email protected]>

remove with leader option

Signed-off-by: you06 <[email protected]>

update go.mod

Signed-off-by: you06 <[email protected]>

update client-go

Signed-off-by: you06 <[email protected]>
  • Loading branch information
you06 committed Jun 21, 2024
1 parent 4f3aba8 commit e6d5426
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 52 deletions.
8 changes: 5 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ require (
github.com/pingcap/errors v0.11.5-0.20240318064555-6bd07397691f
github.com/pingcap/failpoint v0.0.0-20240527053858-9b3b6e34194a
github.com/pingcap/fn v1.0.0
github.com/pingcap/kvproto v0.0.0-20240513094934-d9297553c900
github.com/pingcap/kvproto v0.0.0-20240620063548-118a4cab53e4
github.com/pingcap/log v1.1.1-0.20240314023424-862ccc32f18d
github.com/pingcap/sysutil v1.0.1-0.20240311050922-ae81ee01f3a5
github.com/pingcap/tidb/pkg/parser v0.0.0-20211011031125-9b13dc409c5e
Expand All @@ -107,8 +107,8 @@ require (
github.com/tdakkota/asciicheck v0.2.0
github.com/tiancaiamao/appdash v0.0.0-20181126055449-889f96f722a2
github.com/tidwall/btree v1.7.0
github.com/tikv/client-go/v2 v2.0.8-0.20240614064455-ac8fa1d73a0c
github.com/tikv/pd/client v0.0.0-20240603082825-a929a546a790
github.com/tikv/client-go/v2 v2.0.8-0.20240604045705-156cebc2defa
github.com/tikv/pd/client v0.0.0-20240620115049-049de1761e56
github.com/timakin/bodyclose v0.0.0-20240125160201-f835fa56326a
github.com/twmb/murmur3 v1.1.6
github.com/uber/jaeger-client-go v2.22.1+incompatible
Expand Down Expand Up @@ -331,3 +331,5 @@ replace (
sourcegraph.com/sourcegraph/appdash => github.com/sourcegraph/appdash v0.0.0-20190731080439-ebfcffb1b5c0
sourcegraph.com/sourcegraph/appdash-data => github.com/sourcegraph/appdash-data v0.0.0-20151005221446-73f23eafcf67
)

replace github.com/tikv/client-go/v2 => github.com/you06/client-go/v2 v2.0.0-alpha.0.20240621041621-e22eb694a690
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -690,8 +690,8 @@ github.com/pingcap/fn v1.0.0/go.mod h1:u9WZ1ZiOD1RpNhcI42RucFh/lBuzTu6rw88a+oF2Z
github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989 h1:surzm05a8C9dN8dIUmo4Be2+pMRb6f55i+UIYrluu2E=
github.com/pingcap/goleveldb v0.0.0-20191226122134-f82aafb29989/go.mod h1:O17XtbryoCJhkKGbT62+L2OlrniwqiGLSqrmdHCMzZw=
github.com/pingcap/kvproto v0.0.0-20191211054548-3c6b38ea5107/go.mod h1:WWLmULLO7l8IOcQG+t+ItJ3fEcrL5FxF0Wu+HrMy26w=
github.com/pingcap/kvproto v0.0.0-20240513094934-d9297553c900 h1:snIM8DC846ufdlRclITACXfr1kvVIPU4cuQ6w3JVVY4=
github.com/pingcap/kvproto v0.0.0-20240513094934-d9297553c900/go.mod h1:rXxWk2UnwfUhLXha1jxRWPADw9eMZGWEWCg92Tgmb/8=
github.com/pingcap/kvproto v0.0.0-20240620063548-118a4cab53e4 h1:6aIKNB2YGAec4IUDLw6G2eDECiGiufZcgEbZSCELBx0=
github.com/pingcap/kvproto v0.0.0-20240620063548-118a4cab53e4/go.mod h1:rXxWk2UnwfUhLXha1jxRWPADw9eMZGWEWCg92Tgmb/8=
github.com/pingcap/log v0.0.0-20210625125904-98ed8e2eb1c7/go.mod h1:8AanEdAHATuRurdGxZXBz0At+9avep+ub7U1AGYLIMM=
github.com/pingcap/log v1.1.0/go.mod h1:DWQW5jICDR7UJh4HtxXSM20Churx4CQL0fwL/SoOSA4=
github.com/pingcap/log v1.1.1-0.20240314023424-862ccc32f18d h1:y3EueKVfVykdpTyfUnQGqft0ud+xVFuCdp1XkVL0X1E=
Expand Down Expand Up @@ -846,10 +846,8 @@ github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a h1:J/YdBZ46WKpXsxsW
github.com/tiancaiamao/gp v0.0.0-20221230034425-4025bc8a4d4a/go.mod h1:h4xBhSNtOeEosLJ4P7JyKXX7Cabg7AVkWCK5gV2vOrM=
github.com/tidwall/btree v1.7.0 h1:L1fkJH/AuEh5zBnnBbmTwQ5Lt+bRJ5A8EWecslvo9iI=
github.com/tidwall/btree v1.7.0/go.mod h1:twD9XRA5jj9VUQGELzDO4HPQTNJsoWWfYEL+EUQ2cKY=
github.com/tikv/client-go/v2 v2.0.8-0.20240614064455-ac8fa1d73a0c h1:lmC//5VZCLMYAzCVazTnopQoififZfXqnaIZqTAXL9Q=
github.com/tikv/client-go/v2 v2.0.8-0.20240614064455-ac8fa1d73a0c/go.mod h1:GHzfy/lS+Gr9emV8OwU+k4kXCB3/8H51DZBFDTeyE84=
github.com/tikv/pd/client v0.0.0-20240603082825-a929a546a790 h1:bGmvWcMkbOlVgWpsXza2gu18Ud2dEyTz60UU2oEUSoA=
github.com/tikv/pd/client v0.0.0-20240603082825-a929a546a790/go.mod h1:kNRekhwXqjTjNHy+kPmbZvsMmvl42zOj/UW5IIG+nP0=
github.com/tikv/pd/client v0.0.0-20240620115049-049de1761e56 h1:7TLLfwrKoty9UeJMsSopRTXYw8ooxcF0Z1fegXhIgks=
github.com/tikv/pd/client v0.0.0-20240620115049-049de1761e56/go.mod h1:EHHidLItrJGh0jqfdfFhIHG5vwkR8+43tFnp7v7iv1Q=
github.com/timakin/bodyclose v0.0.0-20240125160201-f835fa56326a h1:A6uKudFIfAEpoPdaal3aSqGxBzLyU8TqyXImLwo6dIo=
github.com/timakin/bodyclose v0.0.0-20240125160201-f835fa56326a/go.mod h1:mkjARE7Yr8qU23YcGMSALbIxTQ9r9QBVahQOBRfU460=
github.com/tklauser/go-sysconf v0.3.9/go.mod h1:11DU/5sG7UexIrp/O6g35hrWzu0JxlwQ3LSFUzyeuhs=
Expand Down Expand Up @@ -882,6 +880,8 @@ github.com/xitongsys/parquet-go-source v0.0.0-20190524061010-2b72cbee77d5/go.mod
github.com/xitongsys/parquet-go-source v0.0.0-20200817004010-026bad9b25d0 h1:a742S4V5A15F93smuVxA60LQWsrCnN8bKeWDBARU1/k=
github.com/xitongsys/parquet-go-source v0.0.0-20200817004010-026bad9b25d0/go.mod h1:HYhIKsdns7xz80OgkbgJYrtQY7FjHWHKH6cvN7+czGE=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
github.com/you06/client-go/v2 v2.0.0-alpha.0.20240621041621-e22eb694a690 h1:tHZZLMciMRAE4L73I8AK2z1qfPHqUeiOAZB2zk1IufE=
github.com/you06/client-go/v2 v2.0.0-alpha.0.20240621041621-e22eb694a690/go.mod h1:bL62tcWNTYzbXdYKdkkjzK4aKdOxW4jgQu5rCRKYWbY=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down
6 changes: 3 additions & 3 deletions pkg/store/copr/batch_coprocessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ func buildBatchCopTasksConsistentHash(

for i, ranges := range rangesForEachPhysicalTable {
rangesLen += ranges.Len()
locations, err := cache.SplitKeyRangesByLocationsWithoutBuckets(bo, ranges, UnspecifiedLimit)
locations, err := cache.SplitKeyRangesByLocations(bo, ranges, UnspecifiedLimit, true, false)
if err != nil {
return nil, errors.Trace(err)
}
Expand Down Expand Up @@ -932,7 +932,7 @@ func buildBatchCopTasksCore(bo *backoff.Backoffer, store *kvStore, rangesForEach
rangesLen = 0
for i, ranges := range rangesForEachPhysicalTable {
rangesLen += ranges.Len()
locations, err := cache.SplitKeyRangesByLocationsWithoutBuckets(bo, ranges, UnspecifiedLimit)
locations, err := cache.SplitKeyRangesByLocations(bo, ranges, UnspecifiedLimit, true, false)
if err != nil {
return nil, errors.Trace(err)
}
Expand Down Expand Up @@ -1483,7 +1483,7 @@ func buildBatchCopTasksConsistentHashForPD(bo *backoff.Backoffer,
splitKeyStart := time.Now()
for i, ranges := range rangesForEachPhysicalTable {
rangesLen += ranges.Len()
locations, err := cache.SplitKeyRangesByLocationsWithoutBuckets(bo, ranges, UnspecifiedLimit)
locations, err := cache.SplitKeyRangesByLocations(bo, ranges, UnspecifiedLimit, true, false)
if err != nil {
return nil, errors.Trace(err)
}
Expand Down
20 changes: 10 additions & 10 deletions pkg/store/copr/coprocessor_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -381,66 +381,66 @@ func TestSplitKeyRangesByLocationsWithoutBuckets(t *testing.T) {

bo := backoff.NewBackofferWithVars(context.Background(), 3000, nil)

locRanges, err := cache.SplitKeyRangesByLocationsWithoutBuckets(bo, NewKeyRanges(BuildKeyRanges("a", "c")), UnspecifiedLimit)
locRanges, err := cache.SplitKeyRangesByLocations(bo, NewKeyRanges(BuildKeyRanges("a", "c")), UnspecifiedLimit, false, false)
require.NoError(t, err)
require.Len(t, locRanges, 1)
rangeEqual(t, locRanges[0].Ranges.ToRanges(), "a", "c")

locRanges, err = cache.SplitKeyRangesByLocationsWithoutBuckets(bo, NewKeyRanges(BuildKeyRanges("a", "c")), 0)
locRanges, err = cache.SplitKeyRangesByLocations(bo, NewKeyRanges(BuildKeyRanges("a", "c")), 0, false, false)
require.NoError(t, err)
require.Len(t, locRanges, 0)

locRanges, err = cache.SplitKeyRangesByLocationsWithoutBuckets(bo, NewKeyRanges(BuildKeyRanges("h", "y")), UnspecifiedLimit)
locRanges, err = cache.SplitKeyRangesByLocations(bo, NewKeyRanges(BuildKeyRanges("h", "y")), UnspecifiedLimit, false, false)
require.NoError(t, err)
require.Len(t, locRanges, 3)
rangeEqual(t, locRanges[0].Ranges.ToRanges(), "h", "n")
rangeEqual(t, locRanges[1].Ranges.ToRanges(), "n", "t")
rangeEqual(t, locRanges[2].Ranges.ToRanges(), "t", "y")

locRanges, err = cache.SplitKeyRangesByLocationsWithoutBuckets(bo, NewKeyRanges(BuildKeyRanges("h", "n")), UnspecifiedLimit)
locRanges, err = cache.SplitKeyRangesByLocations(bo, NewKeyRanges(BuildKeyRanges("h", "n")), UnspecifiedLimit, false, false)
require.NoError(t, err)
require.Len(t, locRanges, 1)
rangeEqual(t, locRanges[0].Ranges.ToRanges(), "h", "n")

locRanges, err = cache.SplitKeyRangesByLocationsWithoutBuckets(bo, NewKeyRanges(BuildKeyRanges("s", "s")), UnspecifiedLimit)
locRanges, err = cache.SplitKeyRangesByLocations(bo, NewKeyRanges(BuildKeyRanges("s", "s")), UnspecifiedLimit, false, false)
require.NoError(t, err)
require.Len(t, locRanges, 1)
rangeEqual(t, locRanges[0].Ranges.ToRanges(), "s", "s")

// min --> max
locRanges, err = cache.SplitKeyRangesByLocationsWithoutBuckets(bo, NewKeyRanges(BuildKeyRanges("a", "z")), UnspecifiedLimit)
locRanges, err = cache.SplitKeyRangesByLocations(bo, NewKeyRanges(BuildKeyRanges("a", "z")), UnspecifiedLimit, false, false)
require.NoError(t, err)
require.Len(t, locRanges, 4)
rangeEqual(t, locRanges[0].Ranges.ToRanges(), "a", "g")
rangeEqual(t, locRanges[1].Ranges.ToRanges(), "g", "n")
rangeEqual(t, locRanges[2].Ranges.ToRanges(), "n", "t")
rangeEqual(t, locRanges[3].Ranges.ToRanges(), "t", "z")

locRanges, err = cache.SplitKeyRangesByLocationsWithoutBuckets(bo, NewKeyRanges(BuildKeyRanges("a", "z")), 3)
locRanges, err = cache.SplitKeyRangesByLocations(bo, NewKeyRanges(BuildKeyRanges("a", "z")), 3, false, false)
require.NoError(t, err)
require.Len(t, locRanges, 3)
rangeEqual(t, locRanges[0].Ranges.ToRanges(), "a", "g")
rangeEqual(t, locRanges[1].Ranges.ToRanges(), "g", "n")
rangeEqual(t, locRanges[2].Ranges.ToRanges(), "n", "t")

// many range
locRanges, err = cache.SplitKeyRangesByLocationsWithoutBuckets(bo, NewKeyRanges(BuildKeyRanges("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z")), UnspecifiedLimit)
locRanges, err = cache.SplitKeyRangesByLocations(bo, NewKeyRanges(BuildKeyRanges("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z")), UnspecifiedLimit, false, false)
require.NoError(t, err)
require.Len(t, locRanges, 4)
rangeEqual(t, locRanges[0].Ranges.ToRanges(), "a", "b", "c", "d", "e", "f", "f", "g")
rangeEqual(t, locRanges[1].Ranges.ToRanges(), "g", "h", "i", "j", "k", "l", "m", "n")
rangeEqual(t, locRanges[2].Ranges.ToRanges(), "o", "p", "q", "r", "s", "t")
rangeEqual(t, locRanges[3].Ranges.ToRanges(), "u", "v", "w", "x", "y", "z")

locRanges, err = cache.SplitKeyRangesByLocationsWithoutBuckets(bo, NewKeyRanges(BuildKeyRanges("a", "b", "b", "h", "h", "m", "n", "t", "v", "w")), UnspecifiedLimit)
locRanges, err = cache.SplitKeyRangesByLocations(bo, NewKeyRanges(BuildKeyRanges("a", "b", "b", "h", "h", "m", "n", "t", "v", "w")), UnspecifiedLimit, false, false)
require.NoError(t, err)
require.Len(t, locRanges, 4)
rangeEqual(t, locRanges[0].Ranges.ToRanges(), "a", "b", "b", "g")
rangeEqual(t, locRanges[1].Ranges.ToRanges(), "g", "h", "h", "m", "n")
rangeEqual(t, locRanges[2].Ranges.ToRanges(), "n", "t")
rangeEqual(t, locRanges[3].Ranges.ToRanges(), "v", "w")

locRanges, err = cache.SplitKeyRangesByLocationsWithoutBuckets(bo, NewKeyRanges(BuildKeyRanges("a", "b", "v", "w")), UnspecifiedLimit)
locRanges, err = cache.SplitKeyRangesByLocations(bo, NewKeyRanges(BuildKeyRanges("a", "b", "v", "w")), UnspecifiedLimit, false, false)
require.NoError(t, err)
require.Len(t, locRanges, 2)
rangeEqual(t, locRanges[0].Ranges.ToRanges(), "a", "b")
Expand Down
50 changes: 20 additions & 30 deletions pkg/store/copr/region_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func NewRegionCache(rc *tikv.RegionCache) *RegionCache {
func (c *RegionCache) SplitRegionRanges(bo *Backoffer, keyRanges []kv.KeyRange, limit int) ([]kv.KeyRange, error) {
ranges := NewKeyRanges(keyRanges)

locations, err := c.SplitKeyRangesByLocationsWithoutBuckets(bo, ranges, limit)
locations, err := c.SplitKeyRangesByLocations(bo, ranges, limit, true, false)
if err != nil {
return nil, derr.ToTiDBErr(err)
}
Expand Down Expand Up @@ -166,38 +166,28 @@ func (c *RegionCache) splitKeyRangesByLocation(loc *tikv.KeyLocation, ranges *Ke
// UnspecifiedLimit means no limit.
const UnspecifiedLimit = -1

// SplitKeyRangesByLocationsWithBuckets splits the KeyRanges by logical info in the cache.
// The buckets in the returned LocationKeyRanges are not empty if the region is split by bucket.
func (c *RegionCache) SplitKeyRangesByLocationsWithBuckets(bo *Backoffer, ranges *KeyRanges, limit int) ([]*LocationKeyRanges, error) {
res := make([]*LocationKeyRanges, 0)
for ranges.Len() > 0 {
if limit != UnspecifiedLimit && len(res) >= limit {
break
}
loc, err := c.LocateKey(bo.TiKVBackoffer(), ranges.At(0).StartKey)
if err != nil {
return res, derr.ToTiDBErr(err)
}

isBreak := false
res, ranges, isBreak = c.splitKeyRangesByLocation(loc, ranges, res)
if isBreak {
break
}
}

return res, nil
}

// SplitKeyRangesByLocationsWithoutBuckets splits the KeyRanges by logical info in the cache.
// SplitKeyRangesByLocations splits the KeyRanges by logical info in the cache.
// The buckets in the returned LocationKeyRanges are empty, regardless of whether the region is split by bucket.
func (c *RegionCache) SplitKeyRangesByLocationsWithoutBuckets(bo *Backoffer, ranges *KeyRanges, limit int) ([]*LocationKeyRanges, error) {
func (c *RegionCache) SplitKeyRangesByLocations(bo *Backoffer, ranges *KeyRanges, limit int, needLeader, buckets bool) ([]*LocationKeyRanges, error) {
if limit == 0 || ranges.Len() <= 0 {
return nil, nil
}
// Currently, LocationKeyRanges returned by `LocateKeyRange` doesn't contains buckets,
// because of https://github.com/tikv/client-go/blob/09ecb550d383c1b048119b586fb5cda658312262/internal/locate/region_cache.go#L1550-L1551.
locs, err := c.LocateKeyRange(bo.TiKVBackoffer(), ranges.RefAt(0).StartKey, ranges.RefAt(ranges.Len()-1).EndKey)

kvRanges := make([]tikv.KeyRange, 0, ranges.Len())
for i := 0; i < ranges.Len(); i++ {
kvRanges = append(kvRanges, tikv.KeyRange{
StartKey: ranges.At(i).StartKey,
EndKey: ranges.At(i).EndKey,
})
}
opts := make([]tikv.BatchLocateKeyRangesOpt, 0, 2)
if needLeader {
opts = append(opts, tikv.WithNeedLeader())
}
if buckets {
opts = append(opts, tikv.WithNeedBuckets())
}
locs, err := c.BatchLocateKeyRanges(bo.TiKVBackoffer(), kvRanges, opts...)
if err != nil {
return nil, derr.ToTiDBErr(err)
}
Expand Down Expand Up @@ -241,7 +231,7 @@ func (c *RegionCache) SplitKeyRangesByLocationsWithoutBuckets(bo *Backoffer, ran
//
// TODO(youjiali1995): Try to do it in one round and reduce allocations if bucket is not enabled.
func (c *RegionCache) SplitKeyRangesByBuckets(bo *Backoffer, ranges *KeyRanges) ([]*LocationKeyRanges, error) {
locs, err := c.SplitKeyRangesByLocationsWithBuckets(bo, ranges, UnspecifiedLimit)
locs, err := c.SplitKeyRangesByLocations(bo, ranges, UnspecifiedLimit, false, true)
if err != nil {
return nil, derr.ToTiDBErr(err)
}
Expand Down
29 changes: 29 additions & 0 deletions pkg/store/mockstore/unistore/tikv/mock_region.go
Original file line number Diff line number Diff line change
Expand Up @@ -911,6 +911,35 @@ func (pd *MockPD) ScanRegions(ctx context.Context, startKey []byte, endKey []byt
return regions, nil
}

func (pd *MockPD) BatchScanRegions(ctx context.Context, keyRanges []pdclient.KeyRange, limit int, opts ...pdclient.GetRegionOption) ([]*pdclient.Region, error) {
regions := make([]*pdclient.Region, 0, len(keyRanges))
var lastRegion *pdclient.Region
for _, keyRange := range keyRanges {
if lastRegion != nil && lastRegion.Meta != nil {
endKey := lastRegion.Meta.EndKey
if len(endKey) == 0 {
return regions, nil
}
if bytes.Compare(keyRange.StartKey, lastRegion.Meta.EndKey) >= 0 {
continue
} else if bytes.Compare(keyRange.StartKey, lastRegion.Meta.StartKey) > 0 {
keyRange.StartKey = endKey
}
}
rangeRegions := pd.rm.ScanRegions(keyRange.StartKey, keyRange.EndKey, limit, opts...)
if len(rangeRegions) == 0 {
continue
}
lastRegion = rangeRegions[len(rangeRegions)-1]
regions = append(regions, rangeRegions...)
limit -= len(rangeRegions)
if limit <= 0 {
break
}
}
return regions, nil
}

// ScatterRegion scatters the specified region. Should use it for a batch of regions,
// and the distribution of these regions will be dispersed.
// NOTICE: This method is the old version of ScatterRegions, you should use the later one as your first choice.
Expand Down

0 comments on commit e6d5426

Please sign in to comment.