From 118920e10d3ffa7c22d9944c1fdb48f16dfa2ed6 Mon Sep 17 00:00:00 2001 From: releng Date: Fri, 10 Jan 2025 09:07:39 -0500 Subject: [PATCH] Sync from server repo (1bb3e064f04) --- commands/cmd_start_replication.go | 13 +++++++++++-- commands/helpers.go | 10 +++++----- 2 files changed, 16 insertions(+), 7 deletions(-) diff --git a/commands/cmd_start_replication.go b/commands/cmd_start_replication.go index d03d2fd..0de0a80 100644 --- a/commands/cmd_start_replication.go +++ b/commands/cmd_start_replication.go @@ -17,6 +17,7 @@ package commands import ( "fmt" + "strings" "github.com/spf13/cobra" "github.com/spf13/viper" @@ -262,8 +263,16 @@ func (c *CmdStartReplication) Run(vcc vclusterops.ClusterCommands) error { transactionID, err := vcc.VReplicateDatabase(options) if err != nil { - vcc.LogError(err, "failed to replicate to database", "targetDB", options.TargetDB.DBName) - return err + errMsg := err.Error() + // when no table matches include pattern, errMsg contains "ERROR 4089: [22023] No objects specified" + // when no table matches table-or-schema-name, errMsg contains "ERROR 11781: [22023] Unknown or unsupported table name" + if !strings.Contains(errMsg, "22023") { + vcc.LogError(err, "failed to replicate to database", "targetDB", options.TargetDB.DBName) + return err + } + vcc.DisplayWarning("No data is replicated to database %s: %s", + options.TargetDB.DBName, errMsg) + return nil } if options.Async { diff --git a/commands/helpers.go b/commands/helpers.go index 1c10730..9bc7d55 100644 --- a/commands/helpers.go +++ b/commands/helpers.go @@ -77,17 +77,17 @@ func converErrorMessage(err error, logger vlog.Printer) string { errMsg := err.Error() logger.Error(err, "error to be converted into err msg") if strings.Contains(errMsg, "down database") { - return "failed to vertify connection parameters. please check your db name and host list" + return "Failed to verify connection parameters. Please check your db name and host list" } else if strings.Contains(errMsg, "Wrong password") { - return "failed to vertify connection parameters. please check your db username and password" + return "Failed to verify connection parameters. Please check your db username and password" } else if strings.Contains(errMsg, "rather than database") { - return "failed to vertify connection parameters. please check your db name" + return "Failed to verify connection parameters. Please check your db name" } else if strings.Contains(errMsg, "no such host") || strings.Contains(errMsg, "network is unreachable") || strings.Contains(errMsg, "fail to send request") || strings.Contains(errMsg, "server misbehaving") || strings.Contains(errMsg, "i/o timeout") { - return "failed to vertify connection parameters. please check your host list" + return "Failed to verify connection parameters. Please check your host list" } - return "failed to vertify connection parameters: " + errMsg + return "Failed to verify connection parameters: " + errMsg } // this function calls ClusterCommand.FetchNodesDetails() for each input hosts and return both valid and invalid hosts