Skip to content

Commit

Permalink
Merge remote-tracking branch 'pingcap/master' into always-glob-stats
Browse files Browse the repository at this point in the history
  • Loading branch information
mjonss committed Sep 27, 2022
2 parents 57e6ed3 + c5a28bf commit 2109f69
Show file tree
Hide file tree
Showing 260 changed files with 20,317 additions and 10,706 deletions.
1 change: 1 addition & 0 deletions .bazelversion
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
5.3.1
1 change: 1 addition & 0 deletions .github/licenserc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,5 @@ header:
- "tidb-binlog/driver/example"
- "tidb-binlog/proto/go-binlog/secondary_binlog.pb.go"
- "**/*.sql"
- ".bazelversion"
comment: on-failure
8 changes: 4 additions & 4 deletions DEPS.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3407,8 +3407,8 @@ def go_deps():
name = "com_github_tikv_client_go_v2",
build_file_proto_mode = "disable_global",
importpath = "github.com/tikv/client-go/v2",
sum = "h1:p8XInTnkUlLabBT7bDS3aZCeemO6tJ/7b5mHN8WbSIE=",
version = "v2.0.1-0.20220913051514-ffaaf7131a8d",
sum = "h1:GJNu6XDT8W2Oahh+w/fhb37PNhFr4EZjdehIklZnhU4=",
version = "v2.0.1-0.20220921101651-ce9203ef66e9",
)
go_repository(
name = "com_github_tikv_pd_client",
Expand Down Expand Up @@ -4453,8 +4453,8 @@ def go_deps():
name = "org_uber_go_goleak",
build_file_proto_mode = "disable_global",
importpath = "go.uber.org/goleak",
sum = "h1:gZAh5/EyT/HQwlpkCy6wTpqfH9H8Lz8zbm3dZh+OyzA=",
version = "v1.1.12",
sum = "h1:xqgm/S+aQvhWFTtR0XK3Jvg7z8kGV8P4X14IzwN3Eqk=",
version = "v1.2.0",
)
go_repository(
name = "org_uber_go_multierr",
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# limitations under the License.

# Builder image
FROM golang:1.18.1-alpine as builder
FROM golang:1.19.1-alpine as builder

RUN apk add --no-cache \
wget \
Expand Down
5 changes: 4 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

include Makefile.common

.PHONY: all clean test server dev benchkv benchraw check checklist parser tidy ddltest build_br build_lightning build_lightning-ctl build_dumpling ut bazel_build bazel_prepare bazel_test check-file-perm
.PHONY: all clean test server dev benchkv benchraw check checklist parser tidy ddltest build_br build_lightning build_lightning-ctl build_dumpling ut bazel_build bazel_prepare bazel_test check-file-perm bazel_lint

default: server buildsucc

Expand Down Expand Up @@ -463,3 +463,6 @@ bazel_txntest: failpoint-enable bazel_ci_prepare
bazel_addindextest: failpoint-enable bazel_ci_prepare
bazel $(BAZEL_GLOBAL_CONFIG) test $(BAZEL_CMD_CONFIG) --test_arg=-with-real-tikv \
-- //tests/realtikvtest/addindextest/...

bazel_lint: bazel_prepare
bazel build //... --//build:with_nogo_flag=true
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ TiDB ("Ti" stands for Titanium) is an open-source NewSQL database that supports

For more details and latest updates, see [TiDB docs](https://docs.pingcap.com/tidb/stable) and [release notes](https://docs.pingcap.com/tidb/dev/release-notes).

For future plans, see [TiDB Roadmap](roadmap.md).

## Quick start

### Start with TiDB Cloud
Expand Down
2 changes: 1 addition & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ go_rules_dependencies()

go_register_toolchains(
nogo = "@//build:tidb_nogo",
version = "1.19",
version = "1.19.1",
)

gazelle_dependencies()
Expand Down
22 changes: 22 additions & 0 deletions bindinfo/bind_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,28 @@ using
require.False(t, tk.HasPlan("with cte as (select * from t1) select * from cte", "CTEFullScan"))
}

func TestBindNoDecorrelate(t *testing.T) {
store := testkit.CreateMockStore(t)

tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("drop table if exists t1")
tk.MustExec("drop table if exists t2")
tk.MustExec("create table t1(a int, b int)")
tk.MustExec("create table t2(a int, b int)")
require.False(t, tk.HasPlan("select exists (select t2.b from t2 where t2.a = t1.b limit 2) from t1", "Apply"))
require.True(t, tk.HasPlan("select exists (select /*+ no_decorrelate() */ t2.b from t2 where t2.a = t1.b limit 2) from t1", "Apply"))

tk.MustExec(`
create global binding for
select exists (select t2.b from t2 where t2.a = t1.b limit 2) from t1
using
select exists (select /*+ no_decorrelate() */ t2.b from t2 where t2.a = t1.b limit 2) from t1
`)

require.True(t, tk.HasPlan("select exists (select t2.b from t2 where t2.a = t1.b limit 2) from t1", "Apply"))
}

// TestBindingSymbolList tests sql with "?, ?, ?, ?", fixes #13871
func TestBindingSymbolList(t *testing.T) {
store, dom := testkit.CreateMockStoreAndDomain(t)
Expand Down
21 changes: 11 additions & 10 deletions br/cmd/br/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,17 @@ func runRestoreCommand(command *cobra.Command, cmdName string) error {
defer trace.TracerFinishSpan(ctx, store)
}

if cfg.MetaPhase {
if err := task.RunRestoreEBSMeta(GetDefaultContext(), gluetikv.Glue{}, cmdName, &cfg); err != nil {
log.Error("failed to restore EBS meta", zap.Error(err))
return errors.Trace(err)
}
return nil
} else if cfg.DataPhase {
if err := task.RunResolveKvData(GetDefaultContext(), tidbGlue, cmdName, &cfg); err != nil {
log.Error("failed to restore data", zap.Error(err))
return errors.Trace(err)
if cfg.FullBackupType == task.FullBackupTypeEBS {
if cfg.Prepare {
if err := task.RunRestoreEBSMeta(GetDefaultContext(), gluetikv.Glue{}, cmdName, &cfg); err != nil {
log.Error("failed to restore EBS meta", zap.Error(err))
return errors.Trace(err)
}
} else {
if err := task.RunResolveKvData(GetDefaultContext(), tidbGlue, cmdName, &cfg); err != nil {
log.Error("failed to restore data", zap.Error(err))
return errors.Trace(err)
}
}
return nil
}
Expand Down
1 change: 1 addition & 0 deletions br/pkg/lightning/config/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ go_test(
flaky = True,
deps = [
":config",
"//br/pkg/lightning/common",
"//parser/mysql",
"@com_github_burntsushi_toml//:toml",
"@com_github_stretchr_testify//require",
Expand Down
13 changes: 10 additions & 3 deletions br/pkg/lightning/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ const (
var (
supportedStorageTypes = []string{"file", "local", "s3", "noop", "gcs", "gs"}

DefaultFilter = []string{
defaultFilter = []string{
"*.*",
"!mysql.*",
"!sys.*",
Expand All @@ -109,6 +109,13 @@ var (
}
)

// GetDefaultFilter gets the default table filter used in Lightning.
// It clones the original default filter,
// so that the original value won't be changed when the returned slice's element is changed.
func GetDefaultFilter() []string {
return append([]string{}, defaultFilter...)
}

type DBStore struct {
Host string `toml:"host" json:"host"`
Port int `toml:"port" json:"port"`
Expand Down Expand Up @@ -715,7 +722,7 @@ func NewConfig() *Config {
},
StrictFormat: false,
MaxRegionSize: MaxRegionSize,
Filter: DefaultFilter,
Filter: GetDefaultFilter(),
DataCharacterSet: defaultCSVDataCharacterSet,
DataInvalidCharReplace: string(defaultCSVDataInvalidCharReplace),
},
Expand Down Expand Up @@ -890,7 +897,7 @@ func (cfg *Config) Adjust(ctx context.Context) error {
// mydumper.filter and black-white-list cannot co-exist.
if cfg.HasLegacyBlackWhiteList() {
log.L().Warn("the config `black-white-list` has been deprecated, please replace with `mydumper.filter`")
if !common.StringSliceEqual(cfg.Mydumper.Filter, DefaultFilter) {
if !common.StringSliceEqual(cfg.Mydumper.Filter, defaultFilter) {
return common.ErrInvalidConfig.GenWithStack("`mydumper.filter` and `black-white-list` cannot be simultaneously defined")
}
}
Expand Down
43 changes: 41 additions & 2 deletions br/pkg/lightning/config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"time"

"github.com/BurntSushi/toml"
"github.com/pingcap/tidb/br/pkg/lightning/common"
"github.com/pingcap/tidb/br/pkg/lightning/config"
"github.com/pingcap/tidb/parser/mysql"
"github.com/stretchr/testify/require"
Expand Down Expand Up @@ -750,7 +751,7 @@ func TestCronEncodeDecode(t *testing.T) {
func TestAdjustWithLegacyBlackWhiteList(t *testing.T) {
cfg := config.NewConfig()
assignMinimalLegalValue(cfg)
require.Equal(t, config.DefaultFilter, cfg.Mydumper.Filter)
require.Equal(t, config.GetDefaultFilter(), cfg.Mydumper.Filter)
require.False(t, cfg.HasLegacyBlackWhiteList())

ctx := context.Background()
Expand All @@ -762,7 +763,7 @@ func TestAdjustWithLegacyBlackWhiteList(t *testing.T) {
cfg.BWList.DoDBs = []string{"test"}
require.EqualError(t, cfg.Adjust(ctx), "[Lightning:Config:ErrInvalidConfig]`mydumper.filter` and `black-white-list` cannot be simultaneously defined")

cfg.Mydumper.Filter = config.DefaultFilter
cfg.Mydumper.Filter = config.GetDefaultFilter()
require.NoError(t, cfg.Adjust(ctx))
require.True(t, cfg.HasLegacyBlackWhiteList())
}
Expand Down Expand Up @@ -955,3 +956,41 @@ func TestCheckAndAdjustForLocalBackend(t *testing.T) {
cfg.TikvImporter.SortedKVDir = base
require.NoError(t, cfg.CheckAndAdjustForLocalBackend())
}

func TestCreateSeveralConfigsWithDifferentFilters(t *testing.T) {
originalDefaultCfg := append([]string{}, config.GetDefaultFilter()...)
cfg1 := config.NewConfig()
require.NoError(t, cfg1.LoadFromTOML([]byte(`
[mydumper]
filter = ["db1.tbl1", "db2.*", "!db2.tbl1"]
`)))
require.Equal(t, 3, len(cfg1.Mydumper.Filter))
require.True(t, common.StringSliceEqual(
cfg1.Mydumper.Filter,
[]string{"db1.tbl1", "db2.*", "!db2.tbl1"},
))
require.True(t, common.StringSliceEqual(config.GetDefaultFilter(), originalDefaultCfg))

cfg2 := config.NewConfig()
require.True(t, common.StringSliceEqual(
cfg2.Mydumper.Filter,
originalDefaultCfg,
))
require.True(t, common.StringSliceEqual(config.GetDefaultFilter(), originalDefaultCfg))

gCfg1, err := config.LoadGlobalConfig([]string{"-f", "db1.tbl1", "-f", "db2.*", "-f", "!db2.tbl1"}, nil)
require.NoError(t, err)
require.True(t, common.StringSliceEqual(
gCfg1.Mydumper.Filter,
[]string{"db1.tbl1", "db2.*", "!db2.tbl1"},
))
require.True(t, common.StringSliceEqual(config.GetDefaultFilter(), originalDefaultCfg))

gCfg2, err := config.LoadGlobalConfig([]string{}, nil)
require.NoError(t, err)
require.True(t, common.StringSliceEqual(
gCfg2.Mydumper.Filter,
originalDefaultCfg,
))
require.True(t, common.StringSliceEqual(config.GetDefaultFilter(), originalDefaultCfg))
}
2 changes: 1 addition & 1 deletion br/pkg/lightning/config/global.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ func NewGlobalConfig() *GlobalConfig {
LogLevel: "error",
},
Mydumper: GlobalMydumper{
Filter: DefaultFilter,
Filter: GetDefaultFilter(),
},
TikvImporter: GlobalImporter{
Backend: "",
Expand Down
4 changes: 2 additions & 2 deletions br/pkg/lightning/restore/precheck_impl.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func (ci *clusterResourceCheckItem) getReplicaCount(ctx context.Context) (uint64
func (ci *clusterResourceCheckItem) Check(ctx context.Context) (*CheckResult, error) {
theResult := &CheckResult{
Item: ci.GetCheckItemID(),
Severity: Critical,
Severity: Warn,
Passed: true,
Message: "Cluster resources are rich for this import task",
}
Expand Down Expand Up @@ -208,7 +208,7 @@ func (ci *emptyRegionCheckItem) GetCheckItemID() CheckItemID {
func (ci *emptyRegionCheckItem) Check(ctx context.Context) (*CheckResult, error) {
theResult := &CheckResult{
Item: ci.GetCheckItemID(),
Severity: Critical,
Severity: Warn,
Passed: true,
Message: "Cluster doesn't have too many empty regions",
}
Expand Down
Loading

0 comments on commit 2109f69

Please sign in to comment.