Skip to content

Commit 26dfc0a

Browse files
committed
Merge remote-tracking branch 'upstream/release-7.1' into cherry-pick-53716-to-release-7.1
Signed-off-by: Yang Keao <[email protected]>
2 parents 001f0f1 + 4fec22b commit 26dfc0a

File tree

266 files changed

+4106
-1209
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

266 files changed

+4106
-1209
lines changed

DEPS.bzl

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -313,8 +313,8 @@ def go_deps():
313313
name = "com_github_bazelbuild_buildtools",
314314
build_file_proto_mode = "disable",
315315
importpath = "github.com/bazelbuild/buildtools",
316-
sum = "h1:XmPu4mXICgdGnC5dXGjUGbwUD/kUmS0l5Aop3LaevBM=",
317-
version = "v0.0.0-20230317132445-9c3c1fc0106e",
316+
sum = "h1:4k69c5E7Sa7jmNtv9itBHYA4Z5pfurInuRrtgohxZeA=",
317+
version = "v0.0.0-20230926111657-7d855c59baeb",
318318
)
319319

320320
go_repository(
@@ -4179,8 +4179,8 @@ def go_deps():
41794179
name = "com_github_tikv_client_go_v2",
41804180
build_file_proto_mode = "disable_global",
41814181
importpath = "github.com/tikv/client-go/v2",
4182-
sum = "h1:NRAYutV0XCtLXVb414GXAShPmrfOQucbGgDHHuucTww=",
4183-
version = "v2.0.8-0.20240510070118-c6d7a483b5e1",
4182+
sum = "h1:UhvIdNeglgwlsTuzDHwo/MBYtI6r/6IDT+B/KyENSLY=",
4183+
version = "v2.0.8-0.20240710074042-ce640b992b7c",
41844184
)
41854185
go_repository(
41864186
name = "com_github_tikv_pd",
@@ -4194,8 +4194,8 @@ def go_deps():
41944194
name = "com_github_tikv_pd_client",
41954195
build_file_proto_mode = "disable_global",
41964196
importpath = "github.com/tikv/pd/client",
4197-
sum = "h1:BBwUZAaBl7DKdyaduOxXqias4xCtdDgIAGsDBuri3lg=",
4198-
version = "v0.0.0-20231211083919-fe6fd1721aa6",
4197+
sum = "h1:Szw9YxqGGEneSniBd4ep09jgB77cKUy+AuhKOmdGPdE=",
4198+
version = "v0.0.0-20240725070735-fb162bf0aa3f",
41994199
)
42004200
go_repository(
42014201
name = "com_github_timakin_bodyclose",
@@ -5984,15 +5984,15 @@ def go_deps():
59845984
name = "org_golang_x_crypto",
59855985
build_file_proto_mode = "disable_global",
59865986
importpath = "golang.org/x/crypto",
5987-
sum = "h1:wBqGXzWJW6m1XrIKlAH0Hs1JJ7+9KBwnIO8v66Q9cHc=",
5988-
version = "v0.14.0",
5987+
sum = "h1:frVn1TEaCEaZcn3Tmd7Y2b5KKPaZ+I32Q2OA3kYp5TA=",
5988+
version = "v0.15.0",
59895989
)
59905990
go_repository(
59915991
name = "org_golang_x_exp",
59925992
build_file_proto_mode = "disable_global",
59935993
importpath = "golang.org/x/exp",
5994-
sum = "h1:SkwG94eNiiYJhbeDE018Grw09HIN/KB9NlRmZsrzfWs=",
5995-
version = "v0.0.0-20221023144134-a1e5550cf13e",
5994+
sum = "h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI=",
5995+
version = "v0.0.0-20231006140011-7918f672742d",
59965996
)
59975997
go_repository(
59985998
name = "org_golang_x_exp_typeparams",
@@ -6027,15 +6027,15 @@ def go_deps():
60276027
name = "org_golang_x_mod",
60286028
build_file_proto_mode = "disable_global",
60296029
importpath = "golang.org/x/mod",
6030-
sum = "h1:lFO9qtOdlre5W1jxS3r/4szv2/6iXxScdzjoBMXNhYk=",
6031-
version = "v0.10.0",
6030+
sum = "h1:dGoOF9QVLYng8IHTm7BAyWqCqSheQ5pYWGhzW00YJr0=",
6031+
version = "v0.14.0",
60326032
)
60336033
go_repository(
60346034
name = "org_golang_x_net",
60356035
build_file_proto_mode = "disable_global",
60366036
importpath = "golang.org/x/net",
6037-
sum = "h1:pVaXccu2ozPjCXewfr1S7xza/zcXTity9cCdXQYSjIM=",
6038-
version = "v0.17.0",
6037+
sum = "h1:mIYleuAkSbHh0tCv7RvjL3F6ZVbLjq4+R7zbOn3Kokg=",
6038+
version = "v0.18.0",
60396039
)
60406040
go_repository(
60416041
name = "org_golang_x_oauth2",
@@ -6048,29 +6048,29 @@ def go_deps():
60486048
name = "org_golang_x_sync",
60496049
build_file_proto_mode = "disable_global",
60506050
importpath = "golang.org/x/sync",
6051-
sum = "h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI=",
6052-
version = "v0.2.0",
6051+
sum = "h1:60k92dhOjHxJkrqnwsfl8KuaHbn/5dl0lUPUklKo3qE=",
6052+
version = "v0.5.0",
60536053
)
60546054
go_repository(
60556055
name = "org_golang_x_sys",
60566056
build_file_proto_mode = "disable_global",
60576057
importpath = "golang.org/x/sys",
6058-
sum = "h1:Af8nKPmuFypiUBjVoU9V20FiaFXOcuZI21p0ycVYYGE=",
6059-
version = "v0.13.0",
6058+
sum = "h1:Vz7Qs629MkJkGyHxUlRHizWJRG2j8fbQKjELVSNhy7Q=",
6059+
version = "v0.14.0",
60606060
)
60616061
go_repository(
60626062
name = "org_golang_x_term",
60636063
build_file_proto_mode = "disable_global",
60646064
importpath = "golang.org/x/term",
6065-
sum = "h1:bb+I9cTfFazGW51MZqBVmZy7+JEJMouUHTUSKVQLBek=",
6066-
version = "v0.13.0",
6065+
sum = "h1:LGK9IlZ8T9jvdy6cTdfKUCltatMFOehAQo9SRC46UQ8=",
6066+
version = "v0.14.0",
60676067
)
60686068
go_repository(
60696069
name = "org_golang_x_text",
60706070
build_file_proto_mode = "disable_global",
60716071
importpath = "golang.org/x/text",
6072-
sum = "h1:ablQoSUd0tRdKxZewP80B+BaqeKJuVhuRxj/dkrun3k=",
6073-
version = "v0.13.0",
6072+
sum = "h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ=",
6073+
version = "v0.14.0",
60746074
)
60756075
go_repository(
60766076
name = "org_golang_x_time",
@@ -6083,8 +6083,8 @@ def go_deps():
60836083
name = "org_golang_x_tools",
60846084
build_file_proto_mode = "disable_global",
60856085
importpath = "golang.org/x/tools",
6086-
sum = "h1:8WMNJAz3zrtPmnYC7ISf5dEn3MT0gY7jBJfw27yrrLo=",
6087-
version = "v0.9.1",
6086+
sum = "h1:zdAyfUGbYmuVokhzVmghFl2ZJh5QhcfebBgmVPFYA+8=",
6087+
version = "v0.15.0",
60886088
)
60896089
go_repository(
60906090
name = "org_golang_x_xerrors",
@@ -6195,8 +6195,8 @@ def go_deps():
61956195
name = "org_uber_go_automaxprocs",
61966196
build_file_proto_mode = "disable_global",
61976197
importpath = "go.uber.org/automaxprocs",
6198-
sum = "h1:CpDZl6aOlLhReez+8S3eEotD7Jx0Os++lemPlMULQP0=",
6199-
version = "v1.4.0",
6198+
sum = "h1:kWazyxZUrS3Gs4qUpbwo5kEIMGe/DAvi5Z4tl2NW4j8=",
6199+
version = "v1.5.3",
62006200
)
62016201
go_repository(
62026202
name = "org_uber_go_dig",
@@ -6255,3 +6255,6 @@ def go_deps():
62556255
sum = "h1:4AuOwCGf4lLR9u3YOe2awrHygurzhO/HeQ6laiA6Sx0=",
62566256
version = "v3.0.3",
62576257
)
6258+
6259+
def go_dependencies():
6260+
pass

OWNERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ approvers:
4040
- guo-shaoge
4141
- hanfei1991
4242
- hawkingrei
43-
- hi-rustin
4443
- hicqu
4544
- holys
4645
- IANTHEREAL
@@ -74,6 +73,7 @@ approvers:
7473
- qw4990
7574
- rebelice
7675
- Reminiscent
76+
- Rustin170506
7777
- sdojjy
7878
- shenli
7979
- siddontang

WORKSPACE

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,33 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
22

33
http_archive(
44
name = "io_bazel_rules_go",
5-
sha256 = "6b65cb7917b4d1709f9410ffe00ecf3e160edf674b78c54a894471320862184f",
5+
sha256 = "d6ab6b57e48c09523e93050f13698f708428cfd5e619252e369d377af6597707",
66
urls = [
7-
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.39.0/rules_go-v0.39.0.zip",
8-
"https://github.com/bazelbuild/rules_go/releases/download/v0.39.0/rules_go-v0.39.0.zip",
9-
"https://ats.apps.svc/bazelbuild/rules_go/releases/download/v0.39.0/rules_go-v0.39.0.zip",
7+
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.43.0/rules_go-v0.43.0.zip",
8+
"https://github.com/bazelbuild/rules_go/releases/download/v0.43.0/rules_go-v0.43.0.zip",
9+
"https://ats.apps.svc/bazelbuild/rules_go/releases/download/v0.43.0/rules_go-v0.43.0.zip",
1010
],
1111
)
1212

