Skip to content

Commit

Permalink
Merge branch 'master' of github.com:pingcap/tidb into split_hashjoin_…
Browse files Browse the repository at this point in the history
…part4
  • Loading branch information
XuHuaiyu committed Nov 23, 2022
2 parents 4b9e524 + 65585a5 commit cbedbb7
Show file tree
Hide file tree
Showing 104 changed files with 13,095 additions and 10,158 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,4 @@ bazel-out
bazel-testlogs
bazel-tidb
.ijwb/
/oom_record/
4 changes: 2 additions & 2 deletions DEPS.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -2915,8 +2915,8 @@ def go_deps():
name = "com_github_pingcap_kvproto",
build_file_proto_mode = "disable_global",
importpath = "github.com/pingcap/kvproto",
sum = "h1:ho5XUD8DVCnkpEj8oiTR57FXDTXnH6znyLe0gyrtzKk=",
version = "v0.0.0-20221103025916-e7e21f0e9cd9",
sum = "h1:HyWSOT/drBEtfXK2HLkWWR8dCO+rcf7OiRDRhBxAfU4=",
version = "v0.0.0-20221114102356-3debb6820e46",
)
go_repository(
name = "com_github_pingcap_log",
Expand Down
4 changes: 2 additions & 2 deletions br/pkg/backup/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ type Client struct {
}

// NewBackupClient returns a new backup client.
func NewBackupClient(ctx context.Context, mgr ClientMgr) (*Client, error) {
func NewBackupClient(ctx context.Context, mgr ClientMgr) *Client {
log.Info("new backup client")
pdClient := mgr.GetPDClient()
clusterID := pdClient.GetClusterID(ctx)
return &Client{
clusterID: clusterID,
mgr: mgr,
}, nil
}
}

// GetTS gets a new timestamp from PD.
Expand Down
3 changes: 1 addition & 2 deletions br/pkg/backup/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ func createBackupSuite(t *testing.T) *testBackup {
mockMgr := &conn.Mgr{PdController: &pdutil.PdController{}}
mockMgr.SetPDClient(s.mockPDClient)
mockMgr.SetHTTP([]string{"test"}, nil)
s.backupClient, err = backup.NewBackupClient(s.ctx, mockMgr)
require.NoError(t, err)
s.backupClient = backup.NewBackupClient(s.ctx, mockMgr)

s.cluster, err = mock.NewCluster()
require.NoError(t, err)
Expand Down
6 changes: 6 additions & 0 deletions br/pkg/errors/errors_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,9 @@ func TestIsContextCanceled(t *testing.T) {
require.True(t, berrors.IsContextCanceled(&url.Error{Err: context.Canceled}))
require.True(t, berrors.IsContextCanceled(&url.Error{Err: context.DeadlineExceeded}))
}

func TestEqual(t *testing.T) {
err := errors.Annotate(berrors.ErrPDBatchScanRegion, "test error equla")
r := berrors.ErrPDBatchScanRegion.Equal(err)
require.True(t, r)
}
14 changes: 10 additions & 4 deletions br/pkg/gluetidb/glue.go
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,8 @@ func (gs *tidbSession) showCreatePlacementPolicy(policy *model.PolicyInfo) strin

// mockSession is used for test.
type mockSession struct {
se session.Session
se session.Session
globalVars map[string]string
}

// GetSessionCtx implements glue.Glue
Expand Down Expand Up @@ -368,12 +369,16 @@ func (s *mockSession) Close() {

// GetGlobalVariables implements glue.Session.
func (s *mockSession) GetGlobalVariable(name string) (string, error) {
return "true", nil
if ret, ok := s.globalVars[name]; ok {
return ret, nil
}
return "True", nil
}

// MockGlue only used for test
type MockGlue struct {
se session.Session
se session.Session
GlobalVars map[string]string
}

func (m *MockGlue) SetSession(se session.Session) {
Expand All @@ -388,7 +393,8 @@ func (*MockGlue) GetDomain(store kv.Storage) (*domain.Domain, error) {
// CreateSession implements glue.Glue.
func (m *MockGlue) CreateSession(store kv.Storage) (glue.Session, error) {
glueSession := &mockSession{
se: m.se,
se: m.se,
globalVars: m.GlobalVars,
}
return glueSession, nil
}
Expand Down
8 changes: 8 additions & 0 deletions br/pkg/lightning/lightning.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ type Lightning struct {

promFactory promutil.Factory
promRegistry promutil.Registry
metrics *metric.Metrics

cancelLock sync.Mutex
curTask *config.Config
Expand Down Expand Up @@ -388,6 +389,7 @@ func (l *Lightning) run(taskCtx context.Context, taskCfg *config.Config, o *opti
defer func() {
metrics.UnregisterFrom(o.promRegistry)
}()
l.metrics = metrics

ctx := metric.NewContext(taskCtx, metrics)
ctx = log.NewContext(ctx, o.logger)
Expand Down Expand Up @@ -544,6 +546,12 @@ func (l *Lightning) Status() (finished int64, total int64) {
return
}

// Metrics returns the metrics of lightning.
// it's inited during `run`, so might return nil.
func (l *Lightning) Metrics() *metric.Metrics {
return l.metrics
}

func writeJSONError(w http.ResponseWriter, code int, prefix string, err error) {
type errorResponse struct {
Error string `json:"error"`
Expand Down
2 changes: 2 additions & 0 deletions br/pkg/restore/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ go_library(
"//br/pkg/summary",
"//br/pkg/utils",
"//br/pkg/utils/iter",
"//br/pkg/version",
"//config",
"//ddl",
"//ddl/util",
Expand All @@ -57,6 +58,7 @@ go_library(
"//tablecodec",
"//util",
"//util/codec",
"//util/collate",
"//util/hack",
"//util/mathutil",
"//util/table-filter",
Expand Down
Loading

0 comments on commit cbedbb7

Please sign in to comment.