diff --git a/DEPS.bzl b/DEPS.bzl index 07ea206f39306..ff6f339cb0c0c 100644 --- a/DEPS.bzl +++ b/DEPS.bzl @@ -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", diff --git a/Makefile b/Makefile index c670d81f0b2f5..a10eaef06b208 100644 --- a/Makefile +++ b/Makefile @@ -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)" diff --git a/go.mod b/go.mod index e87eccf1c379d..bd2953a3d9019 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index cc711c4c3b5f2..d586c031e94e9 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/sessiontxn/isolation/readcommitted_test.go b/sessiontxn/isolation/readcommitted_test.go index beec71685058c..2315546e89549 100644 --- a/sessiontxn/isolation/readcommitted_test.go +++ b/sessiontxn/isolation/readcommitted_test.go @@ -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) diff --git a/store/copr/coprocessor.go b/store/copr/coprocessor.go index 392e31c559cd4..6714e6e622093 100644 --- a/store/copr/coprocessor.go +++ b/store/copr/coprocessor.go @@ -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())) diff --git a/table/tables/partition.go b/table/tables/partition.go index 9f84333213a82..d2f8787ebdc03 100644 --- a/table/tables/partition.go +++ b/table/tables/partition.go @@ -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. @@ -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 { @@ -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