1313
http_archive(
1414
name = "bazel_gazelle",
15-
sha256 = "727f3e4edd96ea20c29e8c2ca9e8d2af724d8c7778e7923a854b2c80952bc405",
15+
sha256 = "d3fa66a39028e97d76f9e2db8f1b0c11c099e8e01bf363a923074784e451f809",
1616
urls = [
17-
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.30.0/bazel-gazelle-v0.30.0.tar.gz",
18-
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.30.0/bazel-gazelle-v0.30.0.tar.gz",
19-
"http://ats.apps.svc/bazelbuild/bazel-gazelle/releases/download/v0.30.0/bazel-gazelle-v0.30.0.tar.gz",
17+
"http://bazel-cache.pingcap.net:8080/bazelbuild/bazel-gazelle/releases/download/v0.33.0/bazel-gazelle-v0.33.0.tar.gz",
18+
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.33.0/bazel-gazelle-v0.33.0.tar.gz",
19+
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.33.0/bazel-gazelle-v0.33.0.tar.gz",
20+
"http://ats.apps.svc/bazelbuild/bazel-gazelle/releases/download/v0.33.0/bazel-gazelle-v0.33.0.tar.gz",
2021
],
2122
)
2223

2324
http_archive(
2425
name = "rules_cc",
26+
sha256 = "3d9e271e2876ba42e114c9b9bc51454e379cbf0ec9ef9d40e2ae4cec61a31b40",
27+
strip_prefix = "rules_cc-0.0.6",
2528
urls = [
2629
"https://github.com/bazelbuild/rules_cc/releases/download/0.0.6/rules_cc-0.0.6.tar.gz",
2730
"http://ats.apps.svc/bazelbuild/rules_cc/releases/download/0.0.6/rules_cc-0.0.6.tar.gz",
2831
],
29-
sha256 = "3d9e271e2876ba42e114c9b9bc51454e379cbf0ec9ef9d40e2ae4cec61a31b40",
30-
strip_prefix = "rules_cc-0.0.6",
3132
)
3233

3334
load("@io_bazel_rules_go//go:deps.bzl", "go_download_sdk", "go_register_toolchains", "go_rules_dependencies")
@@ -75,18 +76,18 @@ http_archive(
7576
name = "remote_java_tools",
7677
sha256 = "5cd59ea6bf938a1efc1e11ea562d37b39c82f76781211b7cd941a2346ea8484d",
7778
urls = [
78-
"http://ats.apps.svc/bazel_java_tools/releases/java/v11.9/java_tools-v11.9.zip",
79-
"https://mirror.bazel.build/bazel_java_tools/releases/java/v11.9/java_tools-v11.9.zip",
80-
"https://github.com/bazelbuild/java_tools/releases/download/java_v11.9/java_tools-v11.9.zip",
79+
"http://ats.apps.svc/bazel_java_tools/releases/java/v11.9/java_tools-v11.9.zip",
80+
"https://mirror.bazel.build/bazel_java_tools/releases/java/v11.9/java_tools-v11.9.zip",
81+
"https://github.com/bazelbuild/java_tools/releases/download/java_v11.9/java_tools-v11.9.zip",
8182
],
8283
)
8384

