From ae69e0f0c2d63fd1ed6ecfea4a83e7b34d51899d Mon Sep 17 00:00:00 2001 From: GMHDBJD <35025882+GMHDBJD@users.noreply.github.com> Date: Fri, 19 Jun 2020 03:31:58 -0700 Subject: [PATCH] error_message: remove stack error message (#746) (#754) --- dm/ctl/common/util.go | 6 +-- dm/ctl/master/break_ddl_lock.go | 11 +++--- dm/ctl/master/check_task.go | 5 +-- dm/ctl/master/migrate_relay.go | 3 +- dm/ctl/master/pause_relay.go | 5 +-- dm/ctl/master/pause_task.go | 5 +-- dm/ctl/master/purge_relay.go | 4 +- dm/ctl/master/query_error.go | 5 +-- dm/ctl/master/query_status.go | 7 ++-- dm/ctl/master/refresh_worker_tasks.go | 3 +- dm/ctl/master/resume_relay.go | 5 +-- dm/ctl/master/resume_task.go | 5 +-- dm/ctl/master/show_ddl_locks.go | 5 +-- dm/ctl/master/sql_inject.go | 9 ++--- dm/ctl/master/sql_replace.go | 7 ++-- dm/ctl/master/sql_skip.go | 5 +-- dm/ctl/master/start_task.go | 7 ++-- dm/ctl/master/stop_task.go | 5 +-- dm/ctl/master/switch_relay_master.go | 5 +-- dm/ctl/master/unlock_ddl_lock.go | 10 ++--- dm/ctl/master/update_masterconfig.go | 5 +-- dm/ctl/master/update_relay.go | 5 +-- dm/ctl/master/update_task.go | 7 ++-- dm/master/server.go | 53 +++++++++++++-------------- dm/tracer/server.go | 5 +-- dm/worker/server.go | 9 ++--- 26 files changed, 88 insertions(+), 113 deletions(-) diff --git a/dm/ctl/common/util.go b/dm/ctl/common/util.go index a2ac08bdea..5c0db201c5 100644 --- a/dm/ctl/common/util.go +++ b/dm/ctl/common/util.go @@ -72,7 +72,7 @@ func PrintLines(format string, a ...interface{}) { func PrettyPrintResponse(resp proto.Message) { s, err := marshResponseToString(resp) if err != nil { - PrintLines(errors.ErrorStack(err)) + PrintLines("%v", err) } else { fmt.Println(s) } @@ -82,7 +82,7 @@ func PrettyPrintResponse(resp proto.Message) { func PrettyPrintInterface(resp interface{}) { s, err := json.MarshalIndent(resp, "", " ") if err != nil { - PrintLines(errors.ErrorStack(err)) + PrintLines("%v", err) } else { fmt.Println(string(s)) } @@ -147,7 +147,7 @@ func PrettyPrintResponseWithCheckTask(resp proto.Message, subStr string) bool { } if err != nil { - fmt.Println(errors.ErrorStack(err)) + PrintLines("%v", err) } else { // add indent to make it prettily. replacedStr = strings.Replace(replacedStr, "detail: {", " \tdetail: {", 1) diff --git a/dm/ctl/master/break_ddl_lock.go b/dm/ctl/master/break_ddl_lock.go index bd27999de5..f8d2d38977 100644 --- a/dm/ctl/master/break_ddl_lock.go +++ b/dm/ctl/master/break_ddl_lock.go @@ -21,7 +21,6 @@ import ( "github.com/pingcap/dm/dm/ctl/common" "github.com/pingcap/dm/dm/pb" - "github.com/pingcap/errors" "github.com/spf13/cobra" ) @@ -49,7 +48,7 @@ func breakDDLLockFunc(cmd *cobra.Command, _ []string) { workers, err := common.GetWorkerArgs(cmd) if err != nil { - fmt.Println(errors.ErrorStack(err)) + common.PrintLines("%v", err) return } if len(workers) == 0 { @@ -59,19 +58,19 @@ func breakDDLLockFunc(cmd *cobra.Command, _ []string) { removeLockID, err := cmd.Flags().GetString("remove-id") if err != nil { - fmt.Println(errors.ErrorStack(err)) + common.PrintLines("%v", err) return } exec, err := cmd.Flags().GetBool("exec") if err != nil { - fmt.Println(errors.ErrorStack(err)) + common.PrintLines("%v", err) return } skip, err := cmd.Flags().GetBool("skip") if err != nil { - fmt.Println(errors.ErrorStack(err)) + common.PrintLines("%v", err) return } @@ -96,7 +95,7 @@ func breakDDLLockFunc(cmd *cobra.Command, _ []string) { SkipDDL: skip, }) if err != nil { - common.PrintLines("can not break DDL lock (in workers %v):\n%s", workers, errors.ErrorStack(err)) + common.PrintLines("can not break DDL lock (in workers %v):\n%v", workers, err) return } diff --git a/dm/ctl/master/check_task.go b/dm/ctl/master/check_task.go index ef4b49c40b..c73fb26fac 100644 --- a/dm/ctl/master/check_task.go +++ b/dm/ctl/master/check_task.go @@ -17,7 +17,6 @@ import ( "context" "os" - "github.com/pingcap/errors" "github.com/spf13/cobra" "github.com/pingcap/dm/checker" @@ -44,7 +43,7 @@ func checkTaskFunc(cmd *cobra.Command, _ []string) { } content, err := common.GetFileContent(cmd.Flags().Arg(0)) if err != nil { - common.PrintLines("get file content error:\n%v", errors.ErrorStack(err)) + common.PrintLines("get file content error:\n%v", err) return } @@ -57,7 +56,7 @@ func checkTaskFunc(cmd *cobra.Command, _ []string) { Task: string(content), }) if err != nil { - common.PrintLines("fail to check task:\n%v", errors.ErrorStack(err)) + common.PrintLines("fail to check task:\n%v", err) return } diff --git a/dm/ctl/master/migrate_relay.go b/dm/ctl/master/migrate_relay.go index c9d1679c1d..7a0c3d1311 100644 --- a/dm/ctl/master/migrate_relay.go +++ b/dm/ctl/master/migrate_relay.go @@ -18,7 +18,6 @@ import ( "os" "strconv" - "github.com/pingcap/errors" "github.com/spf13/cobra" "go.uber.org/zap" @@ -49,7 +48,7 @@ func migrateRelayFunc(cmd *cobra.Command, _ []string) { binlogName := cmd.Flags().Arg(1) binlogPos, err := strconv.Atoi(cmd.Flags().Arg(2)) if err != nil { - common.PrintLines(errors.ErrorStack(err)) + common.PrintLines("%v", err) } ctx, cancel := context.WithCancel(context.Background()) diff --git a/dm/ctl/master/pause_relay.go b/dm/ctl/master/pause_relay.go index 184d0c746b..1d9d50800d 100644 --- a/dm/ctl/master/pause_relay.go +++ b/dm/ctl/master/pause_relay.go @@ -17,7 +17,6 @@ import ( "fmt" "os" - "github.com/pingcap/errors" "github.com/spf13/cobra" "github.com/pingcap/dm/dm/ctl/common" @@ -44,7 +43,7 @@ func pauseRelayFunc(cmd *cobra.Command, _ []string) { workers, err := common.GetWorkerArgs(cmd) if err != nil { - common.PrintLines("%s", errors.ErrorStack(err)) + common.PrintLines("%v", err) return } if len(workers) == 0 { @@ -54,7 +53,7 @@ func pauseRelayFunc(cmd *cobra.Command, _ []string) { resp, err := common.OperateRelay(pb.RelayOp_PauseRelay, workers) if err != nil { - common.PrintLines("can not pause relay unit:\n%v", errors.ErrorStack(err)) + common.PrintLines("can not pause relay unit:\n%v", err) return } diff --git a/dm/ctl/master/pause_task.go b/dm/ctl/master/pause_task.go index 6739a6b098..9d9dc3326c 100644 --- a/dm/ctl/master/pause_task.go +++ b/dm/ctl/master/pause_task.go @@ -16,7 +16,6 @@ package master import ( "os" - "github.com/pingcap/errors" "github.com/spf13/cobra" "github.com/pingcap/dm/dm/ctl/common" @@ -44,13 +43,13 @@ func pauseTaskFunc(cmd *cobra.Command, _ []string) { workers, err := common.GetWorkerArgs(cmd) if err != nil { - common.PrintLines("%s", errors.ErrorStack(err)) + common.PrintLines("%v", err) return } resp, err := common.OperateTask(pb.TaskOp_Pause, name, workers) if err != nil { - common.PrintLines("can not pause task %s:\n%v", name, errors.ErrorStack(err)) + common.PrintLines("can not pause task %s:\n%v", name, err) return } diff --git a/dm/ctl/master/purge_relay.go b/dm/ctl/master/purge_relay.go index 5aca31997c..a79f23fa9f 100644 --- a/dm/ctl/master/purge_relay.go +++ b/dm/ctl/master/purge_relay.go @@ -63,7 +63,7 @@ func purgeRelayFunc(cmd *cobra.Command, _ []string) { workers, err := common.GetWorkerArgs(cmd) if err != nil { - fmt.Println(errors.ErrorStack(err)) + common.PrintLines("%v", err) return } if len(workers) == 0 { @@ -145,7 +145,7 @@ func purgeRelayFunc(cmd *cobra.Command, _ []string) { SubDir: subDir, }) if err != nil { - common.PrintLines("can not purge relay log files: \n%s", errors.ErrorStack(err)) + common.PrintLines("can not purge relay log files: \n%v", err) return } diff --git a/dm/ctl/master/query_error.go b/dm/ctl/master/query_error.go index 9c04f4798c..29acc3235f 100644 --- a/dm/ctl/master/query_error.go +++ b/dm/ctl/master/query_error.go @@ -19,7 +19,6 @@ import ( "github.com/pingcap/dm/dm/ctl/common" "github.com/pingcap/dm/dm/pb" - "github.com/pingcap/dm/pkg/terror" "github.com/spf13/cobra" ) @@ -45,7 +44,7 @@ func queryErrorFunc(cmd *cobra.Command, _ []string) { workers, err := common.GetWorkerArgs(cmd) if err != nil { - common.PrintLines("%s", terror.Message(err)) + common.PrintLines("%v", err) return } @@ -64,7 +63,7 @@ func queryErrorFunc(cmd *cobra.Command, _ []string) { if len(workers) > 0 { common.PrintLines("workers: %v", workers) } - common.PrintLines("error: %s", terror.Message(err)) + common.PrintLines("error: %v", err) return } diff --git a/dm/ctl/master/query_status.go b/dm/ctl/master/query_status.go index 3ebf6da1e2..9cfd15df3e 100644 --- a/dm/ctl/master/query_status.go +++ b/dm/ctl/master/query_status.go @@ -22,7 +22,6 @@ import ( "github.com/pingcap/dm/dm/ctl/common" "github.com/pingcap/dm/dm/pb" - "github.com/pingcap/dm/pkg/terror" ) const stageError = "Error" @@ -61,7 +60,7 @@ func queryStatusFunc(cmd *cobra.Command, _ []string) { workers, err := common.GetWorkerArgs(cmd) if err != nil { - common.PrintLines("%s", terror.Message(err)) + common.PrintLines("%v", err) return } @@ -73,13 +72,13 @@ func queryStatusFunc(cmd *cobra.Command, _ []string) { Workers: workers, }) if err != nil { - common.PrintLines("can not query %s task's status(in workers %v):\n%s", taskName, workers, terror.Message(err)) + common.PrintLines("can not query %s task's status(in workers %v):\n%v", taskName, workers, err) return } more, err := cmd.Flags().GetBool("more") if err != nil { - common.PrintLines("%s", terror.Message(err)) + common.PrintLines("%v", err) return } diff --git a/dm/ctl/master/refresh_worker_tasks.go b/dm/ctl/master/refresh_worker_tasks.go index 5dfb234363..ab44b7d217 100644 --- a/dm/ctl/master/refresh_worker_tasks.go +++ b/dm/ctl/master/refresh_worker_tasks.go @@ -20,7 +20,6 @@ import ( "github.com/pingcap/dm/dm/ctl/common" "github.com/pingcap/dm/dm/pb" - "github.com/pingcap/errors" "github.com/spf13/cobra" ) @@ -47,7 +46,7 @@ func refreshWorkerTasksFunc(cmd *cobra.Command, _ []string) { cli := common.MasterClient() resp, err := cli.RefreshWorkerTasks(ctx, &pb.RefreshWorkerTasksRequest{}) if err != nil { - common.PrintLines("can not refresh workerTasks:\n%v", errors.ErrorStack(err)) + common.PrintLines("can not refresh workerTasks:\n%v", err) return } diff --git a/dm/ctl/master/resume_relay.go b/dm/ctl/master/resume_relay.go index 8f9563c2e3..55a7b7bff1 100644 --- a/dm/ctl/master/resume_relay.go +++ b/dm/ctl/master/resume_relay.go @@ -17,7 +17,6 @@ import ( "fmt" "os" - "github.com/pingcap/errors" "github.com/spf13/cobra" "github.com/pingcap/dm/dm/ctl/common" @@ -44,7 +43,7 @@ func resumeRelayFunc(cmd *cobra.Command, _ []string) { workers, err := common.GetWorkerArgs(cmd) if err != nil { - common.PrintLines("%s", errors.ErrorStack(err)) + common.PrintLines("%v", err) return } if len(workers) == 0 { @@ -54,7 +53,7 @@ func resumeRelayFunc(cmd *cobra.Command, _ []string) { resp, err := common.OperateRelay(pb.RelayOp_ResumeRelay, workers) if err != nil { - common.PrintLines("can not resume relay unit:\n%v", errors.ErrorStack(err)) + common.PrintLines("can not resume relay unit:\n%v", err) return } diff --git a/dm/ctl/master/resume_task.go b/dm/ctl/master/resume_task.go index 85383647e2..5deda3ce4b 100644 --- a/dm/ctl/master/resume_task.go +++ b/dm/ctl/master/resume_task.go @@ -16,7 +16,6 @@ package master import ( "os" - "github.com/pingcap/errors" "github.com/spf13/cobra" "github.com/pingcap/dm/dm/ctl/common" @@ -44,13 +43,13 @@ func resumeTaskFunc(cmd *cobra.Command, _ []string) { workers, err := common.GetWorkerArgs(cmd) if err != nil { - common.PrintLines("%s", errors.ErrorStack(err)) + common.PrintLines("%v", err) return } resp, err := common.OperateTask(pb.TaskOp_Resume, name, workers) if err != nil { - common.PrintLines("can not resume task %s:\n%v", name, errors.ErrorStack(err)) + common.PrintLines("can not resume task %s:\n%v", name, err) return } diff --git a/dm/ctl/master/show_ddl_locks.go b/dm/ctl/master/show_ddl_locks.go index a01eddc76f..48daa01748 100644 --- a/dm/ctl/master/show_ddl_locks.go +++ b/dm/ctl/master/show_ddl_locks.go @@ -20,7 +20,6 @@ import ( "github.com/pingcap/dm/dm/ctl/common" "github.com/pingcap/dm/dm/pb" - "github.com/pingcap/errors" "github.com/spf13/cobra" ) @@ -45,7 +44,7 @@ func showDDLLocksFunc(cmd *cobra.Command, _ []string) { workers, err := common.GetWorkerArgs(cmd) if err != nil { - common.PrintLines("%s", errors.ErrorStack(err)) + common.PrintLines("%v", err) return } @@ -57,7 +56,7 @@ func showDDLLocksFunc(cmd *cobra.Command, _ []string) { Workers: workers, }) if err != nil { - common.PrintLines("can not show DDL locks for task %s and workers %v:\n%s", taskName, workers, errors.ErrorStack(err)) + common.PrintLines("can not show DDL locks for task %s and workers %v:\n%v", taskName, workers, err) return } diff --git a/dm/ctl/master/sql_inject.go b/dm/ctl/master/sql_inject.go index bde0644e3e..448b3e4b1c 100644 --- a/dm/ctl/master/sql_inject.go +++ b/dm/ctl/master/sql_inject.go @@ -18,7 +18,6 @@ import ( "os" "strings" - "github.com/pingcap/errors" "github.com/spf13/cobra" "github.com/pingcap/dm/dm/ctl/common" @@ -45,7 +44,7 @@ func sqlInjectFunc(cmd *cobra.Command, _ []string) { workers, err := common.GetWorkerArgs(cmd) if err != nil { - common.PrintLines("%s", errors.ErrorStack(err)) + common.PrintLines("%v", err) return } if len(workers) != 1 { @@ -62,13 +61,13 @@ func sqlInjectFunc(cmd *cobra.Command, _ []string) { extraArgs := cmd.Flags().Args()[1:] realSQLs, err := common.ExtractSQLsFromArgs(extraArgs) if err != nil { - common.PrintLines("check sqls err %s", errors.ErrorStack(err)) + common.PrintLines("check sqls err %v", err) return } for _, sql := range realSQLs { isDDL, err2 := common.IsDDL(sql) if err2 != nil { - common.PrintLines("check sql err %s", errors.ErrorStack(err2)) + common.PrintLines("check sql err %v", err2) return } if !isDDL { @@ -87,7 +86,7 @@ func sqlInjectFunc(cmd *cobra.Command, _ []string) { Worker: workers[0], }) if err != nil { - common.PrintLines("can not inject sql:\n%v", errors.ErrorStack(err)) + common.PrintLines("can not inject sql:\n%v", err) return } diff --git a/dm/ctl/master/sql_replace.go b/dm/ctl/master/sql_replace.go index 2860c887d5..f9f91988b8 100644 --- a/dm/ctl/master/sql_replace.go +++ b/dm/ctl/master/sql_replace.go @@ -21,7 +21,6 @@ import ( "github.com/pingcap/dm/dm/ctl/common" "github.com/pingcap/dm/dm/pb" - "github.com/pingcap/errors" "github.com/spf13/cobra" ) @@ -55,7 +54,7 @@ func sqlReplaceFunc(cmd *cobra.Command, _ []string) { var worker string workers, err := common.GetWorkerArgs(cmd) if err != nil { - common.PrintLines("%s", errors.ErrorStack(err)) + common.PrintLines("%v", err) return } if sharding { @@ -79,7 +78,7 @@ func sqlReplaceFunc(cmd *cobra.Command, _ []string) { extraArgs := cmd.Flags().Args()[1:] realSQLs, err := common.ExtractSQLsFromArgs(extraArgs) if err != nil { - common.PrintLines("check SQLs error: %s", errors.ErrorStack(err)) + common.PrintLines("check SQLs error: %v", err) return } @@ -96,7 +95,7 @@ func sqlReplaceFunc(cmd *cobra.Command, _ []string) { Sharding: sharding, }) if err != nil { - common.PrintLines("can not replace SQL:\n%v", errors.ErrorStack(err)) + common.PrintLines("can not replace SQL:\n%v", err) return } diff --git a/dm/ctl/master/sql_skip.go b/dm/ctl/master/sql_skip.go index adbd067ccd..080b6c7f98 100644 --- a/dm/ctl/master/sql_skip.go +++ b/dm/ctl/master/sql_skip.go @@ -18,7 +18,6 @@ import ( "os" "strings" - "github.com/pingcap/errors" "github.com/spf13/cobra" "github.com/pingcap/dm/dm/ctl/common" @@ -55,7 +54,7 @@ func sqlSkipFunc(cmd *cobra.Command, _ []string) { var worker string workers, err := common.GetWorkerArgs(cmd) if err != nil { - common.PrintLines("%s", errors.ErrorStack(err)) + common.PrintLines("%v", err) return } if sharding { @@ -89,7 +88,7 @@ func sqlSkipFunc(cmd *cobra.Command, _ []string) { Sharding: sharding, }) if err != nil { - common.PrintLines("can not skip SQL:\n%v", errors.ErrorStack(err)) + common.PrintLines("can not skip SQL:\n%v", err) return } diff --git a/dm/ctl/master/start_task.go b/dm/ctl/master/start_task.go index b072eaff81..13576fea15 100644 --- a/dm/ctl/master/start_task.go +++ b/dm/ctl/master/start_task.go @@ -17,7 +17,6 @@ import ( "context" "os" - "github.com/pingcap/errors" "github.com/spf13/cobra" "github.com/pingcap/dm/checker" @@ -44,13 +43,13 @@ func startTaskFunc(cmd *cobra.Command, _ []string) { } content, err := common.GetFileContent(cmd.Flags().Arg(0)) if err != nil { - common.PrintLines("get file content error:\n%v", errors.ErrorStack(err)) + common.PrintLines("get file content error:\n%v", err) return } workers, err := common.GetWorkerArgs(cmd) if err != nil { - common.PrintLines("%s", errors.ErrorStack(err)) + common.PrintLines("%v", err) return } @@ -64,7 +63,7 @@ func startTaskFunc(cmd *cobra.Command, _ []string) { Workers: workers, }) if err != nil { - common.PrintLines("can not start task:\n%v", errors.ErrorStack(err)) + common.PrintLines("can not start task:\n%v", err) return } diff --git a/dm/ctl/master/stop_task.go b/dm/ctl/master/stop_task.go index bf23d59f2e..35df34aee9 100644 --- a/dm/ctl/master/stop_task.go +++ b/dm/ctl/master/stop_task.go @@ -16,7 +16,6 @@ package master import ( "os" - "github.com/pingcap/errors" "github.com/spf13/cobra" "github.com/pingcap/dm/dm/ctl/common" @@ -44,13 +43,13 @@ func stopTaskFunc(cmd *cobra.Command, _ []string) { workers, err := common.GetWorkerArgs(cmd) if err != nil { - common.PrintLines("%s", errors.ErrorStack(err)) + common.PrintLines("%v", err) return } resp, err := common.OperateTask(pb.TaskOp_Stop, name, workers) if err != nil { - common.PrintLines("can not stop task %s:\n%v", name, errors.ErrorStack(err)) + common.PrintLines("can not stop task %s:\n%v", name, err) return } diff --git a/dm/ctl/master/switch_relay_master.go b/dm/ctl/master/switch_relay_master.go index bbdd6b1305..4438ad2d54 100644 --- a/dm/ctl/master/switch_relay_master.go +++ b/dm/ctl/master/switch_relay_master.go @@ -18,7 +18,6 @@ import ( "fmt" "os" - "github.com/pingcap/errors" "github.com/spf13/cobra" "github.com/pingcap/dm/dm/ctl/common" @@ -45,7 +44,7 @@ func switchRelayMasterFunc(cmd *cobra.Command, _ []string) { workers, err := common.GetWorkerArgs(cmd) if err != nil { - fmt.Println(errors.ErrorStack(err)) + common.PrintLines("%v", err) return } if len(workers) == 0 { @@ -60,7 +59,7 @@ func switchRelayMasterFunc(cmd *cobra.Command, _ []string) { Workers: workers, }) if err != nil { - common.PrintLines("can not switch relay's master server (in workers %v):\n%s", workers, errors.ErrorStack(err)) + common.PrintLines("can not switch relay's master server (in workers %v):\n%v", workers, err) return } diff --git a/dm/ctl/master/unlock_ddl_lock.go b/dm/ctl/master/unlock_ddl_lock.go index 948f8c2bc4..d7e93cdcf8 100644 --- a/dm/ctl/master/unlock_ddl_lock.go +++ b/dm/ctl/master/unlock_ddl_lock.go @@ -15,13 +15,11 @@ package master import ( "context" - "fmt" "os" "github.com/pingcap/dm/dm/ctl/common" "github.com/pingcap/dm/dm/pb" - "github.com/pingcap/errors" "github.com/spf13/cobra" ) @@ -46,7 +44,7 @@ func unlockDDLLockFunc(cmd *cobra.Command, _ []string) { } owner, err := cmd.Flags().GetString("owner") if err != nil { - fmt.Println(errors.ErrorStack(err)) + common.PrintLines("%v", err) return } @@ -54,13 +52,13 @@ func unlockDDLLockFunc(cmd *cobra.Command, _ []string) { workers, err := common.GetWorkerArgs(cmd) if err != nil { - fmt.Println(errors.ErrorStack(err)) + common.PrintLines("%v", err) return } forceRemove, err := cmd.Flags().GetBool("force-remove") if err != nil { - fmt.Println(errors.ErrorStack(err)) + common.PrintLines("%v", err) return } @@ -74,7 +72,7 @@ func unlockDDLLockFunc(cmd *cobra.Command, _ []string) { ForceRemove: forceRemove, }) if err != nil { - common.PrintLines("can not unlock DDL lock %s (in workers %v):\n%s", lockID, workers, errors.ErrorStack(err)) + common.PrintLines("can not unlock DDL lock %s (in workers %v):\n%v", lockID, workers, err) return } diff --git a/dm/ctl/master/update_masterconfig.go b/dm/ctl/master/update_masterconfig.go index 9a533d6895..1ddf9621bf 100644 --- a/dm/ctl/master/update_masterconfig.go +++ b/dm/ctl/master/update_masterconfig.go @@ -20,7 +20,6 @@ import ( "github.com/pingcap/dm/dm/ctl/common" "github.com/pingcap/dm/dm/pb" - "github.com/pingcap/errors" "github.com/spf13/cobra" ) @@ -42,7 +41,7 @@ func updateMasterConfigFunc(cmd *cobra.Command, _ []string) { } content, err := common.GetFileContent(cmd.Flags().Arg(0)) if err != nil { - common.PrintLines("get file content error:\n%v", errors.ErrorStack(err)) + common.PrintLines("get file content error:\n%v", err) return } @@ -54,7 +53,7 @@ func updateMasterConfigFunc(cmd *cobra.Command, _ []string) { Config: string(content), }) if err != nil { - common.PrintLines("can not update master config:\n%v", errors.ErrorStack(err)) + common.PrintLines("can not update master config:\n%v", err) return } diff --git a/dm/ctl/master/update_relay.go b/dm/ctl/master/update_relay.go index 09ffd3ed44..1980535836 100644 --- a/dm/ctl/master/update_relay.go +++ b/dm/ctl/master/update_relay.go @@ -18,7 +18,6 @@ import ( "fmt" "os" - "github.com/pingcap/errors" "github.com/spf13/cobra" "github.com/pingcap/dm/dm/ctl/common" @@ -45,7 +44,7 @@ func updateRelayFunc(cmd *cobra.Command, _ []string) { content, err := common.GetFileContent(cmd.Flags().Arg(0)) if err != nil { - common.PrintLines("get file content error:\n%v", errors.ErrorStack(err)) + common.PrintLines("get file content error:\n%v", err) return } @@ -65,7 +64,7 @@ func updateRelayFunc(cmd *cobra.Command, _ []string) { }) if err != nil { - common.PrintLines("can not update relay config:\n%v", errors.ErrorStack(err)) + common.PrintLines("can not update relay config:\n%v", err) return } diff --git a/dm/ctl/master/update_task.go b/dm/ctl/master/update_task.go index e0fd88db28..b9c535f641 100644 --- a/dm/ctl/master/update_task.go +++ b/dm/ctl/master/update_task.go @@ -17,7 +17,6 @@ import ( "context" "os" - "github.com/pingcap/errors" "github.com/spf13/cobra" "github.com/pingcap/dm/checker" @@ -44,13 +43,13 @@ func updateTaskFunc(cmd *cobra.Command, _ []string) { } content, err := common.GetFileContent(cmd.Flags().Arg(0)) if err != nil { - common.PrintLines("get file content error:\n%v", errors.ErrorStack(err)) + common.PrintLines("get file content error:\n%v", err) return } workers, err := common.GetWorkerArgs(cmd) if err != nil { - common.PrintLines("%s", errors.ErrorStack(err)) + common.PrintLines("%v", err) return } @@ -64,7 +63,7 @@ func updateTaskFunc(cmd *cobra.Command, _ []string) { Workers: workers, }) if err != nil { - common.PrintLines("can not update task:\n%v", errors.ErrorStack(err)) + common.PrintLines("can not update task:\n%v", err) return } diff --git a/dm/master/server.go b/dm/master/server.go index e2b8b3f350..e2ff5cd815 100644 --- a/dm/master/server.go +++ b/dm/master/server.go @@ -25,7 +25,6 @@ import ( "time" "github.com/grpc-ecosystem/grpc-gateway/runtime" - "github.com/pingcap/errors" "github.com/siddontang/go/sync2" "github.com/soheilhy/cmux" "go.uber.org/zap" @@ -231,7 +230,7 @@ func (s *Server) StartTask(ctx context.Context, req *pb.StartTaskRequest) (*pb.S if err != nil { return &pb.StartTaskResponse{ Result: false, - Msg: errors.ErrorStack(err), + Msg: err.Error(), }, nil } log.L().Info("", zap.String("task name", cfg.Name), zap.Stringer("task", cfg), zap.String("request", "StartTask")) @@ -415,7 +414,7 @@ func (s *Server) UpdateTask(ctx context.Context, req *pb.UpdateTaskRequest) (*pb if err != nil { return &pb.UpdateTaskResponse{ Result: false, - Msg: errors.ErrorStack(err), + Msg: err.Error(), }, nil } log.L().Info("update task", zap.String("task name", cfg.Name), zap.Stringer("task", cfg)) @@ -663,7 +662,7 @@ func (s *Server) UnlockDDLLock(ctx context.Context, req *pb.UnlockDDLLockRequest } if err != nil { resp.Result = false - resp.Msg = errors.ErrorStack(err) + resp.Msg = err.Error() log.L().Error("fail to unlock ddl", zap.String("ID", req.ID), zap.String("request", "UnlockDDLLock"), zap.Error(err)) if req.ForceRemove { @@ -705,7 +704,7 @@ func (s *Server) BreakWorkerDDLLock(ctx context.Context, req *pb.BreakWorkerDDLL resp, err := cli.SendRequest(ctx, request, s.cfg.RPCTimeout) workerResp := &pb.CommonWorkerResponse{} if err != nil { - workerResp = errorCommonWorkerResponse(errors.ErrorStack(err), "") + workerResp = errorCommonWorkerResponse(err.Error(), "") } else { workerResp = resp.BreakDDLLock } @@ -743,7 +742,7 @@ func (s *Server) HandleSQLs(ctx context.Context, req *pb.HandleSQLsRequest) (*pb if err != nil { return &pb.HandleSQLsResponse{ Result: false, - Msg: fmt.Sprintf("save request with --sharding error:\n%s", errors.ErrorStack(err)), + Msg: fmt.Sprintf("save request with --sharding error:\n%v", err), }, nil } log.L().Info("handle sqls request was saved", zap.String("task name", req.Name), zap.String("request", "HandleSQLs")) @@ -782,7 +781,7 @@ func (s *Server) HandleSQLs(ctx context.Context, req *pb.HandleSQLsRequest) (*pb response, err := cli.SendRequest(ctx, subReq, s.cfg.RPCTimeout) workerResp := &pb.CommonWorkerResponse{} if err != nil { - workerResp = errorCommonWorkerResponse(errors.ErrorStack(err), "") + workerResp = errorCommonWorkerResponse(err.Error(), "") } else { workerResp = response.HandleSubTaskSQLs } @@ -819,7 +818,7 @@ func (s *Server) PurgeWorkerRelay(ctx context.Context, req *pb.PurgeWorkerRelayR resp, err := cli.SendRequest(ctx, workerReq, s.cfg.RPCTimeout) workerResp := &pb.CommonWorkerResponse{} if err != nil { - workerResp = errorCommonWorkerResponse(errors.ErrorStack(err), "") + workerResp = errorCommonWorkerResponse(err.Error(), "") } else { workerResp = resp.PurgeRelay } @@ -857,7 +856,7 @@ func (s *Server) SwitchWorkerRelayMaster(ctx context.Context, req *pb.SwitchWork log.L().Error("response error", zap.Error(err)) resp := &pb.CommonWorkerResponse{ Result: false, - Msg: errors.ErrorStack(err), + Msg: err.Error(), Worker: worker, } workerRespCh <- resp @@ -880,7 +879,7 @@ func (s *Server) SwitchWorkerRelayMaster(ctx context.Context, req *pb.SwitchWork resp, err := cli.SendRequest(ctx, request, s.cfg.RPCTimeout) workerResp := &pb.CommonWorkerResponse{} if err != nil { - workerResp = errorCommonWorkerResponse(errors.ErrorStack(err), "") + workerResp = errorCommonWorkerResponse(err.Error(), "") } else { workerResp = resp.SwitchRelayMaster } @@ -946,7 +945,7 @@ func (s *Server) OperateWorkerRelayTask(ctx context.Context, req *pb.OperateWork if err != nil { workerResp = &pb.OperateRelayResponse{ Result: false, - Msg: errors.ErrorStack(err), + Msg: err.Error(), } } else { workerResp = resp.OperateRelay @@ -1115,7 +1114,7 @@ func (s *Server) getStatusFromWorkers(ctx context.Context, workers []string, tas log.L().Error("response error", zap.Error(err)) resp := &pb.QueryStatusResponse{ Result: false, - Msg: errors.ErrorStack(err), + Msg: err.Error(), Worker: worker, } workerRespCh <- resp @@ -1137,7 +1136,7 @@ func (s *Server) getStatusFromWorkers(ctx context.Context, workers []string, tas if err != nil { workerStatus = &pb.QueryStatusResponse{ Result: false, - Msg: errors.ErrorStack(err), + Msg: err.Error(), } } else { workerStatus = resp.QueryStatus @@ -1170,7 +1169,7 @@ func (s *Server) getErrorFromWorkers(ctx context.Context, workers []string, task log.L().Error("response error", zap.Error(err)) resp := &pb.QueryErrorResponse{ Result: false, - Msg: errors.ErrorStack(err), + Msg: err.Error(), Worker: worker, } workerRespCh <- resp @@ -1192,7 +1191,7 @@ func (s *Server) getErrorFromWorkers(ctx context.Context, workers []string, task if err != nil { workerError = &pb.QueryErrorResponse{ Result: false, - Msg: errors.ErrorStack(err), + Msg: err.Error(), } } else { workerError = resp.QueryError @@ -1472,7 +1471,7 @@ func (s *Server) resolveDDLLock(ctx context.Context, lockID string, replaceOwner resp, err := cli.SendRequest(ctx, ownerReq, ownerTimeout) ownerResp := &pb.CommonWorkerResponse{} if err != nil { - ownerResp = errorCommonWorkerResponse(errors.ErrorStack(err), "") + ownerResp = errorCommonWorkerResponse(err.Error(), "") } else { ownerResp = resp.ExecDDL } @@ -1528,7 +1527,7 @@ func (s *Server) resolveDDLLock(ctx context.Context, lockID string, replaceOwner resp, err2 := cli.SendRequest(ctx, request, s.cfg.RPCTimeout) var workerResp *pb.CommonWorkerResponse if err2 != nil { - workerResp = errorCommonWorkerResponse(errors.ErrorStack(err2), "") + workerResp = errorCommonWorkerResponse(err2.Error(), "") } else { workerResp = resp.ExecDDL } @@ -1578,7 +1577,7 @@ func (s *Server) UpdateMasterConfig(ctx context.Context, req *pb.UpdateMasterCon s.Unlock() return &pb.UpdateMasterConfigResponse{ Result: false, - Msg: "Failed to write config to local file. detail: " + errors.ErrorStack(err), + Msg: "Failed to write config to local file. detail: " + err.Error(), }, nil } log.L().Info("saved dm-master config file", zap.String("config file", s.cfg.ConfigFile), zap.String("request", "UpdateMasterConfig")) @@ -1590,7 +1589,7 @@ func (s *Server) UpdateMasterConfig(ctx context.Context, req *pb.UpdateMasterCon s.Unlock() return &pb.UpdateMasterConfigResponse{ Result: false, - Msg: fmt.Sprintf("Failed to parse configure from file %s, detail: ", cfg.ConfigFile) + errors.ErrorStack(err), + Msg: fmt.Sprintf("Failed to parse configure from file %s, detail: ", cfg.ConfigFile) + err.Error(), }, nil } log.L().Info("update dm-master config", zap.Stringer("config", cfg), zap.String("request", "UpdateMasterConfig")) @@ -1609,7 +1608,7 @@ func (s *Server) UpdateMasterConfig(ctx context.Context, req *pb.UpdateMasterCon s.Unlock() return &pb.UpdateMasterConfigResponse{ Result: false, - Msg: fmt.Sprintf("Failed to get DDL lock Info from %s, detail: ", workerAddr) + errors.ErrorStack(err2), + Msg: fmt.Sprintf("Failed to get DDL lock Info from %s, detail: ", workerAddr) + err2.Error(), }, nil } if len(resp.Locks) != 0 { @@ -1617,7 +1616,7 @@ func (s *Server) UpdateMasterConfig(ctx context.Context, req *pb.UpdateMasterCon s.Unlock() return &pb.UpdateMasterConfigResponse{ Result: false, - Msg: errors.ErrorStack(err), + Msg: err.Error(), }, nil } } @@ -1634,7 +1633,7 @@ func (s *Server) UpdateMasterConfig(ctx context.Context, req *pb.UpdateMasterCon s.Unlock() return &pb.UpdateMasterConfigResponse{ Result: false, - Msg: fmt.Sprintf("Failed to add woker %s, detail: ", workerAddr) + errors.ErrorStack(err2), + Msg: fmt.Sprintf("Failed to add woker %s, detail: ", workerAddr) + err2.Error(), }, nil } s.workerClients[workerAddr] = cli @@ -1695,7 +1694,7 @@ func (s *Server) UpdateWorkerRelayConfig(ctx context.Context, req *pb.UpdateWork } resp, err := cli.SendRequest(ctx, request, s.cfg.RPCTimeout) if err != nil { - return errorCommonWorkerResponse(errors.ErrorStack(err), worker), nil + return errorCommonWorkerResponse(err.Error(), worker), nil } return resp.UpdateRelay, nil } @@ -1823,7 +1822,7 @@ func (s *Server) MigrateWorkerRelay(ctx context.Context, req *pb.MigrateWorkerRe } resp, err := cli.SendRequest(ctx, request, s.cfg.RPCTimeout) if err != nil { - return errorCommonWorkerResponse(errors.ErrorStack(err), worker), nil + return errorCommonWorkerResponse(err.Error(), worker), nil } return resp.MigrateRelay, nil } @@ -1836,7 +1835,7 @@ func (s *Server) CheckTask(ctx context.Context, req *pb.CheckTaskRequest) (*pb.C if err != nil { return &pb.CheckTaskResponse{ Result: false, - Msg: errors.ErrorStack(err), + Msg: err.Error(), }, nil } @@ -1926,7 +1925,7 @@ func (s *Server) waitOperationOk(ctx context.Context, cli workerrpc.Client, task func (s *Server) handleOperationResult(ctx context.Context, cli workerrpc.Client, taskName, workerID string, err error, resp *workerrpc.Response) *pb.OperateSubTaskResponse { if err != nil { return &pb.OperateSubTaskResponse{ - Meta: errorCommonWorkerResponse(errors.ErrorStack(err), ""), + Meta: errorCommonWorkerResponse(err.Error(), ""), } } response := &pb.OperateSubTaskResponse{} @@ -1945,7 +1944,7 @@ func (s *Server) handleOperationResult(ctx context.Context, cli workerrpc.Client err = s.waitOperationOk(ctx, cli, taskName, workerID, response.LogID) if err != nil { - response.Meta = errorCommonWorkerResponse(errors.ErrorStack(err), "") + response.Meta = errorCommonWorkerResponse(err.Error(), "") } return response diff --git a/dm/tracer/server.go b/dm/tracer/server.go index a8f2ac69b8..62f768bbfe 100644 --- a/dm/tracer/server.go +++ b/dm/tracer/server.go @@ -19,7 +19,6 @@ import ( "sync" "time" - "github.com/pingcap/errors" "github.com/siddontang/go/sync2" "github.com/soheilhy/cmux" "go.uber.org/zap" @@ -139,7 +138,7 @@ func (s *Server) UploadSyncerBinlogEvent(ctx context.Context, req *pb.UploadSync if err != nil { return &pb.CommonUploadResponse{ Result: false, - Msg: errors.ErrorStack(err), + Msg: err.Error(), }, nil } } @@ -157,7 +156,7 @@ func (s *Server) UploadSyncerJobEvent(ctx context.Context, req *pb.UploadSyncerJ if err != nil { return &pb.CommonUploadResponse{ Result: false, - Msg: errors.ErrorStack(err), + Msg: err.Error(), }, nil } } diff --git a/dm/worker/server.go b/dm/worker/server.go index 43f87d38cf..ebf8213264 100644 --- a/dm/worker/server.go +++ b/dm/worker/server.go @@ -20,7 +20,6 @@ import ( "sync" "time" - "github.com/pingcap/errors" "github.com/siddontang/go/sync2" "github.com/soheilhy/cmux" "go.uber.org/zap" @@ -375,7 +374,7 @@ func (s *Server) OperateRelay(ctx context.Context, req *pb.OperateRelayRequest) err := s.worker.OperateRelay(ctx, req) if err != nil { log.L().Error("fail to operate relay", zap.String("request", "OperateRelay"), zap.Stringer("payload", req), zap.Error(err)) - resp.Msg = errors.ErrorStack(err) + resp.Msg = err.Error() return resp, nil } @@ -418,7 +417,7 @@ func (s *Server) QueryWorkerConfig(ctx context.Context, req *pb.QueryWorkerConfi workerCfg, err := s.worker.QueryConfig(ctx) if err != nil { resp.Result = false - resp.Msg = errors.ErrorStack(err) + resp.Msg = err.Error() log.L().Error("fail to query worker config", zap.String("request", "QueryWorkerConfig"), zap.Stringer("payload", req), zap.Error(err)) return resp, nil } @@ -426,7 +425,7 @@ func (s *Server) QueryWorkerConfig(ctx context.Context, req *pb.QueryWorkerConfi rawConfig, err := workerCfg.From.Toml() if err != nil { resp.Result = false - resp.Msg = errors.ErrorStack(err) + resp.Msg = err.Error() log.L().Error("fail to marshal worker config", zap.String("request", "QueryWorkerConfig"), zap.Stringer("worker from config", &workerCfg.From), zap.Error(err)) } @@ -452,7 +451,7 @@ func makeCommonWorkerResponse(reqErr error) *pb.CommonWorkerResponse { } if reqErr != nil { resp.Result = false - resp.Msg = errors.ErrorStack(reqErr) + resp.Msg = reqErr.Error() } return resp }