Skip to content

Commit 3d982ce

Browse files
committed
Merge branch 'master' into stmtsummary
Signed-off-by: mornyx <[email protected]>
2 parents 34ff06b + 337af61 commit 3d982ce

File tree

164 files changed

+15615
-11468
lines changed

Some content is hidden

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

164 files changed

+15615
-11468
lines changed

.github/licenserc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,5 @@ header:
4040
- "tidb-binlog/proto/go-binlog/secondary_binlog.pb.go"
4141
- "**/*.sql"
4242
- ".bazelversion"
43+
- "build/image/.ci_bazel"
4344
comment: on-failure

DEPS.bzl

Lines changed: 21 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -472,8 +472,8 @@ def go_deps():
472472
name = "com_github_chavacava_garif",
473473
build_file_proto_mode = "disable",
474474
importpath = "github.com/chavacava/garif",
475-
sum = "h1:E7LT642ysztPWE0dfz43cWOvMiF42DyTRC+eZIaO4yI=",
476-
version = "v0.0.0-20220630083739-93517212f375",
475+
sum = "h1:cy5GCEZLUCshCGCRRUjxHrDUqkB4l5cuUt3ShEckQEo=",
476+
version = "v0.0.0-20221024190013-b3ef35877348",
477477
)
478478

479479
go_repository(
@@ -1040,8 +1040,8 @@ def go_deps():
10401040
name = "com_github_fatih_color",
10411041
build_file_proto_mode = "disable_global",
10421042
importpath = "github.com/fatih/color",
1043-
sum = "h1:8LOYc1KYPPmyKMuN8QV2DNRWNbLo6LZ0iLs8+mlH53w=",
1044-
version = "v1.13.0",
1043+
sum = "h1:qfhVLaG5s+nCROl1zJsZRxFeYrHLqWroPOQ8BWiNb4w=",
1044+
version = "v1.14.1",
10451045
)
10461046
go_repository(
10471047
name = "com_github_fatih_structs",
@@ -2763,8 +2763,8 @@ def go_deps():
27632763
name = "com_github_mattn_go_isatty",
27642764
build_file_proto_mode = "disable_global",
27652765
importpath = "github.com/mattn/go-isatty",
2766-
sum = "h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ=",
2767-
version = "v0.0.16",
2766+
sum = "h1:BTarxUcIeDqL27Mc+vyvdWYSL28zpIhv3RoTdsLMPng=",
2767+
version = "v0.0.17",
27682768
)
27692769
go_repository(
27702770
name = "com_github_mattn_go_runewidth",
@@ -2844,8 +2844,8 @@ def go_deps():
28442844
name = "com_github_mgechev_revive",
28452845
build_file_proto_mode = "disable",
28462846
importpath = "github.com/mgechev/revive",
2847-
sum = "h1:+2Hd/S8oO2H0Ikq2+egtNwQsVhAeELHjxjIUFX5ajLI=",
2848-
version = "v1.2.4",
2847+
sum = "h1:UF9AR8pOAuwNmhXj2odp4mxv9Nx2qUIwVz8ZsU+Mbec=",
2848+
version = "v1.2.5",
28492849
)
28502850

28512851
go_repository(
@@ -3342,8 +3342,8 @@ def go_deps():
33423342
name = "com_github_pingcap_kvproto",
33433343
build_file_proto_mode = "disable_global",
33443344
importpath = "github.com/pingcap/kvproto",
3345-
sum = "h1:LB+BrfyO5fsz5pwN3V4HvTrpZTAmsjB4VkCEBLbjYUw=",
3346-
version = "v0.0.0-20230119031034-25f1909b7934",
3345+
sum = "h1:oYUK4V5PMlyIooU/+pPkKrJ3vELwcuuCNyKKlqSQa5c=",
3346+
version = "v0.0.0-20230131104319-a7c51106dfe7",
33473347
)
33483348
go_repository(
33493349
name = "com_github_pingcap_log",
@@ -3544,8 +3544,8 @@ def go_deps():
35443544
name = "com_github_rivo_uniseg",
35453545
build_file_proto_mode = "disable_global",
35463546
importpath = "github.com/rivo/uniseg",
3547-
sum = "h1:YwD0ulJSJytLpiaWua0sBDusfsCZohxjxzVTYjwxfV8=",
3548-
version = "v0.4.2",
3547+
sum = "h1:utMvzDsuh3suAEnhH0RdHmoPbU648o6CvXxTx4SBMOw=",
3548+
version = "v0.4.3",
35493549
)
35503550
go_repository(
35513551
name = "com_github_rlmcpherson_s3gof3r",
@@ -4062,8 +4062,8 @@ def go_deps():
40624062
name = "com_github_tikv_pd",
40634063
build_file_proto_mode = "disable",
40644064
importpath = "github.com/tikv/pd",
4065-
sum = "h1:cj3bhdIBJcLL2304EDEmd3eX+r73+hbGSYRFn/APiDU=",
4066-
version = "v1.1.0-beta.0.20230119114149-402c2bfee2f3",
4065+
sum = "h1:ef+kODGby/rmF9fabJzqRM15NcGufkTRftROdy7jvAk=",
4066+
version = "v1.1.0-beta.0.20230201064005-6ca9a3398f15",
40674067
)
40684068

