Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

br, lightning: call memory hook init in main() (#49843) #49854

Open
wants to merge 1 commit into
base: release-5.4
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 64 additions & 0 deletions br/cmd/br/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test")

go_library(
name = "br_lib",
srcs = [
"backup.go",
"cmd.go",
"debug.go",
"main.go",
"operator.go",
"restore.go",
"stream.go",
],
importpath = "github.com/pingcap/tidb/br/cmd/br",
visibility = ["//visibility:private"],
deps = [
"//br/pkg/conn",
"//br/pkg/errors",
"//br/pkg/gluetidb",
"//br/pkg/gluetikv",
"//br/pkg/logutil",
"//br/pkg/metautil",
"//br/pkg/mock/mockid",
"//br/pkg/redact",
"//br/pkg/restore",
"//br/pkg/rtree",
"//br/pkg/streamhelper/config",
"//br/pkg/summary",
"//br/pkg/task",
"//br/pkg/task/operator",
"//br/pkg/trace",
"//br/pkg/utils",
"//br/pkg/version/build",
"//pkg/config",
"//pkg/parser/model",
"//pkg/session",
"//pkg/util",
"//pkg/util/logutil",
"//pkg/util/memory",
"//pkg/util/metricsutil",
"@com_github_gogo_protobuf//proto",
"@com_github_pingcap_errors//:errors",
"@com_github_pingcap_kvproto//pkg/brpb",
"@com_github_pingcap_kvproto//pkg/import_sstpb",
"@com_github_pingcap_log//:log",
"@com_github_spf13_cobra//:cobra",
"@com_sourcegraph_sourcegraph_appdash//:appdash",
"@org_uber_go_zap//:zap",
],
)

go_binary(
name = "br",
embed = [":br_lib"],
visibility = ["//visibility:public"],
)

go_test(
name = "br_test",
timeout = "short",
srcs = ["main_test.go"],
embed = [":br_lib"],
flaky = True,
)
8 changes: 8 additions & 0 deletions br/cmd/br/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,14 @@ import (
"github.com/pingcap/tidb/br/pkg/task"
"github.com/pingcap/tidb/br/pkg/utils"
"github.com/pingcap/tidb/br/pkg/version/build"
<<<<<<< HEAD
"github.com/pingcap/tidb/util/logutil"
=======
"github.com/pingcap/tidb/pkg/config"
tidbutils "github.com/pingcap/tidb/pkg/util"
"github.com/pingcap/tidb/pkg/util/logutil"
"github.com/pingcap/tidb/pkg/util/memory"
>>>>>>> d0d24aeef42 (br, lightning: call memory hook init in main() (#49843))
"github.com/spf13/cobra"
)

Expand Down Expand Up @@ -151,6 +158,7 @@ func Init(cmd *cobra.Command) (err error) {
return
}
log.ReplaceGlobals(lg, p)
memory.InitMemoryHook()

redactLog, e := cmd.Flags().GetBool(FlagRedactLog)
if e != nil {
Expand Down
31 changes: 31 additions & 0 deletions br/cmd/tidb-lightning/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
load("@io_bazel_rules_go//go:def.bzl", "go_binary", "go_library", "go_test")

go_library(
name = "tidb-lightning_lib",
srcs = ["main.go"],
importpath = "github.com/pingcap/tidb/br/cmd/tidb-lightning",
visibility = ["//visibility:private"],
deps = [
"//br/pkg/lightning",
"//br/pkg/lightning/common",
"//br/pkg/lightning/config",
"//br/pkg/lightning/log",
"//br/pkg/lightning/web",
"//pkg/util/memory",
"@org_uber_go_zap//:zap",
],
)

go_binary(
name = "tidb-lightning",
embed = [":tidb-lightning_lib"],
visibility = ["//visibility:public"],
)

go_test(
name = "tidb-lightning_test",
timeout = "short",
srcs = ["main_test.go"],
embed = [":tidb-lightning_lib"],
flaky = True,
)
6 changes: 6 additions & 0 deletions br/cmd/tidb-lightning/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ import (
"github.com/pingcap/tidb/br/pkg/lightning/common"
"github.com/pingcap/tidb/br/pkg/lightning/config"
"github.com/pingcap/tidb/br/pkg/lightning/log"
<<<<<<< HEAD
=======
"github.com/pingcap/tidb/br/pkg/lightning/web"
"github.com/pingcap/tidb/pkg/util/memory"
>>>>>>> d0d24aeef42 (br, lightning: call memory hook init in main() (#49843))
"go.uber.org/zap"
)

Expand All @@ -37,6 +42,7 @@ func main() {
}

app := lightning.New(globalCfg)
memory.InitMemoryHook()

sc := make(chan os.Signal, 1)
signal.Notify(sc,
Expand Down