8485
http_archive(
8586
name = "remote_java_tools_linux",
8687
sha256 = "512582cac5b7ea7974a77b0da4581b21f546c9478f206eedf54687eeac035989",
8788
urls = [
88-
"http://ats.apps.svc/bazel_java_tools/releases/java/v11.9/java_tools_linux-v11.9.zip",
89-
"https://mirror.bazel.build/bazel_java_tools/releases/java/v11.9/java_tools_linux-v11.9.zip",
90-
"https://github.com/bazelbuild/java_tools/releases/download/java_v11.9/java_tools_linux-v11.9.zip",
89+
"http://ats.apps.svc/bazel_java_tools/releases/java/v11.9/java_tools_linux-v11.9.zip",
90+
"https://mirror.bazel.build/bazel_java_tools/releases/java/v11.9/java_tools_linux-v11.9.zip",
91+
"https://github.com/bazelbuild/java_tools/releases/download/java_v11.9/java_tools_linux-v11.9.zip",
9192
],
9293
)

br/pkg/lightning/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ go_library(
2929
"//expression",
3030
"//planner/core",
3131
"//util",
32+
"//util/cmp",
3233
"//util/promutil",
3334
"@com_github_go_sql_driver_mysql//:mysql",
3435
"@com_github_google_uuid//:uuid",

br/pkg/lightning/backend/kv/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ go_library(
3434
"//tablecodec",
3535
"//types",
3636
"//util/chunk",
37+
"//util/cmp",
3738
"//util/codec",
3839
"//util/mathutil",
3940
"//util/topsql/stmtstats",

br/pkg/lightning/backend/kv/sql2kv.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import (
3535
"github.com/pingcap/tidb/table"
3636
"github.com/pingcap/tidb/tablecodec"
3737
"github.com/pingcap/tidb/types"
38+
"github.com/pingcap/tidb/util/cmp"
3839
"golang.org/x/exp/slices"
3940
)
4041

@@ -126,8 +127,8 @@ func CollectGeneratedColumns(se *Session, meta *model.TableInfo, cols []*table.C
126127
}
127128

128129
// order the result by column offset so they match the evaluation order.
129-
slices.SortFunc(genCols, func(i, j GeneratedCol) bool {
130-
return cols[i.Index].Offset < cols[j.Index].Offset
130+
slices.SortFunc(genCols, func(i, j GeneratedCol) int {
131+
return cmp.Compare(cols[i.Index].Offset, cols[j.Index].Offset)
131132
})
132133
return genCols, nil
133134
}

br/pkg/lightning/backend/local/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,11 @@ go_library(
5252
"//table",
5353
"//tablecodec",
5454
"//types",
55+
"//util/cmp",
5556
"//util/codec",
5657
"//util/engine",
5758
"//util/hack",
59+
"//util/intest",
5860
"//util/mathutil",
5961
"//util/ranger",
6062
"@com_github_cockroachdb_pebble//:pebble",

br/pkg/lightning/backend/local/disk_quota.go

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ package local
1717
import (
1818
"github.com/google/uuid"
1919
"github.com/pingcap/tidb/br/pkg/lightning/backend"
20+
"github.com/pingcap/tidb/util/cmp"
2021
"golang.org/x/exp/slices"
2122
)
2223

@@ -38,11 +39,14 @@ func CheckDiskQuota(mgr DiskUsage, quota int64) (
3839
totalMemSize int64,
3940
) {
4041
sizes := mgr.EngineFileSizes()
41-
slices.SortFunc(sizes, func(i, j backend.EngineFileSize) bool {
42+
slices.SortFunc(sizes, func(i, j backend.EngineFileSize) int {
4243
if i.IsImporting != j.IsImporting {
43-
return i.IsImporting
44+
if i.IsImporting {
45+
return -1
46+
}
47+
return 1
4448
}
45-
return i.DiskSize+i.MemSize < j.DiskSize+j.MemSize
49+
return cmp.Compare(i.DiskSize+i.MemSize, j.DiskSize+j.MemSize)
4650
})
4751
for _, size := range sizes {
4852
totalDiskSize += size.DiskSize

br/pkg/lightning/backend/local/engine.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -767,8 +767,8 @@ func (e *Engine) batchIngestSSTs(metas []*sstMeta) error {
767767
if len(metas) == 0 {
768768
return nil
769769
}
770-
slices.SortFunc(metas, func(i, j *sstMeta) bool {
771-
return bytes.Compare(i.minKey, j.minKey) < 0
770+
slices.SortFunc(metas, func(i, j *sstMeta) int {
771+
return bytes.Compare(i.minKey, j.minKey)
772772
})
773773

774774
// non overlapping sst is grouped, and ingested in that order
@@ -1178,8 +1178,8 @@ func (w *Writer) flushKVs(ctx context.Context) error {
11781178
return errors.Trace(err)
11791179
}
11801180
if !w.isWriteBatchSorted {
1181-
slices.SortFunc(w.writeBatch[:w.batchCount], func(i, j common.KvPair) bool {
1182-
return bytes.Compare(i.Key, j.Key) < 0
1181+
slices.SortFunc(w.writeBatch[:w.batchCount], func(i, j common.KvPair) int {
1182+
return bytes.Compare(i.Key, j.Key)
11831183
})
11841184
w.isWriteBatchSorted = true
11851185
}

br/pkg/lightning/backend/local/local.go

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ import (
5656
"github.com/pingcap/tidb/tablecodec"
5757
"github.com/pingcap/tidb/util/codec"
5858
"github.com/pingcap/tidb/util/engine"
59+
"github.com/pingcap/tidb/util/intest"
5960
"github.com/pingcap/tidb/util/mathutil"
6061
"github.com/tikv/client-go/v2/oracle"
6162
tikvclient "github.com/tikv/client-go/v2/tikv"
@@ -76,9 +77,6 @@ const (
7677
dialTimeout = 5 * time.Minute
7778
maxRetryTimes = 5
7879
defaultRetryBackoffTime = 3 * time.Second
79-
// maxWriteAndIngestRetryTimes is the max retry times for write and ingest.
80-
// A large retry times is for tolerating tikv cluster failures.
81-
maxWriteAndIngestRetryTimes = 30
8280

8381
gRPCKeepAliveTime = 10 * time.Minute
8482
gRPCKeepAliveTimeout = 5 * time.Minute
@@ -111,6 +109,10 @@ var (
111109

112110
errorEngineClosed = errors.New("engine is closed")
113111
maxRetryBackoffSecond = 30
112+
113+
// MaxWriteAndIngestRetryTimes is the max retry times for write and ingest.
114+
// A large retry times is for tolerating tikv cluster failures.
115+
MaxWriteAndIngestRetryTimes = 30
114116
)
115117

116118
// ImportClientFactory is factory to create new import client for specific store.
@@ -1523,8 +1525,21 @@ func (local *Backend) doImport(ctx context.Context, engine *Engine, regionRanges
15231525
switch job.stage {
15241526
case regionScanned, wrote:
15251527
job.retryCount++
1526-
if job.retryCount > maxWriteAndIngestRetryTimes {
1527-
firstErr.Set(job.lastRetryableErr)
1528+
if job.retryCount > MaxWriteAndIngestRetryTimes {
1529+
lastErr := job.lastRetryableErr
1530+
if lastErr == nil {
1531+
if intest.InTest {
1532+
panic("lastRetryableErr should not be nil")
1533+
}
1534+
lastErr = errors.New("retry limit exceeded")
1535+
log.FromContext(ctx).Error(
1536+
"lastRetryableErr should not be nil",
1537+
logutil.Key("startKey", job.keyRange.start),
1538+
logutil.Key("endKey", job.keyRange.end),
1539+
zap.Stringer("stage", job.stage),
1540+
zap.Error(lastErr))
1541+
}
1542+
firstErr.Set(lastErr)
15281543
workerCancel()
15291544
jobWg.Done()
15301545
continue

0 commit comments

Comments
 (0)