40694069
go_repository(
@@ -4831,7 +4831,6 @@ def go_deps():
48314831
sum = "h1:CYjC+xzdPvbV65gi6Dr4YowKcmLo045pm18L0DhdELM=",
48324832
version = "v0.2.0",
48334833
)
4834-
48354834
go_repository(
48364835
name = "com_google_cloud_go_gsuiteaddons",
48374836
build_file_proto_mode = "disable",
@@ -5044,7 +5043,6 @@ def go_deps():
50445043
sum = "h1:u6EznTGzIdsyOsvm+Xkw0aSuKFXQlyjGE9a4exk6iNQ=",
50455044
version = "v1.3.1",
50465045
)
5047-
50485046
go_repository(
50495047
name = "com_google_cloud_go_recaptchaenterprise_v2",
50505048
build_file_proto_mode = "disable",
@@ -5249,7 +5247,6 @@ def go_deps():
52495247
sum = "h1:/CsSTkbmO9HC8iQpxbK8ATms3OQaX3YQUeTMGCxlaK4=",
52505248
version = "v1.2.0",
52515249
)
5252-
52535250
go_repository(
52545251
name = "com_google_cloud_go_vision_v2",
52555252
build_file_proto_mode = "disable",
@@ -6079,3 +6076,10 @@ def go_deps():
60796076
sum = "h1:RwpqwwFKBAa2h+F6pMEGpE707Edld0etUD3GhqqhDNc=",
60806077
version = "v1.7.0",
60816078
)
6079+
go_repository(
6080+
name = "tools_gotest_v3",
6081+
build_file_proto_mode = "disable",
6082+
importpath = "gotest.tools/v3",
6083+
sum = "h1:4AuOwCGf4lLR9u3YOe2awrHygurzhO/HeQ6laiA6Sx0=",
6084+
version = "v3.0.3",
6085+
)

Makefile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -411,7 +411,7 @@ bazel_test: failpoint-enable bazel_ci_prepare
411411

412412
bazel_coverage_test: failpoint-enable bazel_ci_prepare
413413
bazel $(BAZEL_GLOBAL_CONFIG) coverage $(BAZEL_CMD_CONFIG) \
414-
--build_event_json_file=bazel_1.json --@io_bazel_rules_go//go/config:cover_format=go_cover --define gotags=deadlock \
414+
--build_event_json_file=bazel_1.json --@io_bazel_rules_go//go/config:cover_format=go_cover --define gotags=deadlock,intest \
415415
-- //... -//cmd/... -//tests/graceshutdown/... \
416416
-//tests/globalkilltest/... -//tests/readonlytest/... -//br/pkg/task:task_test -//tests/realtikvtest/...
417417

@@ -444,27 +444,27 @@ bazel_golangcilinter:
444444
-- run $$($(PACKAGE_DIRECTORIES)) --config ./.golangci.yaml
445445

446446
bazel_brietest: failpoint-enable bazel_ci_prepare
447-
bazel $(BAZEL_GLOBAL_CONFIG) test $(BAZEL_CMD_CONFIG) --test_arg=-with-real-tikv --define gotags=deadlock \
447+
bazel $(BAZEL_GLOBAL_CONFIG) test $(BAZEL_CMD_CONFIG) --test_arg=-with-real-tikv --define gotags=deadlock,intest \
448448
-- //tests/realtikvtest/brietest/...
449449

