Skip to content

Commit

Permalink
br: merge feature branch of ebs-based-br (pingcap#37297)
Browse files Browse the repository at this point in the history
  • Loading branch information
D3Hunter authored Sep 18, 2022
1 parent efc0720 commit 181fb8e
Show file tree
Hide file tree
Showing 58 changed files with 3,196 additions and 67 deletions.
11 changes: 9 additions & 2 deletions DEPS.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ def go_deps():
name = "com_github_aws_aws_sdk_go",
build_file_proto_mode = "disable_global",
importpath = "github.com/aws/aws-sdk-go",
sum = "h1:hAwyfe7eZa7sM+S5mIJZFiNFwJMia9Whz6CYblioLoU=",
version = "v1.36.30",
sum = "h1:jLDC9RsNoYMLFlKpB8LdqUnoDdC2yvkS4QbuyPQJ8+M=",
version = "v1.44.48",
)
go_repository(
name = "com_github_aymerick_raymond",
Expand Down Expand Up @@ -826,6 +826,13 @@ def go_deps():
sum = "h1:G/bYguwHIzWq9ZoyUQqrjTmJbbYn3j3CKKpKinvZLFk=",
version = "v1.0.0",
)
go_repository(
name = "com_github_emirpasic_gods",
build_file_proto_mode = "disable",
importpath = "github.com/emirpasic/gods",
sum = "h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc=",
version = "v1.18.1",
)

go_repository(
name = "com_github_envoyproxy_go_control_plane",
Expand Down
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,9 @@ br_compatibility_test_prepare:
br_compatibility_test:
@cd br && tests/run_compatible.sh run

mock_s3iface:
@mockgen -package mock github.com/aws/aws-sdk-go/service/s3/s3iface S3API > br/pkg/mock/s3iface.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
# cgo enabled on regular builds is performance.
Expand Down
10 changes: 10 additions & 0 deletions br/cmd/br/backup.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,15 @@ func runBackupCommand(command *cobra.Command, cmdName string) error {
ctx, store = trace.TracerStartSpan(ctx)
defer trace.TracerFinishSpan(ctx, store)
}

if cfg.FullBackupType == task.FullBackupTypeEBS {
if err := task.RunBackupEBS(ctx, tidbGlue, &cfg); err != nil {
log.Error("failed to backup", zap.Error(err))
return errors.Trace(err)
}
return nil
}

if cfg.IgnoreStats {
// Do not run stat worker in BR.
session.DisableStats4Test()
Expand Down Expand Up @@ -109,6 +118,7 @@ func newFullBackupCommand() *cobra.Command {
},
}
task.DefineFilterFlags(command, acceptAllTables, false)
task.DefineBackupEBSFlags(command.PersistentFlags())
return command
}

Expand Down
16 changes: 16 additions & 0 deletions br/cmd/br/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,21 @@ func runRestoreCommand(command *cobra.Command, cmdName string) error {
ctx, store = trace.TracerStartSpan(ctx)
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)
}
return nil
}

if err := task.RunRestore(GetDefaultContext(), tidbGlue, cmdName, &cfg); err != nil {
log.Error("failed to restore", zap.Error(err))
printWorkaroundOnFullRestoreError(command, err)
Expand Down Expand Up @@ -128,6 +143,7 @@ func newFullRestoreCommand() *cobra.Command {
},
}
task.DefineFilterFlags(command, filterOutSysAndMemTables, false)
task.DefineRestoreSnapshotFlags(command)
return command
}

Expand Down
29 changes: 29 additions & 0 deletions br/pkg/aws/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")

go_library(
name = "aws",
srcs = ["ebs.go"],
importpath = "github.com/pingcap/tidb/br/pkg/aws",
visibility = ["//visibility:public"],
deps = [
"//br/pkg/config",
"//br/pkg/glue",
"//br/pkg/utils",
"@com_github_aws_aws_sdk_go//aws",
"@com_github_aws_aws_sdk_go//aws/session",
"@com_github_aws_aws_sdk_go//service/ec2",
"@com_github_aws_aws_sdk_go//service/ec2/ec2iface",
"@com_github_pingcap_errors//:errors",
"@com_github_pingcap_log//:log",
"@org_golang_x_sync//errgroup",
"@org_uber_go_atomic//:atomic",
"@org_uber_go_zap//:zap",
],
)

go_test(
name = "aws_test",
srcs = ["ebs_test.go"],
embed = [":aws"],
deps = ["@com_github_stretchr_testify//require"],
)
Loading

0 comments on commit 181fb8e

Please sign in to comment.