From 8ecc2c8b5e506752129c59fcd5658bbb965dc576 Mon Sep 17 00:00:00 2001 From: pingcap-github-bot Date: Thu, 12 Dec 2019 11:53:22 +0800 Subject: [PATCH] dm-portal: don't generate table list for mydumper if DoTables is empty (#419) (#421) --- dm/portal/api.go | 7 ++++++- dm/portal/api_test.go | 4 ++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/dm/portal/api.go b/dm/portal/api.go index e88f1a7587..6fd73910aa 100644 --- a/dm/portal/api.go +++ b/dm/portal/api.go @@ -563,12 +563,17 @@ func generateMydumperCfg(bwList *filter.Rules) *config.MydumperConfig { tables = append(tables, fmt.Sprintf("%s.%s", table.Schema, table.Name)) } + extraArgs := "" + if len(tables) != 0 { + extraArgs = fmt.Sprintf("-T %s", strings.Join(tables, ",")) + } + return &config.MydumperConfig{ MydumperPath: "bin/mydumper", Threads: 4, ChunkFilesize: 64, SkipTzUTC: true, - ExtraArgs: fmt.Sprintf("-T %s", strings.Join(tables, ",")), + ExtraArgs: extraArgs, } } diff --git a/dm/portal/api_test.go b/dm/portal/api_test.go index 2f468d4964..2d3ba0647b 100644 --- a/dm/portal/api_test.go +++ b/dm/portal/api_test.go @@ -329,6 +329,10 @@ func (t *testPortalSuite) TestGenerateMydumperTableCfg(c *C) { } mydumperCfg := generateMydumperCfg(bwList) c.Assert(mydumperCfg.ExtraArgs, Equals, "-T db_1.t_1,db_1.t_2") + + bwList = &filter.Rules{} + mydumperCfg = generateMydumperCfg(bwList) + c.Assert(mydumperCfg.ExtraArgs, Equals, "") } func (t *testPortalSuite) TestGenerateMydumperCfgName(c *C) {