diff --git a/go/test/endtoend/vtorc/readtopologyinstance/main_test.go b/go/test/endtoend/vtorc/readtopologyinstance/main_test.go index 19bd982b9bd..908f2e41d49 100644 --- a/go/test/endtoend/vtorc/readtopologyinstance/main_test.go +++ b/go/test/endtoend/vtorc/readtopologyinstance/main_test.go @@ -117,6 +117,7 @@ func TestReadTopologyInstanceBufferable(t *testing.T) { assert.False(t, primaryInstance.HasReplicationCredentials) assert.Equal(t, primaryInstance.ReplicationIOThreadState, inst.ReplicationThreadStateNoThread) assert.Equal(t, primaryInstance.ReplicationSQLThreadState, inst.ReplicationThreadStateNoThread) + assert.Equal(t, fmt.Sprintf("%v:%v", keyspace.Name, shard0.Name), primaryInstance.ClusterName) replicaInstance, err := inst.ReadTopologyInstanceBufferable(&inst.InstanceKey{ Hostname: utils.Hostname, @@ -168,4 +169,5 @@ func TestReadTopologyInstanceBufferable(t *testing.T) { assert.False(t, replicaInstance.HasReplicationFilters) assert.LessOrEqual(t, int(replicaInstance.SecondsBehindPrimary.Int64), 1) assert.False(t, replicaInstance.AllowTLS) + assert.Equal(t, fmt.Sprintf("%v:%v", keyspace.Name, shard0.Name), replicaInstance.ClusterName) } diff --git a/go/vt/orchestrator/app/cli.go b/go/vt/orchestrator/app/cli.go index 3f7ed5872af..07acbb326e6 100644 --- a/go/vt/orchestrator/app/cli.go +++ b/go/vt/orchestrator/app/cli.go @@ -504,15 +504,7 @@ func Cli(command string, strict bool, instance string, destination string, owner } case registerCliCommand("reattach-replica-primary-host", "Replication, general", `Undo a detach-replica-primary-host operation`): { - instanceKey, _ = inst.FigureInstanceKey(instanceKey, thisInstanceKey) - if instanceKey == nil { - log.Fatal("Cannot deduce instance:", instance) - } - _, err := inst.ReattachReplicaPrimaryHost(instanceKey) - if err != nil { - log.Fatal(err) - } - fmt.Println(instanceKey.DisplayString()) + fmt.Println("Command deprecated") } case registerCliCommand("primary-pos-wait", "Replication, general", `Wait until replica reaches given replication coordinates (--binlog=file:pos)`): { @@ -671,7 +663,7 @@ func Cli(command string, strict bool, instance string, destination string, owner log.Fatal(err) } for _, clusterPoolInstance := range clusterPoolInstances { - fmt.Printf("%s\t%s\t%s\t%s:%d\n", clusterPoolInstance.ClusterName, clusterPoolInstance.ClusterAlias, clusterPoolInstance.Pool, clusterPoolInstance.Hostname, clusterPoolInstance.Port) + fmt.Printf("%s\t%s\t%s:%d\n", clusterPoolInstance.ClusterName, clusterPoolInstance.Pool, clusterPoolInstance.Hostname, clusterPoolInstance.Port) } } case registerCliCommand("which-heuristic-cluster-pool-instances", "Pools", `List instances of a given cluster which are in either any pool or in a specific pool`): @@ -731,7 +723,7 @@ func Cli(command string, strict bool, instance string, destination string, owner log.Fatal(err) } for _, cluster := range clusters { - fmt.Printf("%s\t%s\n", cluster.ClusterName, cluster.ClusterAlias) + fmt.Printf("%s\n", cluster.ClusterName) } } case registerCliCommand("all-clusters-primaries", "Information", `List of writeable primaries, one per cluster`): @@ -804,7 +796,7 @@ func Cli(command string, strict bool, instance string, destination string, owner if err != nil { log.Fatal(err) } - fmt.Println(clusterInfo.ClusterAlias) + fmt.Println(clusterInfo.ClusterName) } case registerCliCommand("which-cluster-domain", "Information", `Output the domain name of the cluster an instance belongs to, or error if unknown to orchestrator`): { diff --git a/go/vt/orchestrator/config/config.go b/go/vt/orchestrator/config/config.go index 4833f609069..58a62801578 100644 --- a/go/vt/orchestrator/config/config.go +++ b/go/vt/orchestrator/config/config.go @@ -199,10 +199,10 @@ type Configuration struct { RecoverPrimaryClusterFilters []string // Only do primary recovery on clusters matching these regexp patterns (of course the ".*" pattern matches everything) RecoverIntermediatePrimaryClusterFilters []string // Only do IM recovery on clusters matching these regexp patterns (of course the ".*" pattern matches everything) ProcessesShellCommand string // Shell that executes command scripts - OnFailureDetectionProcesses []string // Processes to execute when detecting a failover scenario (before making a decision whether to failover or not). May and should use some of these placeholders: {failureType}, {instanceType}, {isPrimary}, {isCoPrimary}, {failureDescription}, {command}, {failedHost}, {failureCluster}, {failureClusterAlias}, {failureClusterDomain}, {failedPort}, {successorHost}, {successorPort}, {successorAlias}, {countReplicas}, {replicaHosts}, {isDowntimed}, {autoPrimaryRecovery}, {autoIntermediatePrimaryRecovery} - PreFailoverProcesses []string // Processes to execute before doing a failover (aborting operation should any once of them exits with non-zero code; order of execution undefined). May and should use some of these placeholders: {failureType}, {instanceType}, {isPrimary}, {isCoPrimary}, {failureDescription}, {command}, {failedHost}, {failureCluster}, {failureClusterAlias}, {failureClusterDomain}, {failedPort}, {countReplicas}, {replicaHosts}, {isDowntimed} - PostFailoverProcesses []string // Processes to execute after doing a failover (order of execution undefined). May and should use some of these placeholders: {failureType}, {instanceType}, {isPrimary}, {isCoPrimary}, {failureDescription}, {command}, {failedHost}, {failureCluster}, {failureClusterAlias}, {failureClusterDomain}, {failedPort}, {successorHost}, {successorPort}, {successorAlias}, {countReplicas}, {replicaHosts}, {isDowntimed}, {isSuccessful}, {lostReplicas}, {countLostReplicas} - PostUnsuccessfulFailoverProcesses []string // Processes to execute after a not-completely-successful failover (order of execution undefined). May and should use some of these placeholders: {failureType}, {instanceType}, {isPrimary}, {isCoPrimary}, {failureDescription}, {command}, {failedHost}, {failureCluster}, {failureClusterAlias}, {failureClusterDomain}, {failedPort}, {successorHost}, {successorPort}, {successorAlias}, {countReplicas}, {replicaHosts}, {isDowntimed}, {isSuccessful}, {lostReplicas}, {countLostReplicas} + OnFailureDetectionProcesses []string // Processes to execute when detecting a failover scenario (before making a decision whether to failover or not). May and should use some of these placeholders: {failureType}, {instanceType}, {isPrimary}, {isCoPrimary}, {failureDescription}, {command}, {failedHost}, {failureCluster}, {failureClusterDomain}, {failedPort}, {successorHost}, {successorPort}, {successorAlias}, {countReplicas}, {replicaHosts}, {isDowntimed}, {autoPrimaryRecovery}, {autoIntermediatePrimaryRecovery} + PreFailoverProcesses []string // Processes to execute before doing a failover (aborting operation should any once of them exits with non-zero code; order of execution undefined). May and should use some of these placeholders: {failureType}, {instanceType}, {isPrimary}, {isCoPrimary}, {failureDescription}, {command}, {failedHost}, {failureCluster}, {failureClusterDomain}, {failedPort}, {countReplicas}, {replicaHosts}, {isDowntimed} + PostFailoverProcesses []string // Processes to execute after doing a failover (order of execution undefined). May and should use some of these placeholders: {failureType}, {instanceType}, {isPrimary}, {isCoPrimary}, {failureDescription}, {command}, {failedHost}, {failureCluster}, {failureClusterDomain}, {failedPort}, {successorHost}, {successorPort}, {successorAlias}, {countReplicas}, {replicaHosts}, {isDowntimed}, {isSuccessful}, {lostReplicas}, {countLostReplicas} + PostUnsuccessfulFailoverProcesses []string // Processes to execute after a not-completely-successful failover (order of execution undefined). May and should use some of these placeholders: {failureType}, {instanceType}, {isPrimary}, {isCoPrimary}, {failureDescription}, {command}, {failedHost}, {failureCluster}, {failureClusterDomain}, {failedPort}, {successorHost}, {successorPort}, {successorAlias}, {countReplicas}, {replicaHosts}, {isDowntimed}, {isSuccessful}, {lostReplicas}, {countLostReplicas} PostPrimaryFailoverProcesses []string // Processes to execute after doing a primary failover (order of execution undefined). Uses same placeholders as PostFailoverProcesses PostIntermediatePrimaryFailoverProcesses []string // Processes to execute after doing a primary failover (order of execution undefined). Uses same placeholders as PostFailoverProcesses PostTakePrimaryProcesses []string // Processes to execute after a successful Take-Primary event has taken place diff --git a/go/vt/orchestrator/db/generate_base.go b/go/vt/orchestrator/db/generate_base.go index b0a9848bde3..007e273581e 100644 --- a/go/vt/orchestrator/db/generate_base.go +++ b/go/vt/orchestrator/db/generate_base.go @@ -272,13 +272,6 @@ var generateSQLBase = []string{ ` CREATE INDEX resolved_timestamp_idx_hostname_resolve ON hostname_resolve (resolved_timestamp) `, - ` - CREATE TABLE IF NOT EXISTS cluster_alias ( - cluster_name varchar(128) CHARACTER SET ascii NOT NULL, - alias varchar(128) NOT NULL, - PRIMARY KEY (cluster_name) - ) ENGINE=InnoDB DEFAULT CHARSET=ascii - `, ` CREATE TABLE IF NOT EXISTS active_node ( anchor tinyint unsigned NOT NULL, @@ -425,7 +418,6 @@ var generateSQLBase = []string{ processcing_node_token varchar(128) NOT NULL, analysis varchar(128) NOT NULL, cluster_name varchar(128) NOT NULL, - cluster_alias varchar(128) NOT NULL, count_affected_replicas int unsigned NOT NULL, replica_hosts text NOT NULL, PRIMARY KEY (detection_id) @@ -736,13 +728,6 @@ var generateSQLBase = []string{ PRIMARY KEY (disable_recovery) ) ENGINE=InnoDB DEFAULT CHARSET=ascii `, - ` - CREATE TABLE IF NOT EXISTS cluster_alias_override ( - cluster_name varchar(128) CHARACTER SET ascii NOT NULL, - alias varchar(128) NOT NULL, - PRIMARY KEY (cluster_name) - ) ENGINE=InnoDB DEFAULT CHARSET=ascii - `, ` CREATE TABLE IF NOT EXISTS topology_recovery_steps ( recovery_step_id bigint unsigned not null auto_increment, diff --git a/go/vt/orchestrator/db/generate_patches.go b/go/vt/orchestrator/db/generate_patches.go index aa7c77e6571..b50d20b82b9 100644 --- a/go/vt/orchestrator/db/generate_patches.go +++ b/go/vt/orchestrator/db/generate_patches.go @@ -92,11 +92,6 @@ var generateSQLPatches = []string{ database_instance_maintenance ADD KEY active_timestamp_idx (maintenance_active, begin_timestamp) `, - ` - ALTER TABLE - cluster_alias - ADD UNIQUE KEY alias_uidx (alias) - `, ` ALTER TABLE database_instance @@ -122,11 +117,6 @@ var generateSQLPatches = []string{ topology_recovery ADD COLUMN cluster_name varchar(128) CHARACTER SET ascii NOT NULL `, - ` - ALTER TABLE - topology_recovery - ADD COLUMN cluster_alias varchar(128) CHARACTER SET ascii NOT NULL - `, ` ALTER TABLE topology_recovery @@ -181,19 +171,6 @@ var generateSQLPatches = []string{ database_instance ADD COLUMN server_uuid varchar(64) CHARACTER SET ascii NOT NULL AFTER server_id `, - ` - ALTER TABLE - database_instance - ADD COLUMN suggested_cluster_alias varchar(128) CHARACTER SET ascii NOT NULL AFTER cluster_name - `, - ` - ALTER TABLE cluster_alias - ADD COLUMN last_registered TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP - `, - ` - ALTER TABLE cluster_alias - ADD KEY last_registered_idx (last_registered) - `, ` ALTER TABLE topology_recovery @@ -454,9 +431,6 @@ var generateSQLPatches = []string{ ` CREATE INDEX end_timestamp_idx_database_instance_downtime ON database_instance_downtime(end_timestamp) `, - ` - CREATE INDEX suggested_cluster_alias_idx_database_instance ON database_instance(suggested_cluster_alias) - `, ` ALTER TABLE topology_failure_detection diff --git a/go/vt/orchestrator/http/api.go b/go/vt/orchestrator/http/api.go index 66f9e704745..b9b5174f64d 100644 --- a/go/vt/orchestrator/http/api.go +++ b/go/vt/orchestrator/http/api.go @@ -620,26 +620,8 @@ func (httpAPI *API) DetachReplicaPrimaryHost(params martini.Params, r render.Ren Respond(r, &APIResponse{Code: OK, Message: fmt.Sprintf("Replica detached: %+v", instance.Key), Details: instance}) } -// ReattachReplicaPrimaryHost reverts a detachReplicaPrimaryHost command -// by resetting the original primary hostname in CHANGE MASTER TO -func (httpAPI *API) ReattachReplicaPrimaryHost(params martini.Params, r render.Render, req *http.Request, user auth.User) { - if !isAuthorizedForAction(req, user) { - Respond(r, &APIResponse{Code: ERROR, Message: "Unauthorized"}) - return - } - instanceKey, err := httpAPI.getInstanceKey(params["host"], params["port"]) - - if err != nil { - Respond(r, &APIResponse{Code: ERROR, Message: err.Error()}) - return - } - instance, err := inst.ReattachReplicaPrimaryHost(&instanceKey) - if err != nil { - Respond(r, &APIResponse{Code: ERROR, Message: err.Error()}) - return - } - - Respond(r, &APIResponse{Code: OK, Message: fmt.Sprintf("Replica reattached: %+v", instance.Key), Details: instance}) +func (httpAPI *API) NoOp(params martini.Params, r render.Render, req *http.Request, user auth.User) { + Respond(r, &APIResponse{Code: OK, Message: "API Deprecated"}) } // EnableGTID attempts to enable GTID on a replica @@ -1375,13 +1357,7 @@ func (httpAPI *API) Cluster(params martini.Params, r render.Render, req *http.Re // ClusterByAlias provides list of instances in given cluster func (httpAPI *API) ClusterByAlias(params martini.Params, r render.Render, req *http.Request) { - clusterName, err := inst.GetClusterByAlias(params["clusterAlias"]) - if err != nil { - Respond(r, &APIResponse{Code: ERROR, Message: fmt.Sprintf("%+v", err)}) - return - } - - params["clusterName"] = clusterName + params["clusterName"] = params["clusterAlias"] httpAPI.Cluster(params, r, req) } @@ -1421,13 +1397,7 @@ func (httpAPI *API) ClusterInfo(params martini.Params, r render.Render, req *htt // Cluster provides list of instances in given cluster func (httpAPI *API) ClusterInfoByAlias(params martini.Params, r render.Render, req *http.Request) { - clusterName, err := inst.GetClusterByAlias(params["clusterAlias"]) - if err != nil { - Respond(r, &APIResponse{Code: ERROR, Message: fmt.Sprintf("%+v", err)}) - return - } - - params["clusterName"] = clusterName + params["clusterName"] = params["clusterAlias"] httpAPI.ClusterInfo(params, r, req) } @@ -1448,29 +1418,6 @@ func (httpAPI *API) ClusterOSCReplicas(params martini.Params, r render.Render, r r.JSON(http.StatusOK, instances) } -// SetClusterAlias will change an alias for a given clustername -func (httpAPI *API) SetClusterAliasManualOverride(params martini.Params, r render.Render, req *http.Request, user auth.User) { - if !isAuthorizedForAction(req, user) { - Respond(r, &APIResponse{Code: ERROR, Message: "Unauthorized"}) - return - } - clusterName := params["clusterName"] - alias := req.URL.Query().Get("alias") - - var err error - if orcraft.IsRaftEnabled() { - _, err = orcraft.PublishCommand("set-cluster-alias-manual-override", []string{clusterName, alias}) - } else { - err = inst.SetClusterAliasManualOverride(clusterName, alias) - } - - if err != nil { - Respond(r, &APIResponse{Code: ERROR, Message: fmt.Sprintf("%+v", err)}) - return - } - Respond(r, &APIResponse{Code: OK, Message: fmt.Sprintf("Cluster %s now has alias '%s'", clusterName, alias)}) -} - // Clusters provides list of known clusters func (httpAPI *API) Clusters(params martini.Params, r render.Render, req *http.Request) { clusterNames, err := inst.ReadClusters() @@ -1878,11 +1825,7 @@ func (httpAPI *API) GetHeuristicClusterPoolInstancesLag(params martini.Params, r Respond(r, &APIResponse{Code: ERROR, Message: "Unauthorized"}) return } - clusterName, err := inst.ReadClusterNameByAlias(params["clusterName"]) - if err != nil { - Respond(r, &APIResponse{Code: ERROR, Message: fmt.Sprintf("%+v", err)}) - return - } + clusterName := params["clusterName"] pool := params["pool"] lag, err := inst.GetHeuristicClusterPoolInstancesLag(clusterName, pool) @@ -2199,12 +2142,7 @@ func (httpAPI *API) ReplicationAnalysis(params martini.Params, r render.Render, // ReplicationAnalysis retuens list of issues func (httpAPI *API) ReplicationAnalysisForCluster(params martini.Params, r render.Render, req *http.Request) { - var clusterName string - var err error - if clusterName, err = inst.DeduceClusterName(params["clusterName"]); err != nil { - Respond(r, &APIResponse{Code: ERROR, Message: fmt.Sprintf("Cannot get analysis: %+v", err)}) - return - } + clusterName := params["clusterName"] if clusterName == "" { Respond(r, &APIResponse{Code: ERROR, Message: fmt.Sprintf("Cannot get cluster name: %+v", params["clusterName"])}) return @@ -2415,7 +2353,7 @@ func (httpAPI *API) AuditFailureDetection(params martini.Params, r render.Render if derr != nil || page < 0 { page = 0 } - audits, err = logic.ReadRecentFailureDetections(params["clusterAlias"], page) + audits, err = logic.ReadRecentFailureDetections(params["clusterName"], page) } if err != nil { @@ -2467,7 +2405,7 @@ func (httpAPI *API) AuditRecovery(params martini.Params, r render.Render, req *h } unacknowledgedOnly := (req.URL.Query().Get("unacknowledged") == "true") - audits, err = logic.ReadRecentRecoveries(params["clusterName"], params["clusterAlias"], unacknowledgedOnly, page) + audits, err = logic.ReadRecentRecoveries(params["clusterName"], unacknowledgedOnly, page) } if err != nil { @@ -2530,7 +2468,7 @@ func (httpAPI *API) AcknowledgeClusterRecoveries(params martini.Params, r render var clusterName string var err error if params["clusterAlias"] != "" { - clusterName, err = inst.GetClusterByAlias(params["clusterAlias"]) + clusterName = params["clusterAlias"] } else { clusterName, err = figureClusterName(getClusterHint(params)) } @@ -2813,9 +2751,9 @@ func (httpAPI *API) RegisterRequests(m *martini.ClassicMartini) { httpAPI.registerAPIRequest(m, "stop-replica-nice/:host/:port", httpAPI.StopReplicationNicely) httpAPI.registerAPIRequest(m, "reset-replica/:host/:port", httpAPI.ResetReplication) httpAPI.registerAPIRequest(m, "detach-replica/:host/:port", httpAPI.DetachReplicaPrimaryHost) - httpAPI.registerAPIRequest(m, "reattach-replica/:host/:port", httpAPI.ReattachReplicaPrimaryHost) + httpAPI.registerAPIRequest(m, "reattach-replica/:host/:port", httpAPI.NoOp) httpAPI.registerAPIRequest(m, "detach-replica-primary-host/:host/:port", httpAPI.DetachReplicaPrimaryHost) - httpAPI.registerAPIRequest(m, "reattach-replica-primary-host/:host/:port", httpAPI.ReattachReplicaPrimaryHost) + httpAPI.registerAPIRequest(m, "reattach-replica-primary-host/:host/:port", httpAPI.NoOp) httpAPI.registerAPIRequest(m, "flush-binary-logs/:host/:port", httpAPI.FlushBinaryLogs) httpAPI.registerAPIRequest(m, "purge-binary-logs/:host/:port/:logFile", httpAPI.PurgeBinaryLogs) httpAPI.registerAPIRequest(m, "restart-replica-statements/:host/:port", httpAPI.RestartReplicationStatements) @@ -2849,7 +2787,7 @@ func (httpAPI *API) RegisterRequests(m *martini.ClassicMartini) { httpAPI.registerAPIRequest(m, "cluster-info/:clusterHint", httpAPI.ClusterInfo) httpAPI.registerAPIRequest(m, "cluster-info/alias/:clusterAlias", httpAPI.ClusterInfoByAlias) httpAPI.registerAPIRequest(m, "cluster-osc-replicas/:clusterHint", httpAPI.ClusterOSCReplicas) - httpAPI.registerAPIRequest(m, "set-cluster-alias/:clusterName", httpAPI.SetClusterAliasManualOverride) + httpAPI.registerAPIRequest(m, "set-cluster-alias/:clusterName", httpAPI.NoOp) httpAPI.registerAPIRequest(m, "clusters", httpAPI.Clusters) httpAPI.registerAPIRequest(m, "clusters-info", httpAPI.ClustersInfo) diff --git a/go/vt/orchestrator/http/web.go b/go/vt/orchestrator/http/web.go index 671bb1beaf9..b784f468660 100644 --- a/go/vt/orchestrator/http/web.go +++ b/go/vt/orchestrator/http/web.go @@ -113,14 +113,7 @@ func (httpWeb *Web) Cluster(params martini.Params, r render.Render, req *http.Re } func (httpWeb *Web) ClusterByAlias(params martini.Params, r render.Render, req *http.Request, user auth.User) { - clusterName, err := inst.GetClusterByAlias(params["clusterAlias"]) - // Willing to accept the case of multiple clusters; we just present one - if clusterName == "" && err != nil { - r.JSON(200, &APIResponse{Code: ERROR, Message: fmt.Sprintf("%+v", err)}) - return - } - - params["clusterName"] = clusterName + params["clusterName"] = params["clusterAlias"] httpWeb.Cluster(params, r, req, user) } diff --git a/go/vt/orchestrator/inst/analysis.go b/go/vt/orchestrator/inst/analysis.go index ce0a29bd734..efb6a8a0fcd 100644 --- a/go/vt/orchestrator/inst/analysis.go +++ b/go/vt/orchestrator/inst/analysis.go @@ -118,7 +118,6 @@ type ReplicationAnalysis struct { AnalyzedInstancePrimaryKey InstanceKey TabletType topodatapb.TabletType PrimaryTimeStamp time.Time - SuggestedClusterAlias string ClusterDetails ClusterInfo AnalyzedInstanceDataCenter string AnalyzedInstanceRegion string diff --git a/go/vt/orchestrator/inst/analysis_dao.go b/go/vt/orchestrator/inst/analysis_dao.go index 7ace24cf310..cebcb09ffc0 100644 --- a/go/vt/orchestrator/inst/analysis_dao.go +++ b/go/vt/orchestrator/inst/analysis_dao.go @@ -88,7 +88,6 @@ func GetReplicationAnalysis(clusterName string, hints *ReplicationAnalysisHints) MIN(primary_instance.cluster_name) AS cluster_name, MIN(primary_instance.binary_log_file) AS binary_log_file, MIN(primary_instance.binary_log_pos) AS binary_log_pos, - MIN(primary_instance.suggested_cluster_alias) AS suggested_cluster_alias, MIN(primary_tablet.info) AS primary_tablet_info, MIN( IFNULL( @@ -98,12 +97,6 @@ func GetReplicationAnalysis(clusterName string, hints *ReplicationAnalysisHints) 0 ) ) AS is_stale_binlog_coordinates, - MIN( - IFNULL( - cluster_alias.alias, - primary_instance.cluster_name - ) - ) AS cluster_alias, MIN( IFNULL( cluster_domain_name.domain_name, @@ -129,13 +122,6 @@ func GetReplicationAnalysis(clusterName string, hints *ReplicationAnalysisHints) ) ) AS is_primary, MIN(primary_instance.is_co_primary) AS is_co_primary, - MIN( - CONCAT( - primary_instance.hostname, - ':', - primary_instance.port - ) = primary_instance.cluster_name - ) AS is_cluster_primary, MIN(primary_instance.gtid_mode) AS gtid_mode, COUNT(replica_instance.server_id) AS count_replicas, IFNULL( @@ -353,9 +339,6 @@ func GetReplicationAnalysis(clusterName string, hints *ReplicationAnalysisHints) AND replica_instance.port = replica_downtime.port AND replica_downtime.downtime_active = 1 ) - LEFT JOIN cluster_alias ON ( - cluster_alias.cluster_name = primary_instance.cluster_name - ) LEFT JOIN cluster_domain_name ON ( cluster_domain_name.cluster_name = primary_instance.cluster_name ) @@ -415,9 +398,7 @@ func GetReplicationAnalysis(clusterName string, hints *ReplicationAnalysisHints) Type: BinaryLog, } isStaleBinlogCoordinates := m.GetBool("is_stale_binlog_coordinates") - a.SuggestedClusterAlias = m.GetString("suggested_cluster_alias") a.ClusterDetails.ClusterName = m.GetString("cluster_name") - a.ClusterDetails.ClusterAlias = m.GetString("cluster_alias") a.ClusterDetails.ClusterDomain = m.GetString("cluster_domain") a.GTIDMode = m.GetString("gtid_mode") a.LastCheckValid = m.GetBool("is_last_check_valid") @@ -476,11 +457,11 @@ func GetReplicationAnalysis(clusterName string, hints *ReplicationAnalysisHints) log.Infof(analysisMessage) } } - if clusters[a.SuggestedClusterAlias] == nil { - clusters[a.SuggestedClusterAlias] = &clusterAnalysis{} + if clusters[a.ClusterDetails.ClusterName] == nil { + clusters[a.ClusterDetails.ClusterName] = &clusterAnalysis{} if a.TabletType == topodatapb.TabletType_PRIMARY { a.IsClusterPrimary = true - clusters[a.SuggestedClusterAlias].primaryKey = &a.AnalyzedInstanceKey + clusters[a.ClusterDetails.ClusterName].primaryKey = &a.AnalyzedInstanceKey } durabilityPolicy := m.GetString("durability_policy") if durabilityPolicy == "" { @@ -492,10 +473,10 @@ func GetReplicationAnalysis(clusterName string, hints *ReplicationAnalysisHints) log.Errorf("can't get the durability policy %v - %v. Skipping keyspace - %v.", durabilityPolicy, err, a.AnalyzedKeyspace) return nil } - clusters[a.SuggestedClusterAlias].durability = durability + clusters[a.ClusterDetails.ClusterName].durability = durability } // ca has clusterwide info - ca := clusters[a.SuggestedClusterAlias] + ca := clusters[a.ClusterDetails.ClusterName] if ca.hasClusterwideAction { // We can only take one cluster level action at a time. return nil diff --git a/go/vt/orchestrator/inst/cluster.go b/go/vt/orchestrator/inst/cluster.go index 6e2abfaf7e8..a20ce548e2b 100644 --- a/go/vt/orchestrator/inst/cluster.go +++ b/go/vt/orchestrator/inst/cluster.go @@ -18,30 +18,13 @@ package inst import ( "regexp" - "strings" "vitess.io/vitess/go/vt/orchestrator/config" ) -// mappedClusterNameToAlias attempts to match a cluster with an alias based on -// configured ClusterNameToAlias map -func mappedClusterNameToAlias(clusterName string) string { - for pattern, alias := range config.Config.ClusterNameToAlias { - if pattern == "" { - // sanity - continue - } - if matched, _ := regexp.MatchString(pattern, clusterName); matched { - return alias - } - } - return "" -} - // ClusterInfo makes for a cluster status/info summary type ClusterInfo struct { ClusterName string - ClusterAlias string // Human friendly alias ClusterDomain string // CNAME/VIP/A-record/whatever of the primary of this cluster CountInstances uint HeuristicLag int64 @@ -61,22 +44,7 @@ func (clusterInfo *ClusterInfo) filtersMatchCluster(filters []string) bool { if filter == clusterInfo.ClusterName { return true } - if filter == clusterInfo.ClusterAlias { - return true - } - if strings.HasPrefix(filter, "alias=") { - // Match by exact cluster alias name - alias := strings.SplitN(filter, "=", 2)[1] - if alias == clusterInfo.ClusterAlias { - return true - } - } else if strings.HasPrefix(filter, "alias~=") { - // Match by cluster alias regex - aliasPattern := strings.SplitN(filter, "~=", 2)[1] - if matched, _ := regexp.MatchString(aliasPattern, clusterInfo.ClusterAlias); matched { - return true - } - } else if filter == "*" { + if filter == "*" { return true } else if matched, _ := regexp.MatchString(filter, clusterInfo.ClusterName); matched && filter != "" { return true @@ -84,14 +52,3 @@ func (clusterInfo *ClusterInfo) filtersMatchCluster(filters []string) bool { } return false } - -// ApplyClusterAlias updates the given clusterInfo's ClusterAlias property -func (clusterInfo *ClusterInfo) ApplyClusterAlias() { - if clusterInfo.ClusterAlias != "" && clusterInfo.ClusterAlias != clusterInfo.ClusterName { - // Already has an alias; abort - return - } - if alias := mappedClusterNameToAlias(clusterInfo.ClusterName); alias != "" { - clusterInfo.ClusterAlias = alias - } -} diff --git a/go/vt/orchestrator/inst/cluster_alias.go b/go/vt/orchestrator/inst/cluster_alias.go deleted file mode 100644 index ccb3a1bf0b9..00000000000 --- a/go/vt/orchestrator/inst/cluster_alias.go +++ /dev/null @@ -1,35 +0,0 @@ -/* - Copyright 2015 Shlomi Noach, courtesy Booking.com - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package inst - -// SetClusterAlias will write (and override) a single cluster name mapping -func SetClusterAlias(clusterName string, alias string) error { - return writeClusterAlias(clusterName, alias) -} - -// SetClusterAliasManualOverride will write (and override) a single cluster name mapping -func SetClusterAliasManualOverride(clusterName string, alias string) error { - return writeClusterAliasManualOverride(clusterName, alias) -} - -// GetClusterByAlias returns the cluster name associated with given alias. -// The function returns with error when: -// - No cluster is associated with the alias -// - More than one cluster is associated with the alias -func GetClusterByAlias(alias string) (string, error) { - return ReadClusterNameByAlias(alias) -} diff --git a/go/vt/orchestrator/inst/cluster_alias_dao.go b/go/vt/orchestrator/inst/cluster_alias_dao.go deleted file mode 100644 index 552f0d58282..00000000000 --- a/go/vt/orchestrator/inst/cluster_alias_dao.go +++ /dev/null @@ -1,245 +0,0 @@ -/* - Copyright 2015 Shlomi Noach, courtesy Booking.com - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. -*/ - -package inst - -import ( - "fmt" - - "vitess.io/vitess/go/vt/log" - - "vitess.io/vitess/go/vt/orchestrator/db" - "vitess.io/vitess/go/vt/orchestrator/external/golib/sqlutils" -) - -// ReadClusterNameByAlias -func ReadClusterNameByAlias(alias string) (clusterName string, err error) { - query := ` - select - cluster_name - from - cluster_alias - where - alias = ? - or cluster_name = ? - ` - err = db.QueryOrchestrator(query, sqlutils.Args(alias, alias), func(m sqlutils.RowMap) error { - clusterName = m.GetString("cluster_name") - return nil - }) - if err != nil { - return "", err - } - if clusterName == "" { - err = fmt.Errorf("No cluster found for alias %s", alias) - } - return clusterName, err -} - -// DeduceClusterName attempts to resolve a cluster name given a name or alias. -// If unsuccessful to match by alias, the function returns the same given string -func DeduceClusterName(nameOrAlias string) (clusterName string, err error) { - if nameOrAlias == "" { - return "", fmt.Errorf("empty cluster name") - } - if name, err := ReadClusterNameByAlias(nameOrAlias); err == nil { - return name, nil - } - return nameOrAlias, nil -} - -// ReadAliasByClusterName returns the cluster alias for the given cluster name, -// or the cluster name itself if not explicit alias found -func ReadAliasByClusterName(clusterName string) (alias string, err error) { - alias = clusterName // default return value - query := ` - select - alias - from - cluster_alias - where - cluster_name = ? - ` - err = db.QueryOrchestrator(query, sqlutils.Args(clusterName), func(m sqlutils.RowMap) error { - alias = m.GetString("alias") - return nil - }) - return clusterName, err -} - -// WriteClusterAlias will write (and override) a single cluster name mapping -func writeClusterAlias(clusterName string, alias string) error { - writeFunc := func() error { - _, err := db.ExecOrchestrator(` - replace into - cluster_alias (cluster_name, alias, last_registered) - values - (?, ?, now()) - `, - clusterName, alias) - if err != nil { - log.Error(err) - } - return err - } - return ExecDBWriteFunc(writeFunc) -} - -// writeClusterAliasManualOverride will write (and override) a single cluster name mapping -func writeClusterAliasManualOverride(clusterName string, alias string) error { - writeFunc := func() error { - _, err := db.ExecOrchestrator(` - replace into - cluster_alias_override (cluster_name, alias) - values - (?, ?) - `, - clusterName, alias) - if err != nil { - log.Error(err) - } - return err - } - return ExecDBWriteFunc(writeFunc) -} - -// UpdateClusterAliases writes down the cluster_alias table based on information -// gained from database_instance -func UpdateClusterAliases() error { - writeFunc := func() error { - _, err := db.ExecOrchestrator(` - replace into - cluster_alias (alias, cluster_name, last_registered) - select - suggested_cluster_alias, - cluster_name, - now() - from - database_instance - left join database_instance_downtime using (hostname, port) - where - suggested_cluster_alias!='' - /* exclude newly demoted, downtimed primaries */ - and ifnull( - database_instance_downtime.downtime_active = 1 - and database_instance_downtime.end_timestamp > now() - and database_instance_downtime.reason = ? - , 0) = 0 - order by - ifnull(last_checked <= last_seen, 0) asc, - read_only desc, - num_replica_hosts asc - `, DowntimeLostInRecoveryMessage) - if err != nil { - log.Error(err) - } - return err - } - if err := ExecDBWriteFunc(writeFunc); err != nil { - return err - } - writeFunc = func() error { - // Handling the case where no cluster alias exists: we write a dummy alias in the form of the real cluster name. - _, err := db.ExecOrchestrator(` - replace into - cluster_alias (alias, cluster_name, last_registered) - select - cluster_name as alias, cluster_name, now() - from - database_instance - group by - cluster_name - having - sum(suggested_cluster_alias = '') = count(*) - `) - if err != nil { - log.Error(err) - } - return err - } - if err := ExecDBWriteFunc(writeFunc); err != nil { - return err - } - return nil -} - -// ReplaceAliasClusterName replaces alis mapping of one cluster name onto a new cluster name. -// Used in topology failover/recovery -func ReplaceAliasClusterName(oldClusterName string, newClusterName string) (err error) { - { - writeFunc := func() error { - _, err := db.ExecOrchestrator(` - update cluster_alias - set cluster_name = ? - where cluster_name = ? - `, - newClusterName, oldClusterName) - if err != nil { - log.Error(err) - } - return err - } - err = ExecDBWriteFunc(writeFunc) - } - { - writeFunc := func() error { - _, err := db.ExecOrchestrator(` - update cluster_alias_override - set cluster_name = ? - where cluster_name = ? - `, - newClusterName, oldClusterName) - if err != nil { - log.Error(err) - } - return err - } - if ferr := ExecDBWriteFunc(writeFunc); ferr != nil { - err = ferr - } - } - return err -} - -// ReadUnambiguousSuggestedClusterAliases reads potential primary hostname:port who have suggested cluster aliases, -// where no one else shares said suggested cluster alias. Such hostname:port are likely true owners -// of the alias. -func ReadUnambiguousSuggestedClusterAliases() (result map[string]InstanceKey, err error) { - result = map[string]InstanceKey{} - - query := ` - select - suggested_cluster_alias, - min(hostname) as hostname, - min(port) as port - from - database_instance - where - suggested_cluster_alias != '' - and replication_depth=0 - group by - suggested_cluster_alias - having - count(*) = 1 - ` - err = db.QueryOrchestrator(query, sqlutils.Args(), func(m sqlutils.RowMap) error { - key := InstanceKey{Hostname: m.GetString("hostname"), Port: m.GetInt("port")} - suggestedAlias := m.GetString("suggested_cluster_alias") - result[suggestedAlias] = key - return nil - }) - return result, err -} diff --git a/go/vt/orchestrator/inst/downtime_dao.go b/go/vt/orchestrator/inst/downtime_dao.go index 8f41da56315..fa39d050f2e 100644 --- a/go/vt/orchestrator/inst/downtime_dao.go +++ b/go/vt/orchestrator/inst/downtime_dao.go @@ -142,10 +142,6 @@ func expireLostInRecoveryDowntime() error { if len(instances) == 0 { return nil } - unambiguousAliases, err := ReadUnambiguousSuggestedClusterAliases() - if err != nil { - return err - } for _, instance := range instances { // We _may_ expire this downtime, but only after a minute // This is a graceful period, during which other servers can claim ownership of the alias, @@ -156,21 +152,8 @@ func expireLostInRecoveryDowntime() error { if !instance.IsLastCheckValid { continue } - endDowntime := false if instance.ReplicaRunning() { // back, alive, replicating in some topology - endDowntime = true - } else if instance.ReplicationDepth == 0 { - // instance makes the appearance of a primary - if unambiguousKey, ok := unambiguousAliases[instance.SuggestedClusterAlias]; ok { - if unambiguousKey.Equals(&instance.Key) { - // This instance seems to be a primary, which is valid, and has a suggested alias, - // and is the _only_ one to have this suggested alias (i.e. no one took its place) - endDowntime = true - } - } - } - if endDowntime { if _, err := EndDowntime(&instance.Key); err != nil { return err } diff --git a/go/vt/orchestrator/inst/instance.go b/go/vt/orchestrator/inst/instance.go index d889f297526..8fbf48eb7e5 100644 --- a/go/vt/orchestrator/inst/instance.go +++ b/go/vt/orchestrator/inst/instance.go @@ -81,7 +81,6 @@ type Instance struct { ReplicationLagSeconds sql.NullInt64 Replicas InstanceKeyMap ClusterName string - SuggestedClusterAlias string DataCenter string Region string PhysicalEnvironment string diff --git a/go/vt/orchestrator/inst/instance_dao.go b/go/vt/orchestrator/inst/instance_dao.go index 47e03dee4c0..de15f7ea450 100644 --- a/go/vt/orchestrator/inst/instance_dao.go +++ b/go/vt/orchestrator/inst/instance_dao.go @@ -297,6 +297,7 @@ func ReadTopologyInstanceBufferable(instanceKey *InstanceKey, bufferWrites bool, if err != nil { goto Cleanup } + instance.ClusterName = fmt.Sprintf("%v:%v", tablet.Keyspace, tablet.Shard) fullStatus, err = FullStatus(*instanceKey) if err != nil { @@ -634,9 +635,6 @@ func ReadTopologyInstanceBufferable(instanceKey *InstanceKey, bufferWrites bool, err = RegisterCandidateInstance(NewCandidateDatabaseInstance(instanceKey, instance.PromotionRule).WithCurrentTime()) _ = logReadTopologyInstanceError(instanceKey, "RegisterCandidateInstance", err) - // TODO(sougou): delete cluster_alias_override metadata - instance.SuggestedClusterAlias = fmt.Sprintf("%v:%v", tablet.Keyspace, tablet.Shard) - if instance.ReplicationDepth == 0 && config.Config.DetectClusterDomainQuery != "" { // Only need to do on primary tablets domainName := "" @@ -776,7 +774,6 @@ func ReadReplicationGroupPrimary(instance *Instance) (err error) { // instances. func ReadInstanceClusterAttributes(instance *Instance) (err error) { var primaryOrGroupPrimaryInstanceKey InstanceKey - var primaryOrGroupPrimaryClusterName string var primaryOrGroupPrimaryReplicationDepth uint var ancestryUUID string var primaryOrGroupPrimaryExecutedGtidSet string @@ -785,8 +782,6 @@ func ReadInstanceClusterAttributes(instance *Instance) (err error) { // Read the cluster_name of the _primary_ or _group_primary_ of our instance, derive it from there. query := ` select - cluster_name, - suggested_cluster_alias, replication_depth, source_host, source_port, @@ -805,7 +800,6 @@ func ReadInstanceClusterAttributes(instance *Instance) (err error) { } args := sqlutils.Args(primaryOrGroupPrimaryInstanceKey.Hostname, primaryOrGroupPrimaryInstanceKey.Port) err = db.QueryOrchestrator(query, args, func(m sqlutils.RowMap) error { - primaryOrGroupPrimaryClusterName = m.GetString("cluster_name") primaryOrGroupPrimaryReplicationDepth = m.GetUint("replication_depth") primaryOrGroupPrimaryInstanceKey.Hostname = m.GetString("source_host") primaryOrGroupPrimaryInstanceKey.Port = m.GetInt("source_port") @@ -820,34 +814,14 @@ func ReadInstanceClusterAttributes(instance *Instance) (err error) { } var replicationDepth uint - var clusterName string if primaryOrGroupPrimaryDataFound { replicationDepth = primaryOrGroupPrimaryReplicationDepth + 1 - clusterName = primaryOrGroupPrimaryClusterName - } - clusterNameByInstanceKey := instance.Key.StringCode() - if clusterName == "" { - // Nothing from primary; we set it to be named after the instance itself - clusterName = clusterNameByInstanceKey } - isCoPrimary := false if primaryOrGroupPrimaryInstanceKey.Equals(&instance.Key) { // co-primary calls for special case, in fear of the infinite loop isCoPrimary = true - clusterNameByCoPrimaryKey := instance.SourceKey.StringCode() - if clusterName != clusterNameByInstanceKey && clusterName != clusterNameByCoPrimaryKey { - // Can be caused by a co-primary topology failover - log.Errorf("ReadInstanceClusterAttributes: in co-primary topology %s is not in (%s, %s). Forcing it to become one of them", clusterName, clusterNameByInstanceKey, clusterNameByCoPrimaryKey) - clusterName = math.TernaryString(instance.Key.SmallerThan(&instance.SourceKey), clusterNameByInstanceKey, clusterNameByCoPrimaryKey) - } - if clusterName == clusterNameByInstanceKey { - // circular replication. Avoid infinite ++ on replicationDepth - replicationDepth = 0 - ancestryUUID = "" - } // While the other stays "1" - } - instance.ClusterName = clusterName + } instance.ReplicationDepth = replicationDepth instance.IsCoPrimary = isCoPrimary instance.AncestryUUID = ancestryUUID @@ -944,7 +918,6 @@ func readInstanceRow(m sqlutils.RowMap) *Instance { instance.SQLDelay = m.GetUint("sql_delay") replicasJSON := m.GetString("replica_hosts") instance.ClusterName = m.GetString("cluster_name") - instance.SuggestedClusterAlias = m.GetString("suggested_cluster_alias") instance.DataCenter = m.GetString("data_center") instance.Region = m.GetString("region") instance.PhysicalEnvironment = m.GetString("physical_environment") @@ -1035,6 +1008,7 @@ func readInstancesByCondition(condition string, args []any, sort string) ([](*In ifnull(database_instance_downtime.end_timestamp, '') as downtime_end_timestamp from database_instance + left join vitess_tablet using (hostname, port) left join candidate_database_instance using (hostname, port) left join hostname_unresolve using (hostname) left join database_instance_downtime using (hostname, port) @@ -1109,8 +1083,9 @@ func ReadClusterWriteablePrimary(clusterName string) ([](*Instance), error) { cluster_name = ? and read_only = 0 and (replication_depth = 0 or is_co_primary) + and tablet_type = ? ` - return readInstancesByCondition(condition, sqlutils.Args(clusterName), "replication_depth asc") + return readInstancesByCondition(condition, sqlutils.Args(clusterName, topodatapb.TabletType_PRIMARY), "replication_depth asc") } // ReadClusterPrimary returns the primary of this cluster. @@ -1120,8 +1095,9 @@ func ReadClusterPrimary(clusterName string) ([](*Instance), error) { condition := ` cluster_name = ? and (replication_depth = 0 or is_co_primary) + and tablet_type = ? ` - return readInstancesByCondition(condition, sqlutils.Args(clusterName), "read_only asc, replication_depth asc") + return readInstancesByCondition(condition, sqlutils.Args(clusterName, topodatapb.TabletType_PRIMARY), "read_only asc, replication_depth asc") } // ReadWriteableClustersPrimaries returns writeable primaries of all clusters, but only one @@ -1130,8 +1106,9 @@ func ReadWriteableClustersPrimaries() (instances [](*Instance), err error) { condition := ` read_only = 0 and (replication_depth = 0 or is_co_primary) + and tablet_type = ? ` - allPrimaries, err := readInstancesByCondition(condition, sqlutils.Args(), "cluster_name asc, replication_depth asc") + allPrimaries, err := readInstancesByCondition(condition, sqlutils.Args(topodatapb.TabletType_PRIMARY), "cluster_name asc, replication_depth asc") if err != nil { return instances, err } @@ -1236,11 +1213,10 @@ func SearchInstances(searchString string) ([](*Instance), error) { or instr(version, ?) > 0 or instr(version_comment, ?) > 0 or instr(concat(hostname, ':', port), ?) > 0 - or instr(suggested_cluster_alias, ?) > 0 or concat(server_id, '') = ? or concat(port, '') = ? ` - args := sqlutils.Args(searchString, searchString, searchString, searchString, searchString, searchString, searchString, searchString) + args := sqlutils.Args(searchString, searchString, searchString, searchString, searchString, searchString, searchString) return readInstancesByCondition(condition, args, `replication_depth asc, num_replica_hosts desc, cluster_name, hostname, port`) } @@ -1569,59 +1545,6 @@ func GetHeuristicClusterPoolInstancesLag(clusterName string, pool string) (int64 return GetInstancesMaxLag(instances) } -// updateInstanceClusterName -func updateInstanceClusterName(instance *Instance) error { - writeFunc := func() error { - _, err := db.ExecOrchestrator(` - update - database_instance - set - cluster_name=? - where - hostname=? and port=? - `, instance.ClusterName, instance.Key.Hostname, instance.Key.Port, - ) - if err != nil { - log.Error(err) - return err - } - _ = AuditOperation("update-cluster-name", &instance.Key, fmt.Sprintf("set to %s", instance.ClusterName)) - return nil - } - return ExecDBWriteFunc(writeFunc) -} - -// ReviewUnseenInstances reviews instances that have not been seen (suposedly dead) and updates some of their data -func ReviewUnseenInstances() error { - instances, err := ReadUnseenInstances() - if err != nil { - log.Error(err) - return err - } - operations := 0 - for _, instance := range instances { - instance := instance - - primaryHostname, err := ResolveHostname(instance.SourceKey.Hostname) - if err != nil { - log.Error(err) - continue - } - instance.SourceKey.Hostname = primaryHostname - savedClusterName := instance.ClusterName - - if err := ReadInstanceClusterAttributes(instance); err != nil { - log.Error(err) - } else if instance.ClusterName != savedClusterName { - _ = updateInstanceClusterName(instance) - operations++ - } - } - - _ = AuditOperation("review-unseen-instances", nil, fmt.Sprintf("Operations: %d", operations)) - return err -} - // readUnseenPrimaryKeys will read list of primaries that have never been seen, and yet whose replicas // seem to be replicating. func readUnseenPrimaryKeys() ([]InstanceKey, error) { @@ -1923,11 +1846,9 @@ func ReadClustersInfo(clusterName string) ([]ClusterInfo, error) { select cluster_name, count(*) as count_instances, - ifnull(min(alias), cluster_name) as alias, ifnull(min(domain_name), '') as domain_name from database_instance - left join cluster_alias using (cluster_name) left join cluster_domain_name using (cluster_name) %s group by @@ -1937,10 +1858,8 @@ func ReadClustersInfo(clusterName string) ([]ClusterInfo, error) { clusterInfo := ClusterInfo{ ClusterName: m.GetString("cluster_name"), CountInstances: m.GetUint("count_instances"), - ClusterAlias: m.GetString("alias"), ClusterDomain: m.GetString("domain_name"), } - clusterInfo.ApplyClusterAlias() clusterInfo.ReadRecoveryInfo() clusters = append(clusters, clusterInfo) @@ -2149,7 +2068,6 @@ func mkInsertOdkuForInstances(instances []*Instance, instanceWasActuallyFound bo "num_replica_hosts", "replica_hosts", "cluster_name", - "suggested_cluster_alias", "data_center", "region", "physical_environment", @@ -2239,7 +2157,6 @@ func mkInsertOdkuForInstances(instances []*Instance, instanceWasActuallyFound bo args = append(args, len(instance.Replicas)) args = append(args, instance.Replicas.ToJSONString()) args = append(args, instance.ClusterName) - args = append(args, instance.SuggestedClusterAlias) args = append(args, instance.DataCenter) args = append(args, instance.Region) args = append(args, instance.PhysicalEnvironment) @@ -2692,14 +2609,6 @@ func FigureClusterName(clusterHint string, instanceKey *InstanceKey, thisInstanc if clusterInfo, err := ReadClusterInfo(clusterHint); err == nil && clusterInfo != nil { return clusterInfo.ClusterName, nil } - // Exact cluster alias match: - if clustersInfo, err := ReadClustersInfo(""); err == nil { - for _, clusterInfo := range clustersInfo { - if clusterInfo.ClusterAlias == clusterHint { - return clusterInfo.ClusterName, nil - } - } - } } clusterByInstanceKey := func(instanceKey *InstanceKey) (hasResult bool, clusterName string, err error) { diff --git a/go/vt/orchestrator/inst/instance_dao_test.go b/go/vt/orchestrator/inst/instance_dao_test.go index c4f3032912d..08334b567a8 100644 --- a/go/vt/orchestrator/inst/instance_dao_test.go +++ b/go/vt/orchestrator/inst/instance_dao_test.go @@ -60,17 +60,17 @@ func TestMkInsertOdkuSingle(t *testing.T) { version, major_version, version_comment, binlog_server, read_only, binlog_format, binlog_row_image, log_bin, log_replica_updates, binary_log_file, binary_log_pos, source_host, source_port, replica_sql_running, replica_io_running, replication_sql_thread_state, replication_io_thread_state, has_replication_filters, supports_oracle_gtid, oracle_gtid, source_uuid, ancestry_uuid, executed_gtid_set, gtid_mode, gtid_purged, gtid_errant, mariadb_gtid, pseudo_gtid, - source_log_file, read_source_log_pos, relay_source_log_file, exec_source_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, replication_lag_seconds, replica_lag_seconds, sql_delay, num_replica_hosts, replica_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, replication_depth, is_co_primary, has_replication_credentials, allow_tls, semi_sync_enforced, semi_sync_primary_enabled, semi_sync_primary_timeout, semi_sync_primary_wait_for_replica_count, semi_sync_replica_enabled, semi_sync_primary_status, semi_sync_primary_clients, semi_sync_replica_status, instance_alias, last_discovery_latency, replication_group_name, replication_group_is_single_primary_mode, replication_group_member_state, replication_group_member_role, replication_group_members, replication_group_primary_host, replication_group_primary_port, last_seen) + source_log_file, read_source_log_pos, relay_source_log_file, exec_source_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, replication_lag_seconds, replica_lag_seconds, sql_delay, num_replica_hosts, replica_hosts, cluster_name, data_center, region, physical_environment, replication_depth, is_co_primary, has_replication_credentials, allow_tls, semi_sync_enforced, semi_sync_primary_enabled, semi_sync_primary_timeout, semi_sync_primary_wait_for_replica_count, semi_sync_replica_enabled, semi_sync_primary_status, semi_sync_primary_clients, semi_sync_replica_status, instance_alias, last_discovery_latency, replication_group_name, replication_group_is_single_primary_mode, replication_group_member_state, replication_group_member_role, replication_group_members, replication_group_primary_host, replication_group_primary_port, last_seen) VALUES - (?, ?, NOW(), NOW(), 1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW()) + (?, ?, NOW(), NOW(), 1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW()) ON DUPLICATE KEY UPDATE - hostname=VALUES(hostname), port=VALUES(port), last_checked=VALUES(last_checked), last_attempted_check=VALUES(last_attempted_check), last_check_partial_success=VALUES(last_check_partial_success), server_id=VALUES(server_id), server_uuid=VALUES(server_uuid), version=VALUES(version), major_version=VALUES(major_version), version_comment=VALUES(version_comment), binlog_server=VALUES(binlog_server), read_only=VALUES(read_only), binlog_format=VALUES(binlog_format), binlog_row_image=VALUES(binlog_row_image), log_bin=VALUES(log_bin), log_replica_updates=VALUES(log_replica_updates), binary_log_file=VALUES(binary_log_file), binary_log_pos=VALUES(binary_log_pos), source_host=VALUES(source_host), source_port=VALUES(source_port), replica_sql_running=VALUES(replica_sql_running), replica_io_running=VALUES(replica_io_running), replication_sql_thread_state=VALUES(replication_sql_thread_state), replication_io_thread_state=VALUES(replication_io_thread_state), has_replication_filters=VALUES(has_replication_filters), supports_oracle_gtid=VALUES(supports_oracle_gtid), oracle_gtid=VALUES(oracle_gtid), source_uuid=VALUES(source_uuid), ancestry_uuid=VALUES(ancestry_uuid), executed_gtid_set=VALUES(executed_gtid_set), gtid_mode=VALUES(gtid_mode), gtid_purged=VALUES(gtid_purged), gtid_errant=VALUES(gtid_errant), mariadb_gtid=VALUES(mariadb_gtid), pseudo_gtid=VALUES(pseudo_gtid), source_log_file=VALUES(source_log_file), read_source_log_pos=VALUES(read_source_log_pos), relay_source_log_file=VALUES(relay_source_log_file), exec_source_log_pos=VALUES(exec_source_log_pos), relay_log_file=VALUES(relay_log_file), relay_log_pos=VALUES(relay_log_pos), last_sql_error=VALUES(last_sql_error), last_io_error=VALUES(last_io_error), replication_lag_seconds=VALUES(replication_lag_seconds), replica_lag_seconds=VALUES(replica_lag_seconds), sql_delay=VALUES(sql_delay), num_replica_hosts=VALUES(num_replica_hosts), replica_hosts=VALUES(replica_hosts), cluster_name=VALUES(cluster_name), suggested_cluster_alias=VALUES(suggested_cluster_alias), data_center=VALUES(data_center), region=VALUES(region), physical_environment=VALUES(physical_environment), replication_depth=VALUES(replication_depth), is_co_primary=VALUES(is_co_primary), has_replication_credentials=VALUES(has_replication_credentials), allow_tls=VALUES(allow_tls), + hostname=VALUES(hostname), port=VALUES(port), last_checked=VALUES(last_checked), last_attempted_check=VALUES(last_attempted_check), last_check_partial_success=VALUES(last_check_partial_success), server_id=VALUES(server_id), server_uuid=VALUES(server_uuid), version=VALUES(version), major_version=VALUES(major_version), version_comment=VALUES(version_comment), binlog_server=VALUES(binlog_server), read_only=VALUES(read_only), binlog_format=VALUES(binlog_format), binlog_row_image=VALUES(binlog_row_image), log_bin=VALUES(log_bin), log_replica_updates=VALUES(log_replica_updates), binary_log_file=VALUES(binary_log_file), binary_log_pos=VALUES(binary_log_pos), source_host=VALUES(source_host), source_port=VALUES(source_port), replica_sql_running=VALUES(replica_sql_running), replica_io_running=VALUES(replica_io_running), replication_sql_thread_state=VALUES(replication_sql_thread_state), replication_io_thread_state=VALUES(replication_io_thread_state), has_replication_filters=VALUES(has_replication_filters), supports_oracle_gtid=VALUES(supports_oracle_gtid), oracle_gtid=VALUES(oracle_gtid), source_uuid=VALUES(source_uuid), ancestry_uuid=VALUES(ancestry_uuid), executed_gtid_set=VALUES(executed_gtid_set), gtid_mode=VALUES(gtid_mode), gtid_purged=VALUES(gtid_purged), gtid_errant=VALUES(gtid_errant), mariadb_gtid=VALUES(mariadb_gtid), pseudo_gtid=VALUES(pseudo_gtid), source_log_file=VALUES(source_log_file), read_source_log_pos=VALUES(read_source_log_pos), relay_source_log_file=VALUES(relay_source_log_file), exec_source_log_pos=VALUES(exec_source_log_pos), relay_log_file=VALUES(relay_log_file), relay_log_pos=VALUES(relay_log_pos), last_sql_error=VALUES(last_sql_error), last_io_error=VALUES(last_io_error), replication_lag_seconds=VALUES(replication_lag_seconds), replica_lag_seconds=VALUES(replica_lag_seconds), sql_delay=VALUES(sql_delay), num_replica_hosts=VALUES(num_replica_hosts), replica_hosts=VALUES(replica_hosts), cluster_name=VALUES(cluster_name), data_center=VALUES(data_center), region=VALUES(region), physical_environment=VALUES(physical_environment), replication_depth=VALUES(replication_depth), is_co_primary=VALUES(is_co_primary), has_replication_credentials=VALUES(has_replication_credentials), allow_tls=VALUES(allow_tls), semi_sync_enforced=VALUES(semi_sync_enforced), semi_sync_primary_enabled=VALUES(semi_sync_primary_enabled), semi_sync_primary_timeout=VALUES(semi_sync_primary_timeout), semi_sync_primary_wait_for_replica_count=VALUES(semi_sync_primary_wait_for_replica_count), semi_sync_replica_enabled=VALUES(semi_sync_replica_enabled), semi_sync_primary_status=VALUES(semi_sync_primary_status), semi_sync_primary_clients=VALUES(semi_sync_primary_clients), semi_sync_replica_status=VALUES(semi_sync_replica_status), instance_alias=VALUES(instance_alias), last_discovery_latency=VALUES(last_discovery_latency), replication_group_name=VALUES(replication_group_name), replication_group_is_single_primary_mode=VALUES(replication_group_is_single_primary_mode), replication_group_member_state=VALUES(replication_group_member_state), replication_group_member_role=VALUES(replication_group_member_role), replication_group_members=VALUES(replication_group_members), replication_group_primary_host=VALUES(replication_group_primary_host), replication_group_primary_port=VALUES(replication_group_primary_port), last_seen=VALUES(last_seen) ` a1 := `i710, 3306, 710, , 5.6.7, 5.6, MySQL, false, false, STATEMENT, FULL, false, false, , 0, , 0, - false, false, 0, 0, false, false, false, , , , , , , false, false, , 0, mysql.000007, 10, , 0, , , {0 false}, {0 false}, 0, 0, [], , , , , , 0, false, false, false, false, false, 0, 0, false, false, 0, false, , 0, , false, , , [], , 0, ` + false, false, 0, 0, false, false, false, , , , , , , false, false, , 0, mysql.000007, 10, , 0, , , {0 false}, {0 false}, 0, 0, [], , , , , 0, false, false, false, false, false, 0, 0, false, false, 0, false, , 0, , false, , , [], , 0, ` sql1, args1, err := mkInsertOdkuForInstances(instances[:1], false, true) test.S(t).ExpectNil(err) @@ -83,22 +83,22 @@ func TestMkInsertOdkuThree(t *testing.T) { // three instances s3 := `INSERT INTO database_instance - (hostname, port, last_checked, last_attempted_check, last_check_partial_success, server_id, server_uuid, version, major_version, version_comment, binlog_server, read_only, binlog_format, binlog_row_image, log_bin, log_replica_updates, binary_log_file, binary_log_pos, source_host, source_port, replica_sql_running, replica_io_running, replication_sql_thread_state, replication_io_thread_state, has_replication_filters, supports_oracle_gtid, oracle_gtid, source_uuid, ancestry_uuid, executed_gtid_set, gtid_mode, gtid_purged, gtid_errant, mariadb_gtid, pseudo_gtid, source_log_file, read_source_log_pos, relay_source_log_file, exec_source_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, replication_lag_seconds, replica_lag_seconds, sql_delay, num_replica_hosts, replica_hosts, cluster_name, suggested_cluster_alias, data_center, region, physical_environment, replication_depth, is_co_primary, has_replication_credentials, allow_tls, semi_sync_enforced, semi_sync_primary_enabled, semi_sync_primary_timeout, semi_sync_primary_wait_for_replica_count, + (hostname, port, last_checked, last_attempted_check, last_check_partial_success, server_id, server_uuid, version, major_version, version_comment, binlog_server, read_only, binlog_format, binlog_row_image, log_bin, log_replica_updates, binary_log_file, binary_log_pos, source_host, source_port, replica_sql_running, replica_io_running, replication_sql_thread_state, replication_io_thread_state, has_replication_filters, supports_oracle_gtid, oracle_gtid, source_uuid, ancestry_uuid, executed_gtid_set, gtid_mode, gtid_purged, gtid_errant, mariadb_gtid, pseudo_gtid, source_log_file, read_source_log_pos, relay_source_log_file, exec_source_log_pos, relay_log_file, relay_log_pos, last_sql_error, last_io_error, replication_lag_seconds, replica_lag_seconds, sql_delay, num_replica_hosts, replica_hosts, cluster_name, data_center, region, physical_environment, replication_depth, is_co_primary, has_replication_credentials, allow_tls, semi_sync_enforced, semi_sync_primary_enabled, semi_sync_primary_timeout, semi_sync_primary_wait_for_replica_count, semi_sync_replica_enabled, semi_sync_primary_status, semi_sync_primary_clients, semi_sync_replica_status, instance_alias, last_discovery_latency, replication_group_name, replication_group_is_single_primary_mode, replication_group_member_state, replication_group_member_role, replication_group_members, replication_group_primary_host, replication_group_primary_port, last_seen) VALUES - (?, ?, NOW(), NOW(), 1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW()), - (?, ?, NOW(), NOW(), 1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW()), - (?, ?, NOW(), NOW(), 1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW()) + (?, ?, NOW(), NOW(), 1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW()), + (?, ?, NOW(), NOW(), 1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW()), + (?, ?, NOW(), NOW(), 1, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, NOW()) ON DUPLICATE KEY UPDATE - hostname=VALUES(hostname), port=VALUES(port), last_checked=VALUES(last_checked), last_attempted_check=VALUES(last_attempted_check), last_check_partial_success=VALUES(last_check_partial_success), server_id=VALUES(server_id), server_uuid=VALUES(server_uuid), version=VALUES(version), major_version=VALUES(major_version), version_comment=VALUES(version_comment), binlog_server=VALUES(binlog_server), read_only=VALUES(read_only), binlog_format=VALUES(binlog_format), binlog_row_image=VALUES(binlog_row_image), log_bin=VALUES(log_bin), log_replica_updates=VALUES(log_replica_updates), binary_log_file=VALUES(binary_log_file), binary_log_pos=VALUES(binary_log_pos), source_host=VALUES(source_host), source_port=VALUES(source_port), replica_sql_running=VALUES(replica_sql_running), replica_io_running=VALUES(replica_io_running), replication_sql_thread_state=VALUES(replication_sql_thread_state), replication_io_thread_state=VALUES(replication_io_thread_state), has_replication_filters=VALUES(has_replication_filters), supports_oracle_gtid=VALUES(supports_oracle_gtid), oracle_gtid=VALUES(oracle_gtid), source_uuid=VALUES(source_uuid), ancestry_uuid=VALUES(ancestry_uuid), executed_gtid_set=VALUES(executed_gtid_set), gtid_mode=VALUES(gtid_mode), gtid_purged=VALUES(gtid_purged), gtid_errant=VALUES(gtid_errant), mariadb_gtid=VALUES(mariadb_gtid), pseudo_gtid=VALUES(pseudo_gtid), source_log_file=VALUES(source_log_file), read_source_log_pos=VALUES(read_source_log_pos), relay_source_log_file=VALUES(relay_source_log_file), exec_source_log_pos=VALUES(exec_source_log_pos), relay_log_file=VALUES(relay_log_file), relay_log_pos=VALUES(relay_log_pos), last_sql_error=VALUES(last_sql_error), last_io_error=VALUES(last_io_error), replication_lag_seconds=VALUES(replication_lag_seconds), replica_lag_seconds=VALUES(replica_lag_seconds), sql_delay=VALUES(sql_delay), num_replica_hosts=VALUES(num_replica_hosts), replica_hosts=VALUES(replica_hosts), cluster_name=VALUES(cluster_name), suggested_cluster_alias=VALUES(suggested_cluster_alias), data_center=VALUES(data_center), region=VALUES(region), + hostname=VALUES(hostname), port=VALUES(port), last_checked=VALUES(last_checked), last_attempted_check=VALUES(last_attempted_check), last_check_partial_success=VALUES(last_check_partial_success), server_id=VALUES(server_id), server_uuid=VALUES(server_uuid), version=VALUES(version), major_version=VALUES(major_version), version_comment=VALUES(version_comment), binlog_server=VALUES(binlog_server), read_only=VALUES(read_only), binlog_format=VALUES(binlog_format), binlog_row_image=VALUES(binlog_row_image), log_bin=VALUES(log_bin), log_replica_updates=VALUES(log_replica_updates), binary_log_file=VALUES(binary_log_file), binary_log_pos=VALUES(binary_log_pos), source_host=VALUES(source_host), source_port=VALUES(source_port), replica_sql_running=VALUES(replica_sql_running), replica_io_running=VALUES(replica_io_running), replication_sql_thread_state=VALUES(replication_sql_thread_state), replication_io_thread_state=VALUES(replication_io_thread_state), has_replication_filters=VALUES(has_replication_filters), supports_oracle_gtid=VALUES(supports_oracle_gtid), oracle_gtid=VALUES(oracle_gtid), source_uuid=VALUES(source_uuid), ancestry_uuid=VALUES(ancestry_uuid), executed_gtid_set=VALUES(executed_gtid_set), gtid_mode=VALUES(gtid_mode), gtid_purged=VALUES(gtid_purged), gtid_errant=VALUES(gtid_errant), mariadb_gtid=VALUES(mariadb_gtid), pseudo_gtid=VALUES(pseudo_gtid), source_log_file=VALUES(source_log_file), read_source_log_pos=VALUES(read_source_log_pos), relay_source_log_file=VALUES(relay_source_log_file), exec_source_log_pos=VALUES(exec_source_log_pos), relay_log_file=VALUES(relay_log_file), relay_log_pos=VALUES(relay_log_pos), last_sql_error=VALUES(last_sql_error), last_io_error=VALUES(last_io_error), replication_lag_seconds=VALUES(replication_lag_seconds), replica_lag_seconds=VALUES(replica_lag_seconds), sql_delay=VALUES(sql_delay), num_replica_hosts=VALUES(num_replica_hosts), replica_hosts=VALUES(replica_hosts), cluster_name=VALUES(cluster_name), data_center=VALUES(data_center), region=VALUES(region), physical_environment=VALUES(physical_environment), replication_depth=VALUES(replication_depth), is_co_primary=VALUES(is_co_primary), has_replication_credentials=VALUES(has_replication_credentials), allow_tls=VALUES(allow_tls), semi_sync_enforced=VALUES(semi_sync_enforced), semi_sync_primary_enabled=VALUES(semi_sync_primary_enabled), semi_sync_primary_timeout=VALUES(semi_sync_primary_timeout), semi_sync_primary_wait_for_replica_count=VALUES(semi_sync_primary_wait_for_replica_count), semi_sync_replica_enabled=VALUES(semi_sync_replica_enabled), semi_sync_primary_status=VALUES(semi_sync_primary_status), semi_sync_primary_clients=VALUES(semi_sync_primary_clients), semi_sync_replica_status=VALUES(semi_sync_replica_status), instance_alias=VALUES(instance_alias), last_discovery_latency=VALUES(last_discovery_latency), replication_group_name=VALUES(replication_group_name), replication_group_is_single_primary_mode=VALUES(replication_group_is_single_primary_mode), replication_group_member_state=VALUES(replication_group_member_state), replication_group_member_role=VALUES(replication_group_member_role), replication_group_members=VALUES(replication_group_members), replication_group_primary_host=VALUES(replication_group_primary_host), replication_group_primary_port=VALUES(replication_group_primary_port), last_seen=VALUES(last_seen) ` a3 := ` - i710, 3306, 710, , 5.6.7, 5.6, MySQL, false, false, STATEMENT, FULL, false, false, , 0, , 0, false, false, 0, 0, false, false, false, , , , , , , false, false, , 0, mysql.000007, 10, , 0, , , {0 false}, {0 false}, 0, 0, [], , , , , , 0, false, false, false, false, false, 0, 0, false, false, 0, false, , 0, , false, , , [], , 0, - i720, 3306, 720, , 5.6.7, 5.6, MySQL, false, false, STATEMENT, FULL, false, false, , 0, , 0, false, false, 0, 0, false, false, false, , , , , , , false, false, , 0, mysql.000007, 20, , 0, , , {0 false}, {0 false}, 0, 0, [], , , , , , 0, false, false, false, false, false, 0, 0, false, false, 0, false, , 0, , false, , , [], , 0, - i730, 3306, 730, , 5.6.7, 5.6, MySQL, false, false, STATEMENT, FULL, false, false, , 0, , 0, false, false, 0, 0, false, false, false, , , , , , , false, false, , 0, mysql.000007, 30, , 0, , , {0 false}, {0 false}, 0, 0, [], , , , , , 0, false, false, false, false, false, 0, 0, false, false, 0, false, , 0, , false, , , [], , 0, + i710, 3306, 710, , 5.6.7, 5.6, MySQL, false, false, STATEMENT, FULL, false, false, , 0, , 0, false, false, 0, 0, false, false, false, , , , , , , false, false, , 0, mysql.000007, 10, , 0, , , {0 false}, {0 false}, 0, 0, [], , , , , 0, false, false, false, false, false, 0, 0, false, false, 0, false, , 0, , false, , , [], , 0, + i720, 3306, 720, , 5.6.7, 5.6, MySQL, false, false, STATEMENT, FULL, false, false, , 0, , 0, false, false, 0, 0, false, false, false, , , , , , , false, false, , 0, mysql.000007, 20, , 0, , , {0 false}, {0 false}, 0, 0, [], , , , , 0, false, false, false, false, false, 0, 0, false, false, 0, false, , 0, , false, , , [], , 0, + i730, 3306, 730, , 5.6.7, 5.6, MySQL, false, false, STATEMENT, FULL, false, false, , 0, , 0, false, false, 0, 0, false, false, false, , , , , , , false, false, , 0, mysql.000007, 30, , 0, , , {0 false}, {0 false}, 0, 0, [], , , , , 0, false, false, false, false, false, 0, 0, false, false, 0, false, , 0, , false, , , [], , 0, ` sql3, args3, err := mkInsertOdkuForInstances(instances[:3], true, true) diff --git a/go/vt/orchestrator/inst/instance_topology.go b/go/vt/orchestrator/inst/instance_topology.go index 417cd47896a..ed3bf7daf63 100644 --- a/go/vt/orchestrator/inst/instance_topology.go +++ b/go/vt/orchestrator/inst/instance_topology.go @@ -1087,54 +1087,6 @@ Cleanup: return instance, err } -// ReattachReplicaPrimaryHost reattaches a replica back onto its primary by undoing a DetachReplicaPrimaryHost operation -func ReattachReplicaPrimaryHost(instanceKey *InstanceKey) (*Instance, error) { - instance, err := ReadTopologyInstance(instanceKey) - if err != nil { - return instance, err - } - if !instance.IsReplica() { - return instance, fmt.Errorf("instance is not a replica: %+v", *instanceKey) - } - if !instance.SourceKey.IsDetached() { - return instance, fmt.Errorf("instance does not seem to be detached: %+v", *instanceKey) - } - - reattachedPrimaryKey := instance.SourceKey.ReattachedKey() - - log.Infof("Will reattach primary host on %+v. Reattached key is %+v", *instanceKey, *reattachedPrimaryKey) - - if maintenanceToken, merr := BeginMaintenance(instanceKey, GetMaintenanceOwner(), "reattach-replica-primary-host"); merr != nil { - err = fmt.Errorf("Cannot begin maintenance on %+v: %v", *instanceKey, merr) - goto Cleanup - } else { - defer EndMaintenance(maintenanceToken) - } - - instance, err = StopReplication(instanceKey) - if err != nil { - goto Cleanup - } - - _, err = ChangePrimaryTo(instanceKey, reattachedPrimaryKey, &instance.ExecBinlogCoordinates, true, GTIDHintNeutral) - if err != nil { - goto Cleanup - } - // Just in case this instance used to be a primary: - _ = ReplaceAliasClusterName(instanceKey.StringCode(), reattachedPrimaryKey.StringCode()) - -Cleanup: - instance, _ = StartReplication(instanceKey) - if err != nil { - log.Error(err) - return instance, err - } - // and we're done (pending deferred functions) - AuditOperation("repoint", instanceKey, fmt.Sprintf("replica %+v reattached to primary %+v", *instanceKey, *reattachedPrimaryKey)) - - return instance, err -} - // EnableGTID will attempt to enable GTID-mode (either Oracle or MariaDB) func EnableGTID(instanceKey *InstanceKey) (*Instance, error) { instance, err := ReadTopologyInstance(instanceKey) diff --git a/go/vt/orchestrator/inst/pool.go b/go/vt/orchestrator/inst/pool.go index 834b8c042a5..648cde192eb 100644 --- a/go/vt/orchestrator/inst/pool.go +++ b/go/vt/orchestrator/inst/pool.go @@ -45,11 +45,10 @@ func NewPoolInstancesSubmission(pool string, instances string) *PoolInstancesSub // ClusterPoolInstance is an instance mapping a cluster, pool & instance type ClusterPoolInstance struct { - ClusterName string - ClusterAlias string - Pool string - Hostname string - Port int + ClusterName string + Pool string + Hostname string + Port int } func ApplyPoolInstances(submission *PoolInstancesSubmission) error { diff --git a/go/vt/orchestrator/inst/pool_dao.go b/go/vt/orchestrator/inst/pool_dao.go index dc9b4fb2972..db82d93d8ed 100644 --- a/go/vt/orchestrator/inst/pool_dao.go +++ b/go/vt/orchestrator/inst/pool_dao.go @@ -70,21 +70,18 @@ func ReadClusterPoolInstances(clusterName string, pool string) (result [](*Clust query := fmt.Sprintf(` select cluster_name, - ifnull(alias, cluster_name) as alias, database_instance_pool.* from database_instance join database_instance_pool using (hostname, port) - left join cluster_alias using (cluster_name) %s `, whereClause) err = db.QueryOrchestrator(query, args, func(m sqlutils.RowMap) error { clusterPoolInstance := ClusterPoolInstance{ - ClusterName: m.GetString("cluster_name"), - ClusterAlias: m.GetString("alias"), - Pool: m.GetString("pool"), - Hostname: m.GetString("hostname"), - Port: m.GetInt("port"), + ClusterName: m.GetString("cluster_name"), + Pool: m.GetString("pool"), + Hostname: m.GetString("hostname"), + Port: m.GetInt("port"), } result = append(result, &clusterPoolInstance) return nil diff --git a/go/vt/orchestrator/logic/command_applier.go b/go/vt/orchestrator/logic/command_applier.go index 650a20a230b..d0e6ffe4740 100644 --- a/go/vt/orchestrator/logic/command_applier.go +++ b/go/vt/orchestrator/logic/command_applier.go @@ -77,7 +77,7 @@ func (applier *CommandApplier) ApplyCommand(op string, value []byte) any { case "delete-instance-tag": return applier.deleteInstanceTag(value) case "set-cluster-alias-manual-override": - return applier.setClusterAliasManualOverride(value) + return applier.noop(value) } errMsg := fmt.Sprintf("Unknown command op: %s", op) log.Errorf(errMsg) @@ -268,13 +268,6 @@ func (applier *CommandApplier) deleteInstanceTag(value []byte) any { return err } -func (applier *CommandApplier) setClusterAliasManualOverride(value []byte) any { - var params [2]string - if err := json.Unmarshal(value, ¶ms); err != nil { - log.Error(err) - return err - } - clusterName, alias := params[0], params[1] - err := inst.SetClusterAliasManualOverride(clusterName, alias) - return err +func (applier *CommandApplier) noop(value []byte) any { + return nil } diff --git a/go/vt/orchestrator/logic/orchestrator.go b/go/vt/orchestrator/logic/orchestrator.go index 78c1f9b5bad..daa3c46da0e 100644 --- a/go/vt/orchestrator/logic/orchestrator.go +++ b/go/vt/orchestrator/logic/orchestrator.go @@ -386,7 +386,6 @@ func ContinuousDiscovery() { // But rather should invoke such routinely operations that need to be as (or roughly as) frequent // as instance poll if IsLeaderOrActive() { - go inst.UpdateClusterAliases() go inst.ExpireDowntime() go injectSeeds(&seedOnce) } @@ -395,7 +394,6 @@ func ContinuousDiscovery() { // Various periodic internal maintenance tasks go func() { if IsLeaderOrActive() { - go inst.ReviewUnseenInstances() go inst.InjectUnseenPrimaries() go inst.ForgetLongUnseenInstances() diff --git a/go/vt/orchestrator/logic/topology_recovery.go b/go/vt/orchestrator/logic/topology_recovery.go index 21ddae23024..d243d7df733 100644 --- a/go/vt/orchestrator/logic/topology_recovery.go +++ b/go/vt/orchestrator/logic/topology_recovery.go @@ -273,7 +273,6 @@ func prepareCommand(command string, topologyRecovery *TopologyRecovery) (result command = strings.Replace(command, "{failedHost}", analysisEntry.AnalyzedInstanceKey.Hostname, -1) command = strings.Replace(command, "{failedPort}", fmt.Sprintf("%d", analysisEntry.AnalyzedInstanceKey.Port), -1) command = strings.Replace(command, "{failureCluster}", analysisEntry.ClusterDetails.ClusterName, -1) - command = strings.Replace(command, "{failureClusterAlias}", analysisEntry.ClusterDetails.ClusterAlias, -1) command = strings.Replace(command, "{failureClusterDomain}", analysisEntry.ClusterDetails.ClusterDomain, -1) command = strings.Replace(command, "{countReplicas}", fmt.Sprintf("%d", analysisEntry.CountReplicas), -1) command = strings.Replace(command, "{isDowntimed}", fmt.Sprint(analysisEntry.IsDowntimed), -1) @@ -311,7 +310,6 @@ func applyEnvironmentVariables(topologyRecovery *TopologyRecovery) []string { env = append(env, fmt.Sprintf("ORC_FAILED_HOST=%s", analysisEntry.AnalyzedInstanceKey.Hostname)) env = append(env, fmt.Sprintf("ORC_FAILED_PORT=%d", analysisEntry.AnalyzedInstanceKey.Port)) env = append(env, fmt.Sprintf("ORC_FAILURE_CLUSTER=%s", analysisEntry.ClusterDetails.ClusterName)) - env = append(env, fmt.Sprintf("ORC_FAILURE_CLUSTER_ALIAS=%s", analysisEntry.ClusterDetails.ClusterAlias)) env = append(env, fmt.Sprintf("ORC_FAILURE_CLUSTER_DOMAIN=%s", analysisEntry.ClusterDetails.ClusterDomain)) env = append(env, fmt.Sprintf("ORC_COUNT_REPLICAS=%d", analysisEntry.CountReplicas)) env = append(env, fmt.Sprintf("ORC_IS_DOWNTIMED=%v", analysisEntry.IsDowntimed)) @@ -665,18 +663,6 @@ func postErsCompletion(topologyRecovery *TopologyRecovery, analysisEntry inst.Re } topologyRecovery.AddPostponedFunction(postponedFunction, fmt.Sprintf("RecoverDeadPrimary, detaching promoted primary host %+v", promotedReplica.Key)) } - func() error { - before := analysisEntry.AnalyzedInstanceKey.StringCode() - after := promotedReplica.Key.StringCode() - AuditTopologyRecovery(topologyRecovery, fmt.Sprintf("- RecoverDeadPrimary: updating cluster_alias: %v -> %v", before, after)) - //~~~inst.ReplaceClusterName(before, after) - if alias := analysisEntry.ClusterDetails.ClusterAlias; alias != "" { - inst.SetClusterAlias(promotedReplica.Key.StringCode(), alias) - } else { - inst.ReplaceAliasClusterName(before, after) - } - return nil - }() attributes.SetGeneralAttribute(analysisEntry.ClusterDetails.ClusterDomain, promotedReplica.Key.StringCode()) @@ -1304,20 +1290,6 @@ func postPrsCompletion(topologyRecovery *TopologyRecovery, analysisEntry inst.Re if promotedReplica != nil { // Success! AuditTopologyRecovery(topologyRecovery, fmt.Sprintf("%+v: successfully promoted %+v", analysisEntry.Analysis, promotedReplica.Key)) - - func() error { - before := analysisEntry.AnalyzedInstanceKey.StringCode() - after := promotedReplica.Key.StringCode() - AuditTopologyRecovery(topologyRecovery, fmt.Sprintf("- %+v: updating cluster_alias: %v -> %v", analysisEntry.Analysis, before, after)) - //~~~inst.ReplaceClusterName(before, after) - if alias := analysisEntry.ClusterDetails.ClusterAlias; alias != "" { - inst.SetClusterAlias(promotedReplica.Key.StringCode(), alias) - } else { - inst.ReplaceAliasClusterName(before, after) - } - return nil - }() - attributes.SetGeneralAttribute(analysisEntry.ClusterDetails.ClusterDomain, promotedReplica.Key.StringCode()) } } @@ -1329,7 +1301,7 @@ func electNewPrimary(ctx context.Context, analysisEntry inst.ReplicationAnalysis AuditTopologyRecovery(topologyRecovery, fmt.Sprintf("found an active or recent recovery on %+v. Will not issue another electNewPrimary.", analysisEntry.AnalyzedInstanceKey)) return false, nil, err } - log.Infof("Analysis: %v, will elect a new primary: %v", analysisEntry.Analysis, analysisEntry.SuggestedClusterAlias) + log.Infof("Analysis: %v, will elect a new primary: %v", analysisEntry.Analysis, analysisEntry.ClusterDetails.ClusterName) var promotedReplica *inst.Instance // This has to be done in the end; whether successful or not, we should mark that the recovery is done. diff --git a/go/vt/orchestrator/logic/topology_recovery_dao.go b/go/vt/orchestrator/logic/topology_recovery_dao.go index 05a0ca58798..48789f42e26 100644 --- a/go/vt/orchestrator/logic/topology_recovery_dao.go +++ b/go/vt/orchestrator/logic/topology_recovery_dao.go @@ -39,7 +39,6 @@ func AttemptFailureDetectionRegistration(analysisEntry *inst.ReplicationAnalysis util.ProcessToken.Hash, string(analysisEntry.Analysis), analysisEntry.ClusterDetails.ClusterName, - analysisEntry.ClusterDetails.ClusterAlias, analysisEntry.CountReplicas, analysisEntry.Replicas.ToCommaDelimitedList(), analysisEntry.IsActionableRecovery, @@ -61,7 +60,6 @@ func AttemptFailureDetectionRegistration(analysisEntry *inst.ReplicationAnalysis processcing_node_token, analysis, cluster_name, - cluster_alias, count_affected_replicas, replica_hosts, is_actionable, @@ -78,7 +76,6 @@ func AttemptFailureDetectionRegistration(analysisEntry *inst.ReplicationAnalysis ?, ?, ?, - ?, %s ) `, startActivePeriodHint) @@ -149,7 +146,6 @@ func writeTopologyRecovery(topologyRecovery *TopologyRecovery) (*TopologyRecover processcing_node_token, analysis, cluster_name, - cluster_alias, count_affected_replicas, replica_hosts, last_detection_id @@ -167,7 +163,6 @@ func writeTopologyRecovery(topologyRecovery *TopologyRecovery) (*TopologyRecover ?, ?, ?, - ?, (select ifnull(max(detection_id), 0) from topology_failure_detection where hostname=? and port=?) ) `, @@ -177,7 +172,6 @@ func writeTopologyRecovery(topologyRecovery *TopologyRecovery) (*TopologyRecover process.ThisHostname, util.ProcessToken.Hash, string(analysisEntry.Analysis), analysisEntry.ClusterDetails.ClusterName, - analysisEntry.ClusterDetails.ClusterAlias, analysisEntry.CountReplicas, analysisEntry.Replicas.ToCommaDelimitedList(), analysisEntry.AnalyzedInstanceKey.Hostname, analysisEntry.AnalyzedInstanceKey.Port, ) @@ -433,18 +427,6 @@ func AcknowledgeClusterRecoveries(clusterName string, owner string, comment stri } countAcknowledgedEntries = countAcknowledgedEntries + count } - { - clusterInfo, _ := inst.ReadClusterInfo(clusterName) - whereClause := `cluster_alias = ? and cluster_alias != ''` - args := sqlutils.Args(clusterInfo.ClusterAlias) - _ = clearAcknowledgedFailureDetections(whereClause, args) - count, err := acknowledgeRecoveries(owner, comment, false, whereClause, args) - if err != nil { - return count, err - } - countAcknowledgedEntries = countAcknowledgedEntries + count - - } return countAcknowledgedEntries, nil } @@ -535,7 +517,6 @@ func readRecoveries(whereCondition string, limit string, args []any) ([]*Topolog ifnull(successor_alias, '') as successor_alias, analysis, cluster_name, - cluster_alias, count_affected_replicas, replica_hosts, participating_instances, @@ -569,7 +550,6 @@ func readRecoveries(whereCondition string, limit string, args []any) ([]*Topolog topologyRecovery.AnalysisEntry.AnalyzedInstanceKey.Port = m.GetInt("port") topologyRecovery.AnalysisEntry.Analysis = inst.AnalysisCode(m.GetString("analysis")) topologyRecovery.AnalysisEntry.ClusterDetails.ClusterName = m.GetString("cluster_name") - topologyRecovery.AnalysisEntry.ClusterDetails.ClusterAlias = m.GetString("cluster_alias") topologyRecovery.AnalysisEntry.CountReplicas = m.GetUint("count_affected_replicas") _ = topologyRecovery.AnalysisEntry.ReadReplicaHostsFromString(m.GetString("replica_hosts")) @@ -664,7 +644,7 @@ func ReadRecoveryByUID(recoveryUID string) ([]*TopologyRecovery, error) { } // ReadRecentRecoveries reads latest recovery entries from topology_recovery -func ReadRecentRecoveries(clusterName string, clusterAlias string, unacknowledgedOnly bool, page int) ([]*TopologyRecovery, error) { +func ReadRecentRecoveries(clusterName string, unacknowledgedOnly bool, page int) ([]*TopologyRecovery, error) { whereConditions := []string{} whereClause := "" args := sqlutils.Args() @@ -674,9 +654,6 @@ func ReadRecentRecoveries(clusterName string, clusterAlias string, unacknowledge if clusterName != "" { whereConditions = append(whereConditions, `cluster_name=?`) args = append(args, clusterName) - } else if clusterAlias != "" { - whereConditions = append(whereConditions, `cluster_alias=?`) - args = append(args, clusterAlias) } if len(whereConditions) > 0 { whereClause = fmt.Sprintf("where %s", strings.Join(whereConditions, " and ")) @@ -703,7 +680,6 @@ func readFailureDetections(whereCondition string, limit string, args []any) ([]* processcing_node_token, analysis, cluster_name, - cluster_alias, count_affected_replicas, replica_hosts, (select max(recovery_id) from topology_recovery where topology_recovery.last_detection_id = detection_id) as related_recovery_id @@ -727,7 +703,6 @@ func readFailureDetections(whereCondition string, limit string, args []any) ([]* failureDetection.AnalysisEntry.AnalyzedInstanceKey.Port = m.GetInt("port") failureDetection.AnalysisEntry.Analysis = inst.AnalysisCode(m.GetString("analysis")) failureDetection.AnalysisEntry.ClusterDetails.ClusterName = m.GetString("cluster_name") - failureDetection.AnalysisEntry.ClusterDetails.ClusterAlias = m.GetString("cluster_alias") failureDetection.AnalysisEntry.CountReplicas = m.GetUint("count_affected_replicas") _ = failureDetection.AnalysisEntry.ReadReplicaHostsFromString(m.GetString("replica_hosts")) failureDetection.AnalysisEntry.StartActivePeriod = m.GetString("start_active_period") @@ -747,12 +722,12 @@ func readFailureDetections(whereCondition string, limit string, args []any) ([]* } // ReadRecentFailureDetections -func ReadRecentFailureDetections(clusterAlias string, page int) ([]*TopologyRecovery, error) { +func ReadRecentFailureDetections(clusterName string, page int) ([]*TopologyRecovery, error) { whereClause := "" args := sqlutils.Args() - if clusterAlias != "" { - whereClause = `where cluster_alias = ?` - args = append(args, clusterAlias) + if clusterName != "" { + whereClause = `where cluster_name = ?` + args = append(args, clusterName) } limit := ` limit ? diff --git a/go/vt/orchestrator/test/recovery_analysis.go b/go/vt/orchestrator/test/recovery_analysis.go index 03871382a35..8548374789b 100644 --- a/go/vt/orchestrator/test/recovery_analysis.go +++ b/go/vt/orchestrator/test/recovery_analysis.go @@ -46,9 +46,7 @@ type InfoForRecoveryAnalysis struct { LogFile string LogPos int64 IsStaleBinlogCoordinates int - SuggestedClusterAlias string ClusterName string - ClusterAlias string ClusterDomain string GTIDMode string LastCheckValid int @@ -92,7 +90,6 @@ func (info *InfoForRecoveryAnalysis) ConvertToRowMap() sqlutils.RowMap { rowMap := make(sqlutils.RowMap) rowMap["binary_log_file"] = sqlutils.CellData{String: info.LogFile, Valid: true} rowMap["binary_log_pos"] = sqlutils.CellData{String: fmt.Sprintf("%v", info.LogPos), Valid: true} - rowMap["cluster_alias"] = sqlutils.CellData{String: info.ClusterAlias, Valid: true} rowMap["cluster_domain"] = sqlutils.CellData{String: info.ClusterDomain, Valid: true} rowMap["cluster_name"] = sqlutils.CellData{String: info.ClusterName, Valid: true} rowMap["count_binlog_server_replicas"] = sqlutils.CellData{Valid: false} @@ -154,7 +151,6 @@ func (info *InfoForRecoveryAnalysis) ConvertToRowMap() sqlutils.RowMap { rowMap["semi_sync_replica_enabled"] = sqlutils.CellData{String: fmt.Sprintf("%v", info.SemiSyncReplicaEnabled), Valid: true} rowMap["source_host"] = sqlutils.CellData{String: info.SourceHost, Valid: true} rowMap["source_port"] = sqlutils.CellData{String: fmt.Sprintf("%v", info.SourcePort), Valid: true} - rowMap["suggested_cluster_alias"] = sqlutils.CellData{String: info.SuggestedClusterAlias, Valid: true} res, _ := prototext.Marshal(info.TabletInfo) rowMap["tablet_info"] = sqlutils.CellData{String: string(res), Valid: true} return rowMap @@ -165,7 +161,6 @@ func (info *InfoForRecoveryAnalysis) SetValuesFromTabletInfo() { info.Port = int(info.TabletInfo.MysqlPort) info.DataCenter = info.TabletInfo.Alias.Cell info.Keyspace = info.TabletInfo.Keyspace - info.ClusterName = fmt.Sprintf("%v:%d", info.TabletInfo.MysqlHostname, info.TabletInfo.MysqlPort) - info.ClusterAlias = fmt.Sprintf("%v:%d", info.TabletInfo.MysqlHostname, info.TabletInfo.MysqlPort) + info.ClusterName = fmt.Sprintf("%v:%v", info.TabletInfo.Keyspace, info.TabletInfo.Shard) info.ClusterDomain = fmt.Sprintf("%v:%d", info.TabletInfo.MysqlHostname, info.TabletInfo.MysqlPort) }