450450
bazel_pessimistictest: failpoint-enable bazel_ci_prepare
451-
bazel $(BAZEL_GLOBAL_CONFIG) test $(BAZEL_CMD_CONFIG) --test_arg=-with-real-tikv --define gotags=deadlock \
451+
bazel $(BAZEL_GLOBAL_CONFIG) test $(BAZEL_CMD_CONFIG) --test_arg=-with-real-tikv --define gotags=deadlock,intest \
452452
-- //tests/realtikvtest/pessimistictest/...
453453

454454
bazel_sessiontest: failpoint-enable bazel_ci_prepare
455-
bazel $(BAZEL_GLOBAL_CONFIG) test $(BAZEL_CMD_CONFIG) --test_arg=-with-real-tikv --define gotags=deadlock \
455+
bazel $(BAZEL_GLOBAL_CONFIG) test $(BAZEL_CMD_CONFIG) --test_arg=-with-real-tikv --define gotags=deadlock,intest \
456456
-- //tests/realtikvtest/sessiontest/...
457457

458458
bazel_statisticstest: failpoint-enable bazel_ci_prepare
459-
bazel $(BAZEL_GLOBAL_CONFIG) test $(BAZEL_CMD_CONFIG) --test_arg=-with-real-tikv --define gotags=deadlock \
459+
bazel $(BAZEL_GLOBAL_CONFIG) test $(BAZEL_CMD_CONFIG) --test_arg=-with-real-tikv --define gotags=deadlock,intest \
460460
-- //tests/realtikvtest/statisticstest/...
461461

462462
bazel_txntest: failpoint-enable bazel_ci_prepare
463-
bazel $(BAZEL_GLOBAL_CONFIG) test $(BAZEL_CMD_CONFIG) --test_arg=-with-real-tikv --define gotags=deadlock \
463+
bazel $(BAZEL_GLOBAL_CONFIG) test $(BAZEL_CMD_CONFIG) --test_arg=-with-real-tikv --define gotags=deadlock,intest \
464464
-- //tests/realtikvtest/txntest/...
465465

466466
bazel_addindextest: failpoint-enable bazel_ci_prepare
467-
bazel $(BAZEL_GLOBAL_CONFIG) test $(BAZEL_CMD_CONFIG) --test_arg=-with-real-tikv --define gotags=deadlock \
467+
bazel $(BAZEL_GLOBAL_CONFIG) test $(BAZEL_CMD_CONFIG) --test_arg=-with-real-tikv --define gotags=deadlock,intest \
468468
-- //tests/realtikvtest/addindextest/...
469469

470470
bazel_lint: bazel_prepare

