Skip to content

Commit

Permalink
merge upstream
Browse files Browse the repository at this point in the history
Signed-off-by: husharp <[email protected]>
  • Loading branch information
HuSharp committed Apr 12, 2023
2 parents 1b78647 + 5109e41 commit 255f22c
Show file tree
Hide file tree
Showing 415 changed files with 21,254 additions and 15,663 deletions.
2 changes: 1 addition & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ test:ci --color=yes
test:ci --verbose_failures --test_verbose_timeout_warnings
test:ci --test_env=GO_TEST_WRAP_TESTV=1
test:ci --experimental_ui_max_stdouterr_bytes=104857600
test:ci --test_timeout=120,300,900,3600
test:ci --test_timeout=150,300,900,3600
test:race --test_timeout=1200,6000,18000,72000

try-import /data/bazel
621 changes: 322 additions & 299 deletions DEPS.bzl

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ errdoc:tools/bin/errdoc-gen
lint:tools/bin/revive
@echo "linting"
@tools/bin/revive -formatter friendly -config tools/check/revive.toml $(FILES_TIDB_TESTS)
@tools/bin/revive -formatter friendly -config tools/check/revive.toml ./br/pkg/lightning/...

license:
bazel $(BAZEL_GLOBAL_CONFIG) run $(BAZEL_CMD_CONFIG) \
Expand Down Expand Up @@ -333,8 +334,9 @@ mock_s3iface:
@mockgen -package mock github.com/aws/aws-sdk-go/service/s3/s3iface S3API > br/pkg/mock/s3iface.go

mock_lightning:
@mockgen -package mock -mock_names AbstractBackend=MockBackend github.com/pingcap/tidb/br/pkg/lightning/backend AbstractBackend,EngineWriter,TargetInfoGetter > br/pkg/mock/backend.go
@mockgen -package mock github.com/pingcap/tidb/br/pkg/lightning/backend Backend,EngineWriter,TargetInfoGetter,ChunkFlushStatus > br/pkg/mock/backend.go
@mockgen -package mock github.com/pingcap/tidb/br/pkg/lightning/backend/encode Encoder,EncodingBuilder,Rows,Row > br/pkg/mock/encode.go
@mockgen -package mocklocal github.com/pingcap/tidb/br/pkg/lightning/backend/local DiskUsage > br/pkg/mock/mocklocal/local.go

# There is no FreeBSD environment for GitHub actions. So cross-compile on Linux
# but that doesn't work with CGO_ENABLED=1, so disable cgo. The reason to have
Expand Down Expand Up @@ -479,6 +481,10 @@ bazel_addindextest: failpoint-enable bazel_ci_prepare
bazel $(BAZEL_GLOBAL_CONFIG) test $(BAZEL_CMD_CONFIG) --test_arg=-with-real-tikv --define gotags=deadlock,intest \
-- //tests/realtikvtest/addindextest/...

bazel_loaddatatest: failpoint-enable bazel_ci_prepare
bazel $(BAZEL_GLOBAL_CONFIG) test $(BAZEL_CMD_CONFIG) --test_arg=-with-real-tikv --define gotags=deadlock,intest \
-- //tests/realtikvtest/loaddatatest/...

bazel_lint: bazel_prepare
bazel build //... --//build:with_nogo_flag=true

Expand Down
18 changes: 9 additions & 9 deletions WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")

http_archive(
name = "io_bazel_rules_go",
sha256 = "dd926a88a564a9246713a9c00b35315f54cbd46b31a26d5d8fb264c07045f05d",
sha256 = "6b65cb7917b4d1709f9410ffe00ecf3e160edf674b78c54a894471320862184f",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.38.1/rules_go-v0.38.1.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.38.1/rules_go-v0.38.1.zip",
"https://ats.apps.svc/bazelbuild/rules_go/releases/download/v0.38.1/rules_go-v0.38.1.zip",
"https://mirror.bazel.build/github.com/bazelbuild/rules_go/releases/download/v0.39.0/rules_go-v0.39.0.zip",
"https://github.com/bazelbuild/rules_go/releases/download/v0.39.0/rules_go-v0.39.0.zip",
"https://ats.apps.svc/bazelbuild/rules_go/releases/download/v0.39.0/rules_go-v0.39.0.zip",
],
)

http_archive(
name = "bazel_gazelle",
sha256 = "ecba0f04f96b4960a5b250c8e8eeec42281035970aa8852dda73098274d14a1d",
sha256 = "727f3e4edd96ea20c29e8c2ca9e8d2af724d8c7778e7923a854b2c80952bc405",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.29.0/bazel-gazelle-v0.29.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.29.0/bazel-gazelle-v0.29.0.tar.gz",
"http://ats.apps.svc/bazelbuild/bazel-gazelle/releases/download/v0.29.0/bazel-gazelle-v0.29.0.tar.gz",
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.30.0/bazel-gazelle-v0.30.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.30.0/bazel-gazelle-v0.30.0.tar.gz",
"http://ats.apps.svc/bazelbuild/bazel-gazelle/releases/download/v0.30.0/bazel-gazelle-v0.30.0.tar.gz",
],
)

Expand Down Expand Up @@ -47,7 +47,7 @@ go_download_sdk(
"https://mirrors.aliyun.com/golang/{}",
"https://dl.google.com/go/{}",
],
version = "1.20.2",
version = "1.20.3",
)

