Skip to content

Commit

Permalink
Merge branch 'master' into fix-36243
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkingrei authored Jul 15, 2022
2 parents 46ae8b4 + ea306fc commit d788629
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 24 deletions.
4 changes: 2 additions & 2 deletions DEPS.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -1298,8 +1298,8 @@ def go_deps():
name = "com_github_google_btree",
build_file_proto_mode = "disable_global",
importpath = "github.com/google/btree",
sum = "h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4=",
version = "v1.0.1",
sum = "h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU=",
version = "v1.1.2",
)
go_repository(
name = "com_github_google_go_cmp",
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ dev: checklist check explaintest gogenerate br_unit_test test_part_parser_dev ut
# Install the check tools.
check-setup:tools/bin/revive tools/bin/goword

check: fmt check-parallel unconvert lint tidy testSuite check-static vet errdoc
check: fmt check-parallel lint tidy testSuite check-static vet errdoc

fmt:
@echo "gofmt (simplify)"
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ require (
github.com/golang/mock v1.6.0
github.com/golang/protobuf v1.5.2
github.com/golang/snappy v0.0.4
github.com/google/btree v1.0.1
github.com/google/btree v1.1.2
github.com/google/pprof v0.0.0-20211122183932-1daafda22083
github.com/google/uuid v1.1.2
github.com/gorilla/mux v1.8.0
Expand Down
3 changes: 2 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -362,8 +362,9 @@ github.com/golangci/unconvert v0.0.0-20180507085042-28b1c447d1f4/go.mod h1:Izgrg
github.com/gomodule/redigo v1.7.1-0.20190724094224-574c33c3df38/go.mod h1:B4C85qUVwatsJoIUNIfCRsp7qO0iAmpGFZ4EELWSbC4=
github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ=
github.com/google/btree v1.0.1 h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4=
github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9uaxA=
github.com/google/btree v1.1.2 h1:xf4v41cLI2Z6FxbKm+8Bu+m8ifhj15JuZ9sa0jZCMUU=
github.com/google/btree v1.1.2/go.mod h1:qOPhT0dTNdNzV6Z/lhRX0YXUafgPLFUh+gZMl761Gm4=
github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M=
github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU=
Expand Down
2 changes: 2 additions & 0 deletions sessiontxn/isolation/readcommitted_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,8 @@ func TestPessimisticRCTxnContextProviderRCCheckForPrepareExecute(t *testing.T) {
require.NoError(t, err)
_, err = session.ResultSetToStringSlice(ctx, tk.Session(), rs)
require.Error(t, err)
rs.Close()

ts, err = provider.GetStmtForUpdateTS()
require.NoError(t, err)
require.Greater(t, compareTS, ts)
Expand Down
16 changes: 1 addition & 15 deletions store/copr/coprocessor.go
Original file line number Diff line number Diff line change
Expand Up @@ -123,21 +123,7 @@ func (c *CopClient) Send(ctx context.Context, req *kv.Request, variables interfa
it.sendRate = util.NewRateLimit(2 * it.concurrency)
it.respChan = nil
} else {
capacity := it.concurrency
if enabledRateLimitAction {
// The count of cached response in memory is controlled by the capacity of the it.sendRate, not capacity of the respChan.
// As the worker will send finCopResponse after each task being handled, we make the capacity of the respCh equals to
// 2*it.concurrency to avoid deadlock in the unit test caused by the `MustExec` or `Exec`
capacity = it.concurrency * 2
}
// in paging request, a request will be returned in multi batches,
// enlarge the channel size to avoid the request blocked by buffer full.
if req.Paging {
if capacity < 2048 {
capacity = 2048
}
}
it.respChan = make(chan *copResponse, capacity)
it.respChan = make(chan *copResponse)
it.sendRate = util.NewRateLimit(it.concurrency)
}
it.actionOnExceed = newRateLimitAction(uint(it.sendRate.GetCapacity()))
Expand Down
12 changes: 8 additions & 4 deletions table/tables/partition.go
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,16 @@ func (item *btreeListColumnItem) Less(other btree.Item) bool {
return item.key < other.(*btreeListColumnItem).key
}

func lessBtreeListColumnItem(a, b *btreeListColumnItem) bool {
return a.key < b.key
}

// ForListColumnPruning is used for list columns partition pruning.
type ForListColumnPruning struct {
ExprCol *expression.Column
valueTp *types.FieldType
valueMap map[string]ListPartitionLocation
sorted *btree.BTree
sorted *btree.BTreeG[*btreeListColumnItem]

// To deal with the location partition failure caused by inconsistent NewCollationEnabled values(see issue #32416).
// The following fields are used to delay building valueMap.
Expand Down Expand Up @@ -677,7 +681,7 @@ func (lp *ForListPruning) buildListColumnsPruner(ctx sessionctx.Context, tblInfo
ExprCol: columns[idx],
valueTp: &colInfo.FieldType,
valueMap: make(map[string]ListPartitionLocation),
sorted: btree.New(btreeDegree),
sorted: btree.NewG[*btreeListColumnItem](btreeDegree, lessBtreeListColumnItem),
}
err := colPrune.buildPartitionValueMapAndSorted(p)
if err != nil {
Expand Down Expand Up @@ -891,8 +895,8 @@ func (lp *ForListColumnPruning) LocateRanges(sc *stmtctx.StatementContext, r *ra
}

locations := make([]ListPartitionLocation, 0, lp.sorted.Len())
lp.sorted.AscendRange(newBtreeListColumnSearchItem(string(hack.String(lowKey))), newBtreeListColumnSearchItem(string(hack.String(highKey))), func(item btree.Item) bool {
locations = append(locations, item.(*btreeListColumnItem).location)
lp.sorted.AscendRange(newBtreeListColumnSearchItem(string(hack.String(lowKey))), newBtreeListColumnSearchItem(string(hack.String(highKey))), func(item *btreeListColumnItem) bool {
locations = append(locations, item.location)
return true
})
return locations, nil
Expand Down

0 comments on commit d788629

Please sign in to comment.