README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ See the [Get Started](https://pingcap.github.io/tidb-dev-guide/get-started/intro
4444
You can join the following groups or channels to discuss or ask questions about TiDB, and to keep yourself informed of the latest TiDB updates:
4545

4646
- Seek help when you use TiDB
47-
- [TiDB Forum](https://ask.pingcap.com/)
48-
- [Chinese TiDB Forum](https://asktug.com)
47+
- TiDB Forum: [English](https://ask.pingcap.com/), [Chinese](https://asktug.com)
4948
- Slack channels: [#everyone](https://slack.tidb.io/invite?team=tidb-community&channel=everyone&ref=pingcap-tidb) (English), [#tidb-japan](https://slack.tidb.io/invite?team=tidb-community&channel=tidb-japan&ref=github-tidb) (Japanese)
5049
- [Stack Overflow](https://stackoverflow.com/questions/tagged/tidb) (questions tagged with #tidb)
5150
- Discuss TiDB's implementation and design

bindinfo/capture_test.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -434,8 +434,9 @@ func TestUpdateSubqueryCapture(t *testing.T) {
434434
rows := tk.MustQuery("show global bindings").Rows()
435435
require.Len(t, rows, 1)
436436
bindSQL := "UPDATE /*+ hash_join(@`upd_1` `test`.`t1`), use_index(@`upd_1` `test`.`t1` `idx_b`), use_index(@`sel_1` `test`.`t2` ), use_index(@`sel_2` `test`.`t2` )*/ `test`.`t1` SET `b`=1 WHERE `b` = 2 AND (`a` IN (SELECT `a` FROM `test`.`t2` WHERE `b` = 1) OR `c` IN (SELECT `a` FROM `test`.`t2` WHERE `b` = 1))"
437+
originSQL := "UPDATE `test`.`t1` SET `b`=1 WHERE `b` = 2 AND (`a` IN (SELECT `a` FROM `test`.`t2` WHERE `b` = 1) OR `c` IN (SELECT `a` FROM `test`.`t2` WHERE `b` = 1))"
437438
require.Equal(t, bindSQL, rows[0][1])
438-
tk.MustExec(bindSQL)
439+
tk.MustExec(originSQL)
439440
require.Len(t, tk.Session().GetSessionVars().StmtCtx.GetWarnings(), 0)
440441
}
441442

br/pkg/checksum/executor.go

Lines changed: 37 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,9 @@ type ExecutorBuilder struct {
2727
oldTable *metautil.Table
2828

2929
concurrency uint
30+
31+
oldKeyspace []byte
32+
newKeyspace []byte
3033
}
3134

3235
// NewExecutorBuilder returns a new executor builder.
@@ -51,9 +54,26 @@ func (builder *ExecutorBuilder) SetConcurrency(conc uint) *ExecutorBuilder {
5154
return builder
5255
}
5356

57+
func (builder *ExecutorBuilder) SetOldKeyspace(keyspace []byte) *ExecutorBuilder {
58+
builder.oldKeyspace = keyspace
59+
return builder
60+
}
61+
62+
func (builder *ExecutorBuilder) SetNewKeyspace(keyspace []byte) *ExecutorBuilder {
63+
builder.newKeyspace = keyspace
64+
return builder
65+
}
66+
5467
// Build builds a checksum executor.
5568
func (builder *ExecutorBuilder) Build() (*Executor, error) {
56-
reqs, err := buildChecksumRequest(builder.table, builder.oldTable, builder.ts, builder.concurrency)
69+
reqs, err := buildChecksumRequest(
70+
builder.table,
71+
builder.oldTable,
72+
builder.ts,
73+
builder.concurrency,
74+
builder.oldKeyspace,
75+
builder.newKeyspace,
76+
)
5777
if err != nil {
5878
return nil, errors.Trace(err)
5979
}
@@ -65,6 +85,8 @@ func buildChecksumRequest(
6585
oldTable *metautil.Table,
6686
startTS uint64,
6787
concurrency uint,
88+
oldKeyspace []byte,
89+
newKeyspace []byte,
6890
) ([]*kv.Request, error) {
6991
var partDefs []model.PartitionDefinition
7092
if part := newTable.Partition; part != nil {
@@ -76,7 +98,7 @@ func buildChecksumRequest(
7698
if oldTable != nil {
7799
oldTableID = oldTable.Info.ID
78100
}
79-
rs, err := buildRequest(newTable, newTable.ID, oldTable, oldTableID, startTS, concurrency)
101+
rs, err := buildRequest(newTable, newTable.ID, oldTable, oldTableID, startTS, concurrency, oldKeyspace, newKeyspace)
80102
if err != nil {
81103
return nil, errors.Trace(err)
82104
}
@@ -91,7 +113,7 @@ func buildChecksumRequest(
91113
}
92114
}
93115
}
94-
rs, err := buildRequest(newTable, partDef.ID, oldTable, oldPartID, startTS, concurrency)
116+
rs, err := buildRequest(newTable, partDef.ID, oldTable, oldPartID, startTS, concurrency, oldKeyspace, newKeyspace)
95117
if err != nil {
96118
return nil, errors.Trace(err)
97119
}
@@ -108,9 +130,11 @@ func buildRequest(
108130
oldTableID int64,
109131
startTS uint64,
110132
concurrency uint,
133+
oldKeyspace []byte,
134+
newKeyspace []byte,
111135
) ([]*kv.Request, error) {
112136
reqs := make([]*kv.Request, 0)
113-
req, err := buildTableRequest(tableInfo, tableID, oldTable, oldTableID, startTS, concurrency)
137+
req, err := buildTableRequest(tableInfo, tableID, oldTable, oldTableID, startTS, concurrency, oldKeyspace, newKeyspace)
114138
if err != nil {
115139
return nil, errors.Trace(err)
116140
}
@@ -139,7 +163,7 @@ func buildRequest(
139163
}
140164
}
141165
req, err = buildIndexRequest(
142-
tableID, indexInfo, oldTableID, oldIndexInfo, startTS, concurrency)
166+
tableID, indexInfo, oldTableID, oldIndexInfo, startTS, concurrency, oldKeyspace, newKeyspace)
143167
if err != nil {
144168
return nil, errors.Trace(err)
145169
}
@@ -156,12 +180,14 @@ func buildTableRequest(
156180
oldTableID int64,
157181
startTS uint64,
158182
concurrency uint,
183+
oldKeyspace []byte,
184+
newKeyspace []byte,
159185
) (*kv.Request, error) {
160186
var rule *tipb.ChecksumRewriteRule
161187
if oldTable != nil {
162188
rule = &tipb.ChecksumRewriteRule{
163-
OldPrefix: tablecodec.GenTableRecordPrefix(oldTableID),
164-
NewPrefix: tablecodec.GenTableRecordPrefix(tableID),
189+
OldPrefix: append(append([]byte{}, oldKeyspace...), tablecodec.GenTableRecordPrefix(oldTableID)...),
190+
NewPrefix: append(append([]byte{}, newKeyspace...), tablecodec.GenTableRecordPrefix(tableID)...),
165191
}
166192
}
167193

@@ -195,12 +221,14 @@ func buildIndexRequest(
195221
oldIndexInfo *model.IndexInfo,
196222
startTS uint64,
197223
concurrency uint,
224+
oldKeyspace []byte,
225+
newKeyspace []byte,
198226
) (*kv.Request, error) {
199227
var rule *tipb.ChecksumRewriteRule
200228
if oldIndexInfo != nil {
201229
rule = &tipb.ChecksumRewriteRule{
202-
OldPrefix: tablecodec.EncodeTableIndexPrefix(oldTableID, oldIndexInfo.ID),
203-
NewPrefix: tablecodec.EncodeTableIndexPrefix(tableID, indexInfo.ID),
230+
OldPrefix: append(append([]byte{}, oldKeyspace...), tablecodec.EncodeTableIndexPrefix(oldTableID, oldIndexInfo.ID)...),
231+
NewPrefix: append(append([]byte{}, newKeyspace...), tablecodec.EncodeTableIndexPrefix(tableID, indexInfo.ID)...),
204232
}
205233
}
206234
checksum := &tipb.ChecksumRequest{

br/pkg/conn/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ go_library(
1313
"//br/pkg/pdutil",
1414
"//br/pkg/utils",
1515
"//br/pkg/version",
16+
"//config",
1617
"//domain",
1718
"//kv",
1819
"@com_github_docker_go_units//:go-units",

br/pkg/conn/conn.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import (
2626
"github.com/pingcap/tidb/br/pkg/pdutil"
2727
"github.com/pingcap/tidb/br/pkg/utils"
2828
"github.com/pingcap/tidb/br/pkg/version"
29+
"github.com/pingcap/tidb/config"
2930
"github.com/pingcap/tidb/domain"
3031
"github.com/pingcap/tidb/kv"
3132
"github.com/tikv/client-go/v2/oracle"
@@ -174,7 +175,8 @@ func NewMgr(
174175
}
175176

176177
// Disable GC because TiDB enables GC already.
177-
storage, err := g.Open(fmt.Sprintf("tikv://%s?disableGC=true", pdAddrs), securityOption)
178+
path := fmt.Sprintf("tikv://%s?disableGC=true&keyspaceName=%s", pdAddrs, config.GetGlobalKeyspaceName())
179+
storage, err := g.Open(path, securityOption)
178180
if err != nil {
179181
return nil, errors.Trace(err)
180182
}

br/pkg/gluetidb/glue.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,8 @@ func (gs *tidbSession) CreateTable(ctx context.Context, dbName model.CIStr, tabl
288288
return errors.Trace(err)
289289
}
290290
gs.se.SetValue(sessionctx.QueryString, query)
291+
// Disable foreign key check when batch create tables.
292+
gs.se.GetSessionVars().ForeignKeyChecks = false
291293
// Clone() does not clone partitions yet :(
292294
table = table.Clone()
293295
if table.Partition != nil {

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ go_test(
111111
"//br/pkg/restore/split",
112112
"//br/pkg/utils",
113113
"//ddl",
114+
"//keyspace",
114115
"//kv",
115116
"//parser",
116117
"//parser/ast",

0 commit comments

Comments
 (0)