go_register_toolchains(
Expand Down
2 changes: 2 additions & 0 deletions bindinfo/handle.go
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,9 @@ func (h *BindHandle) CaptureBaselines() {
if bindSQL == "" {
continue
}
h.sctx.Lock()
charset, collation := h.sctx.GetSessionVars().GetCharsetInfo()
h.sctx.Unlock()
binding := Binding{
BindSQL: bindSQL,
Status: Enabled,
Expand Down
2 changes: 2 additions & 0 deletions br/pkg/gluetidb/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,14 @@ go_test(
embed = [":gluetidb"],
flaky = True,
deps = [
"//br/pkg/glue",
"//ddl",
"//kv",
"//meta",
"//parser/model",
"//sessionctx",
"//testkit",
"//types",
"@com_github_pingcap_failpoint//:failpoint",
"@com_github_stretchr_testify//require",
],
Expand Down
6 changes: 6 additions & 0 deletions br/pkg/gluetidb/glue.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,12 @@ func (gs *tidbSession) ExecuteInternal(ctx context.Context, sql string, args ...
if err != nil {
return errors.Trace(err)
}
defer func() {
vars := gs.se.GetSessionVars()
vars.TxnCtxMu.Lock()
vars.TxnCtx.InfoSchema = nil
vars.TxnCtxMu.Unlock()
}()
// Some of SQLs (like ADMIN RECOVER INDEX) may lazily take effect
// when we polling the result set.
// At least call `next` once for triggering theirs side effect.
Expand Down
62 changes: 62 additions & 0 deletions br/pkg/gluetidb/glue_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,14 @@ import (
"testing"

"github.com/pingcap/failpoint"
"github.com/pingcap/tidb/br/pkg/glue"
"github.com/pingcap/tidb/ddl"
"github.com/pingcap/tidb/kv"
"github.com/pingcap/tidb/meta"
"github.com/pingcap/tidb/parser/model"
"github.com/pingcap/tidb/sessionctx"
"github.com/pingcap/tidb/testkit"
"github.com/pingcap/tidb/types"
"github.com/stretchr/testify/require"
)

Expand Down Expand Up @@ -206,3 +208,63 @@ func TestSplitBatchCreateTableFailWithEntryTooLarge(t *testing.T) {

require.NoError(t, failpoint.Disable("github.com/pingcap/tidb/ddl/RestoreBatchCreateTableEntryTooLarge"))
}

func TestTheSessionIsoation(t *testing.T) {
req := require.New(t)
store, _ := testkit.CreateMockStoreAndDomain(t)
ctx := context.Background()

g := Glue{}
session, err := g.CreateSession(store)
req.NoError(err)

req.NoError(session.ExecuteInternal(ctx, "use test;"))
infos := []*model.TableInfo{}
infos = append(infos, &model.TableInfo{
Name: model.NewCIStr("tables_1"),
Columns: []*model.ColumnInfo{
{Name: model.NewCIStr("foo"), FieldType: *types.NewFieldType(types.KindBinaryLiteral), State: model.StatePublic},
},
})
infos = append(infos, &model.TableInfo{
Name: model.NewCIStr("tables_2"),
PlacementPolicyRef: &model.PolicyRefInfo{
Name: model.NewCIStr("threereplication"),
},
Columns: []*model.ColumnInfo{
{Name: model.NewCIStr("foo"), FieldType: *types.NewFieldType(types.KindBinaryLiteral), State: model.StatePublic},
},
})
infos = append(infos, &model.TableInfo{
Name: model.NewCIStr("tables_3"),
PlacementPolicyRef: &model.PolicyRefInfo{
Name: model.NewCIStr("fivereplication"),
},
Columns: []*model.ColumnInfo{
{Name: model.NewCIStr("foo"), FieldType: *types.NewFieldType(types.KindBinaryLiteral), State: model.StatePublic},
},
})
polices := []*model.PolicyInfo{
{
PlacementSettings: &model.PlacementSettings{
Followers: 4,
},
Name: model.NewCIStr("fivereplication"),
},
{
PlacementSettings: &model.PlacementSettings{
Followers: 2,
},
Name: model.NewCIStr("threereplication"),
},
}
for _, pinfo := range polices {
before := session.(*tidbSession).se.GetInfoSchema().SchemaMetaVersion()
req.NoError(session.CreatePlacementPolicy(ctx, pinfo))
after := session.(*tidbSession).se.GetInfoSchema().SchemaMetaVersion()
req.Greater(after, before)
}
req.NoError(session.(glue.BatchCreateTableSession).CreateTables(ctx, map[string][]*model.TableInfo{
"test": infos,
}))
}
3 changes: 0 additions & 3 deletions br/pkg/lightning/backend/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,13 @@ go_library(
"//br/pkg/lightning/backend/encode",
"//br/pkg/lightning/checkpoints",
"//br/pkg/lightning/common",
"//br/pkg/lightning/config",
"//br/pkg/lightning/log",
"//br/pkg/lightning/metric",
"//br/pkg/lightning/mydump",
"//parser/model",
"//table",
"@com_github_google_uuid//:uuid",
"@com_github_pingcap_errors//:errors",
"@com_github_pingcap_failpoint//:failpoint",
"@org_golang_x_exp//slices",
"@org_uber_go_zap//:zap",
],
)
Expand Down
Loading

0 comments on commit 255f22c

Please sign in to comment.