Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into kill-ddl
Browse files Browse the repository at this point in the history
* upstream/master: (57 commits)
  types: fix incompatible implementation of jsonpath extraction (pingcap#35320)
  planner: fix TRACE PLAN TARGET = 'estimation' panic when meeting partition table (pingcap#35743)
  *: Add `testfork.RunTest` to run multiple tests in one function (pingcap#35746)
  sessionctx/variable: add tests to ensure skipInit can be removed (pingcap#35703)
  helper: request another PD if one of them is unavailable (pingcap#35750)
  metrics: add cached table related metrics to grafana panel (pingcap#34718)
  expression: use cloned RetType at `evaluateExprWithNull` when it may be changed. (pingcap#35759)
  executor: fix left join on partition table generate invalid lock key (pingcap#35732)
  readme: remove adopters (pingcap/docs#8725) (pingcap#35124)
  *: only add default value for final aggregation to fix the aggregate push down (partition) union case (pingcap#35443)
  planner: fix the wrong cost formula of MPPExchanger on cost model ver2 (pingcap#35718)
  sessionctx: support encoding and decoding statement context (pingcap#35688)
  txn: refactor ts acquisition within build and execute phases (pingcap#35376)
  ddl: for schema-level DDL method parameter is now XXXStmt (pingcap#35722)
  *: enable gofmt (pingcap#35721)
  planner: disable collate clause support for enum or set column (pingcap#35684)
  *: Provide a util to "pause" session in uint test (pingcap#35529)
  ddl: implement the core for multi-schema change (pingcap#35429)
  parser: XXXDatabaseStmt now use CIStr for DB name (pingcap#35668)
  *: remove real tikv test on github actions (pingcap#35710)
  ...
  • Loading branch information
morgo committed Jun 28, 2022
2 parents afde8a8 + ed5e63a commit 11e57df
Show file tree
Hide file tree
Showing 294 changed files with 7,297 additions and 3,715 deletions.
44 changes: 0 additions & 44 deletions .github/workflows/integration-test-with-real-tikv.yml

This file was deleted.

1 change: 1 addition & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ load("@bazel_gazelle//:def.bzl", "gazelle")
# gazelle:prefix github.com/pingcap/tidb
# gazelle:exclude tidb-binlog/proto/proto
# gazelle:exclude plugin/conn_ip_example
# gazelle:exclude build/linter/staticcheck
gazelle(name = "gazelle")

package(default_visibility = ["//visibility:public"])
Expand Down
69 changes: 59 additions & 10 deletions DEPS.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@ def go_deps():
name = "co_honnef_go_tools",
build_file_proto_mode = "disable_global",
importpath = "honnef.co/go/tools",
sum = "h1:UoveltGrhghAA7ePc+e+QYDHXrBps2PqFZiHkGR/xK8=",
version = "v0.0.1-2020.1.4",
replace = "honnef.co/go/tools",
sum = "h1:ytYb4rOqyp1TSa2EPvNVwtPQJctSELKaMyLfqNP4+34=",
version = "v0.3.2",
)
go_repository(
name = "com_github_ajg_form",
Expand Down Expand Up @@ -167,15 +168,15 @@ def go_deps():
name = "com_github_blacktear23_go_proxyprotocol",
build_file_proto_mode = "disable_global",
importpath = "github.com/blacktear23/go-proxyprotocol",
sum = "h1:rQlvB2AYWme2bIB18r/SipGiMEVJYE9U0z+MGoU/LtQ=",
version = "v0.0.0-20180807104634-af7a81e8dd0d",
sum = "h1:WmMmtZanGEfIHnJN9N3A4Pl6mM69D+GxEph2eOaCf7g=",
version = "v1.0.0",
)
go_repository(
name = "com_github_burntsushi_toml",
build_file_proto_mode = "disable_global",
importpath = "github.com/BurntSushi/toml",
sum = "h1:WXkYYl6Yr3qBf1K79EBnL4mak0OimBfB0XUf9Vl28OQ=",
version = "v0.3.1",
sum = "h1:GaI7EiDXDRfa8VshkTj7Fym7ha+y8/XxIgD2okUIjLw=",
version = "v0.4.1",
)
go_repository(
name = "com_github_burntsushi_xgb",
Expand Down Expand Up @@ -219,6 +220,14 @@ def go_deps():
sum = "h1:YRXhKfTDauu4ajMg1TPgFO5jnlC2HCbmLXMcTG5cbYE=",
version = "v2.1.2",
)
go_repository(
name = "com_github_charithe_durationcheck",
build_file_proto_mode = "disable",
importpath = "github.com/charithe/durationcheck",
sum = "h1:mPP4ucLrf/rKZiIG/a9IPXHGlh8p4CzgpyTy6EEutYk=",
version = "v0.0.9",
)

go_repository(
name = "com_github_cheggaaa_pb_v3",
build_file_proto_mode = "disable_global",
Expand Down Expand Up @@ -918,6 +927,22 @@ def go_deps():
sum = "h1:yAGX7huGHXlcLOEtBnF4w7FQwA26wojNCwOYAEhLjQM=",
version = "v0.0.4",
)
go_repository(
name = "com_github_golangci_gofmt",
build_file_proto_mode = "disable",
importpath = "github.com/golangci/gofmt",
sum = "h1:iR3fYXUjHCR97qWS8ch1y9zPNsgXThGwjKPrYfqMPks=",
version = "v0.0.0-20190930125516-244bba706f1a",
)

go_repository(
name = "com_github_golangci_prealloc",
build_file_proto_mode = "disable",
importpath = "github.com/golangci/prealloc",
sum = "h1:leSNB7iYzLYSSx3J/s5sVf4Drkc68W2wm4Ixh/mr0us=",
version = "v0.0.0-20180630174525-215b22d4de21",
)

go_repository(
name = "com_github_gomodule_redigo",
build_file_proto_mode = "disable_global",
Expand Down Expand Up @@ -1002,6 +1027,14 @@ def go_deps():
sum = "h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8=",
version = "v0.0.0-20181017120253-0766667cb4d1",
)
go_repository(
name = "com_github_gordonklaus_ineffassign",
build_file_proto_mode = "disable",
importpath = "github.com/gordonklaus/ineffassign",
sum = "h1:PVRE9d4AQKmbelZ7emNig1+NT27DUmKZn5qXxfio54U=",
version = "v0.0.0-20210914165742-4cc7213b9bc8",
)

go_repository(
name = "com_github_gorilla_handlers",
build_file_proto_mode = "disable_global",
Expand Down Expand Up @@ -1532,6 +1565,14 @@ def go_deps():
sum = "h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=",
version = "v0.2.0",
)
go_repository(
name = "com_github_kyoh86_exportloopref",
build_file_proto_mode = "disable",
importpath = "github.com/kyoh86/exportloopref",
sum = "h1:5Ry/at+eFdkX9Vsdw3qU4YkvGtzuVfzT4X7S77LoN/M=",
version = "v0.1.8",
)

go_repository(
name = "com_github_labstack_echo_v4",
build_file_proto_mode = "disable_global",
Expand Down Expand Up @@ -2928,6 +2969,14 @@ def go_deps():
sum = "h1:rxKZ2gOnYxjfmakvUUqh9Gyb6KXfrj7JWTxORTYqb0E=",
version = "v0.0.0-20220426173459-3bcf042a4bf5",
)
go_repository(
name = "org_golang_x_exp_typeparams",
build_file_proto_mode = "disable",
importpath = "golang.org/x/exp/typeparams",
sum = "h1:qyrTQ++p1afMkO4DPEeLGq/3oTsdlvdH4vqZUBWzUKM=",
version = "v0.0.0-20220218215828-6cf2b201936e",
)

go_repository(
name = "org_golang_x_image",
build_file_proto_mode = "disable_global",
Expand All @@ -2953,8 +3002,8 @@ def go_deps():
name = "org_golang_x_mod",
build_file_proto_mode = "disable_global",
importpath = "golang.org/x/mod",
sum = "h1:LQmS1nU0twXLA96Kt7U9qtHJEbBk3z6Q0V4UXjZkpr4=",
version = "v0.6.0-dev.0.20211013180041-c96bc1413d57",
sum = "h1:6zppjxzCulZykYSLyVDYbneBfbaBIQPYMevg0bEwv2s=",
version = "v0.6.0-dev.0.20220419223038-86c51ed26bb4",
)
go_repository(
name = "org_golang_x_net",
Expand Down Expand Up @@ -3009,8 +3058,8 @@ def go_deps():
name = "org_golang_x_tools",
build_file_proto_mode = "disable_global",
importpath = "golang.org/x/tools",
sum = "h1:P1HhGGuLW4aAclzjtmJdf0mJOjVUZUzOTqkAkWL+l6w=",
version = "v0.1.8",
sum = "h1:OKYpQQVE3DKSc3r3zHVzq46vq5YH7x8xpR3/k9ixmUg=",
version = "v0.1.11-0.20220513221640-090b14e8501f",
)
go_repository(
name = "org_golang_x_xerrors",
Expand Down
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,7 @@ The [community repository](https://github.com/pingcap/community) hosts all infor

[<img src="docs/contribution-map.png" alt="contribution-map" width="180">](https://github.com/pingcap/tidb-map/blob/master/maps/contribution-map.md#tidb-is-an-open-source-distributed-htap-database-compatible-with-the-mysql-protocol)

Contributions are welcomed and greatly appreciated. See [Contribution to TiDB](https://pingcap.github.io/tidb-dev-guide/contribute-to-tidb/introduction.html) for details on typical contribution workflows. For more contributing information, click on the contributor icon above.

## Adopters

View the current list of in-production TiDB adopters [here](https://docs.pingcap.com/tidb/stable/adopters).
Contributions are welcomed and greatly appreciated. All the contributors are welcomed to claim your reward by filing this [form](https://forms.pingcap.com/f/tidb-contribution-swag). See [Contribution to TiDB](https://pingcap.github.io/tidb-dev-guide/contribute-to-tidb/introduction.html) for details on typical contribution workflows. For more contributing information, click on the contributor icon above.

## Case studies

Expand Down
1 change: 1 addition & 0 deletions bindinfo/bind_cache.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ func (c *bindCache) GetAllBindRecords() []*BindRecord {
c.lock.Lock()
defer c.lock.Unlock()
values := c.cache.Values()
//nolint: prealloc
var bindRecords []*BindRecord
for _, vals := range values {
bindRecords = append(bindRecords, vals.([]*BindRecord)...)
Expand Down
2 changes: 1 addition & 1 deletion br/cmd/tidb-lightning-ctl/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,7 @@ func checkpointDump(ctx context.Context, cfg *config.Config, dumpFolder string)
}

func getLocalStoringTables(ctx context.Context, cfg *config.Config) (err2 error) {
//nolint:prealloc // This is a placeholder.
//nolint: prealloc
var tables []string
defer func() {
if err2 == nil {
Expand Down
4 changes: 3 additions & 1 deletion br/pkg/backup/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,9 @@ func (bc *Client) BackupRanges(
progressCallBack func(ProgressUnit),
) error {
init := time.Now()
defer log.Info("Backup Ranges", zap.Duration("take", time.Since(init)))
defer func() {
log.Info("Backup Ranges", zap.Duration("take", time.Since(init)))
}()

if span := opentracing.SpanFromContext(ctx); span != nil && span.Tracer() != nil {
span1 := span.Tracer().StartSpan("Client.BackupRanges", opentracing.ChildOf(span.Context()))
Expand Down
12 changes: 11 additions & 1 deletion br/pkg/errors/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library")
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "errors",
Expand All @@ -7,3 +7,13 @@ go_library(
visibility = ["//visibility:public"],
deps = ["@com_github_pingcap_errors//:errors"],
)

go_test(
name = "errors_test",
srcs = ["errors_test.go"],
deps = [
":errors",
"@com_github_pingcap_errors//:errors",
"@com_github_stretchr_testify//require",
],
)
14 changes: 14 additions & 0 deletions br/pkg/errors/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
package errors

import (
"context"
stderrors "errors"

"github.com/pingcap/errors"
)

Expand All @@ -15,6 +18,17 @@ func Is(err error, is *errors.Error) bool {
return errorFound != nil
}

// IsContextCanceled checks whether the is caused by context.Canceled.
// errors.Cause does not work for the error wrapped by %w in fmt.Errorf.
// So we need to call stderrors.Is to unwrap the error.
func IsContextCanceled(err error) bool {
err = errors.Cause(err)
if err == context.Canceled || err == context.DeadlineExceeded {
return true
}
return stderrors.Is(err, context.Canceled) || stderrors.Is(err, context.DeadlineExceeded)
}

// BR errors.
var (
ErrUnknown = errors.Normalize("internal error", errors.RFCCodeText("BR:Common:ErrUnknown"))
Expand Down
24 changes: 24 additions & 0 deletions br/pkg/errors/errors_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
// Copyright 2022 PingCAP, Inc. Licensed under Apache-2.0.

package errors_test

import (
"context"
"net/url"
"testing"

"github.com/pingcap/errors"
berrors "github.com/pingcap/tidb/br/pkg/errors"
"github.com/stretchr/testify/require"
)

func TestIsContextCanceled(t *testing.T) {
require.False(t, berrors.IsContextCanceled(nil))
require.False(t, berrors.IsContextCanceled(errors.New("connection closed")))
require.True(t, berrors.IsContextCanceled(context.Canceled))
require.True(t, berrors.IsContextCanceled(context.DeadlineExceeded))
require.True(t, berrors.IsContextCanceled(errors.Trace(context.Canceled)))
require.True(t, berrors.IsContextCanceled(errors.Trace(context.DeadlineExceeded)))
require.True(t, berrors.IsContextCanceled(&url.Error{Err: context.Canceled}))
require.True(t, berrors.IsContextCanceled(&url.Error{Err: context.DeadlineExceeded}))
}
1 change: 1 addition & 0 deletions br/pkg/lightning/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ go_test(
"//br/pkg/lightning/checkpoints",
"//br/pkg/lightning/config",
"//br/pkg/lightning/glue",
"//br/pkg/lightning/log",
"//br/pkg/lightning/mydump",
"//br/pkg/lightning/web",
"@com_github_docker_go_units//:go-units",
Expand Down
16 changes: 8 additions & 8 deletions br/pkg/lightning/backend/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ func makeTag(tableName string, engineID int32) string {
return fmt.Sprintf("%s:%d", tableName, engineID)
}

func makeLogger(tag string, engineUUID uuid.UUID) log.Logger {
return log.With(
func makeLogger(logger log.Logger, tag string, engineUUID uuid.UUID) log.Logger {
return logger.With(
zap.String("engineTag", tag),
zap.Stringer("engineUUID", engineUUID),
)
Expand Down Expand Up @@ -143,7 +143,7 @@ type AbstractBackend interface {
ShouldPostProcess() bool

// NewEncoder creates an encoder of a TiDB table.
NewEncoder(tbl table.Table, options *kv.SessionOptions) (kv.Encoder, error)
NewEncoder(ctx context.Context, tbl table.Table, options *kv.SessionOptions) (kv.Encoder, error)

OpenEngine(ctx context.Context, config *EngineConfig, engineUUID uuid.UUID) error

Expand Down Expand Up @@ -260,8 +260,8 @@ func (be Backend) MakeEmptyRows() kv.Rows {
return be.abstract.MakeEmptyRows()
}

func (be Backend) NewEncoder(tbl table.Table, options *kv.SessionOptions) (kv.Encoder, error) {
return be.abstract.NewEncoder(tbl, options)
func (be Backend) NewEncoder(ctx context.Context, tbl table.Table, options *kv.SessionOptions) (kv.Encoder, error) {
return be.abstract.NewEncoder(ctx, tbl, options)
}

func (be Backend) ShouldPostProcess() bool {
Expand Down Expand Up @@ -321,7 +321,7 @@ func (be Backend) UnsafeImportAndReset(ctx context.Context, engineUUID uuid.UUID
closedEngine := ClosedEngine{
engine: engine{
backend: be.abstract,
logger: makeLogger("<import-and-reset>", engineUUID),
logger: makeLogger(log.FromContext(ctx), "<import-and-reset>", engineUUID),
uuid: engineUUID,
},
}
Expand All @@ -334,7 +334,7 @@ func (be Backend) UnsafeImportAndReset(ctx context.Context, engineUUID uuid.UUID
// OpenEngine opens an engine with the given table name and engine ID.
func (be Backend) OpenEngine(ctx context.Context, config *EngineConfig, tableName string, engineID int32) (*OpenedEngine, error) {
tag, engineUUID := MakeUUID(tableName, engineID)
logger := makeLogger(tag, engineUUID)
logger := makeLogger(log.FromContext(ctx), tag, engineUUID)

if err := be.abstract.OpenEngine(ctx, config, engineUUID); err != nil {
return nil, err
Expand Down Expand Up @@ -437,7 +437,7 @@ func (be Backend) UnsafeCloseEngine(ctx context.Context, cfg *EngineConfig, tabl
func (be Backend) UnsafeCloseEngineWithUUID(ctx context.Context, cfg *EngineConfig, tag string, engineUUID uuid.UUID) (*ClosedEngine, error) {
return engine{
backend: be.abstract,
logger: makeLogger(tag, engineUUID),
logger: makeLogger(log.FromContext(ctx), tag, engineUUID),
uuid: engineUUID,
}.unsafeClose(ctx, cfg)
}
Expand Down
4 changes: 2 additions & 2 deletions br/pkg/lightning/backend/backend_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,9 +326,9 @@ func TestNewEncoder(t *testing.T) {

encoder := mock.NewMockEncoder(s.controller)
options := &kv.SessionOptions{SQLMode: mysql.ModeANSIQuotes, Timestamp: 1234567890}
s.mockBackend.EXPECT().NewEncoder(nil, options).Return(encoder, nil)
s.mockBackend.EXPECT().NewEncoder(nil, nil, options).Return(encoder, nil)

realEncoder, err := s.mockBackend.NewEncoder(nil, options)
realEncoder, err := s.mockBackend.NewEncoder(nil, nil, options)
require.Equal(t, realEncoder, encoder)
require.NoError(t, err)
}
Expand Down
Loading

0 comments on commit 11e57df

Please sign in to comment.