Skip to content

Commit

Permalink
feat: remove unused codes
Browse files Browse the repository at this point in the history
Signed-off-by: Manan Gupta <manan@planetscale.com>
  • Loading branch information
GuptaManan100 committed Apr 29, 2024
1 parent ca2659d commit 4f7e411
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 37 deletions.
5 changes: 0 additions & 5 deletions go/vt/vtorc/inst/analysis.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ const (
AllPrimaryReplicasNotReplicatingOrDead AnalysisCode = "AllPrimaryReplicasNotReplicatingOrDead"
LockedSemiSyncPrimaryHypothesis AnalysisCode = "LockedSemiSyncPrimaryHypothesis"
LockedSemiSyncPrimary AnalysisCode = "LockedSemiSyncPrimary"
BinlogServerFailingToConnectToPrimary AnalysisCode = "BinlogServerFailingToConnectToPrimary"
ErrantGTIDDetected AnalysisCode = "ErrantGTIDDetected"
)

Expand Down Expand Up @@ -100,15 +99,11 @@ type ReplicationAnalysis struct {
CountReplicas uint
CountValidReplicas uint
CountValidReplicatingReplicas uint
CountReplicasFailingToConnectToPrimary uint
ReplicationDepth uint
IsFailingToConnectToPrimary bool
ReplicationStopped bool
ErrantGTID string
Analysis AnalysisCode
Description string
StructureAnalysis []StructureAnalysisCode
IsBinlogServer bool
OracleGTIDImmediateTopology bool
MariaDBGTIDImmediateTopology bool
BinlogServerImmediateTopology bool
Expand Down
26 changes: 2 additions & 24 deletions go/vt/vtorc/inst/analysis_dao.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,19 +135,10 @@ func GetReplicationAnalysis(keyspace string, shard string, hints *ReplicationAna
),
0
) AS count_replicas_failing_to_connect_to_primary,
MIN(primary_instance.replication_depth) AS replication_depth,
MIN(
primary_instance.replica_sql_running = 1
AND primary_instance.replica_io_running = 0
AND primary_instance.last_io_error like '%%error %%connecting to master%%'
) AS is_failing_to_connect_to_primary,
MIN(
primary_instance.replica_sql_running = 0
OR primary_instance.replica_io_running = 0
) AS replication_stopped,
MIN(
primary_instance.binlog_server
) AS is_binlog_server,
MIN(
primary_instance.supports_oracle_gtid
) AS supports_oracle_gtid,
Expand Down Expand Up @@ -340,11 +331,7 @@ func GetReplicationAnalysis(keyspace string, shard string, hints *ReplicationAna
a.CountReplicas = m.GetUint("count_replicas")
a.CountValidReplicas = m.GetUint("count_valid_replicas")
a.CountValidReplicatingReplicas = m.GetUint("count_valid_replicating_replicas")
a.CountReplicasFailingToConnectToPrimary = m.GetUint("count_replicas_failing_to_connect_to_primary")
a.ReplicationDepth = m.GetUint("replication_depth")
a.IsFailingToConnectToPrimary = m.GetBool("is_failing_to_connect_to_primary")
a.ReplicationStopped = m.GetBool("replication_stopped")
a.IsBinlogServer = m.GetBool("is_binlog_server")
a.ErrantGTID = m.GetString("gtid_errant")

countValidOracleGTIDReplicas := m.GetUint("count_valid_oracle_gtid_replicas")
Expand Down Expand Up @@ -377,8 +364,8 @@ func GetReplicationAnalysis(keyspace string, shard string, hints *ReplicationAna
a.IsReadOnly = m.GetUint("read_only") == 1

if !a.LastCheckValid {
analysisMessage := fmt.Sprintf("analysis: Alias: %+v, Keyspace: %+v, Shard: %+v, IsPrimary: %+v, LastCheckValid: %+v, LastCheckPartialSuccess: %+v, CountReplicas: %+v, CountValidReplicas: %+v, CountValidReplicatingReplicas: %+v, CountLaggingReplicas: %+v, CountDelayedReplicas: %+v, CountReplicasFailingToConnectToPrimary: %+v",
a.AnalyzedInstanceAlias, a.ClusterDetails.Keyspace, a.ClusterDetails.Shard, a.IsPrimary, a.LastCheckValid, a.LastCheckPartialSuccess, a.CountReplicas, a.CountValidReplicas, a.CountValidReplicatingReplicas, a.CountLaggingReplicas, a.CountDelayedReplicas, a.CountReplicasFailingToConnectToPrimary,
analysisMessage := fmt.Sprintf("analysis: Alias: %+v, Keyspace: %+v, Shard: %+v, IsPrimary: %+v, LastCheckValid: %+v, LastCheckPartialSuccess: %+v, CountReplicas: %+v, CountValidReplicas: %+v, CountValidReplicatingReplicas: %+v, CountLaggingReplicas: %+v, CountDelayedReplicas: %+v",
a.AnalyzedInstanceAlias, a.ClusterDetails.Keyspace, a.ClusterDetails.Shard, a.IsPrimary, a.LastCheckValid, a.LastCheckPartialSuccess, a.CountReplicas, a.CountValidReplicas, a.CountValidReplicatingReplicas, a.CountLaggingReplicas, a.CountDelayedReplicas,
)
if util.ClearToLog("analysis_dao", analysisMessage) {
log.Infof(analysisMessage)
Expand Down Expand Up @@ -507,11 +494,6 @@ func GetReplicationAnalysis(keyspace string, shard string, hints *ReplicationAna
a.Analysis = UnreachablePrimary
a.Description = "Primary cannot be reached by vtorc but it has replicating replicas; possibly a network/host issue"
//
} else if a.IsPrimary && !a.LastCheckValid && a.LastCheckPartialSuccess && a.CountReplicasFailingToConnectToPrimary > 0 && a.CountValidReplicas > 0 && a.CountValidReplicatingReplicas > 0 {
// there's partial success, but also at least one replica is failing to connect to primary
a.Analysis = UnreachablePrimary
a.Description = "Primary cannot be reached by vtorc but it has replicating replicas; possibly a network/host issue"
//
} else if a.IsPrimary && a.SemiSyncPrimaryEnabled && a.SemiSyncPrimaryStatus && a.SemiSyncPrimaryWaitForReplicaCount > 0 && a.SemiSyncPrimaryClients < a.SemiSyncPrimaryWaitForReplicaCount {
if isStaleBinlogCoordinates {
a.Analysis = LockedSemiSyncPrimary
Expand All @@ -536,10 +518,6 @@ func GetReplicationAnalysis(keyspace string, shard string, hints *ReplicationAna
a.Analysis = AllPrimaryReplicasNotReplicatingOrDead
a.Description = "Primary is reachable but none of its replicas is replicating"
//
} else if a.IsBinlogServer && a.IsFailingToConnectToPrimary {
a.Analysis = BinlogServerFailingToConnectToPrimary
a.Description = "Binlog server is unable to connect to its primary"
//
}
// else if a.IsPrimary && a.CountReplicas == 0 {
// a.Analysis = PrimaryWithoutReplicas
Expand Down
8 changes: 0 additions & 8 deletions go/vt/vtorc/test/recovery_analysis.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,11 @@ type InfoForRecoveryAnalysis struct {
CountReplicas uint
CountValidReplicas uint
CountValidReplicatingReplicas uint
CountReplicasFailingToConnectToPrimary uint
CountDowntimedReplicas uint
ReplicationDepth uint
IsFailingToConnectToPrimary int
ReplicationStopped int
IsDowntimed int
DowntimeEndTimestamp string
DowntimeRemainingSeconds int
IsBinlogServer int
CountValidOracleGTIDReplicas uint
CountValidMariaDBGTIDReplicas uint
CountValidBinlogServerReplicas uint
Expand Down Expand Up @@ -100,7 +96,6 @@ func (info *InfoForRecoveryAnalysis) ConvertToRowMap() sqlutils.RowMap {
rowMap["count_mixed_based_logging_replicas"] = sqlutils.CellData{String: fmt.Sprintf("%v", info.CountMixedBasedLoggingReplicas), Valid: true}
rowMap["count_oracle_gtid_replicas"] = sqlutils.CellData{Valid: false}
rowMap["count_replicas"] = sqlutils.CellData{String: fmt.Sprintf("%v", info.CountReplicas), Valid: true}
rowMap["count_replicas_failing_to_connect_to_primary"] = sqlutils.CellData{String: fmt.Sprintf("%v", info.CountReplicasFailingToConnectToPrimary), Valid: true}
rowMap["count_row_based_logging_replicas"] = sqlutils.CellData{String: fmt.Sprintf("%v", info.CountRowBasedLoggingReplicas), Valid: true}
rowMap["count_semi_sync_replicas"] = sqlutils.CellData{String: fmt.Sprintf("%v", info.CountSemiSyncReplicasEnabled), Valid: true}
rowMap["count_statement_based_logging_replicas"] = sqlutils.CellData{String: fmt.Sprintf("%v", info.CountStatementBasedLoggingReplicas), Valid: true}
Expand All @@ -116,10 +111,8 @@ func (info *InfoForRecoveryAnalysis) ConvertToRowMap() sqlutils.RowMap {
rowMap["gtid_errant"] = sqlutils.CellData{String: info.ErrantGTID, Valid: true}
rowMap["gtid_mode"] = sqlutils.CellData{String: info.GTIDMode, Valid: true}
rowMap["hostname"] = sqlutils.CellData{String: info.Hostname, Valid: true}
rowMap["is_binlog_server"] = sqlutils.CellData{String: fmt.Sprintf("%v", info.IsBinlogServer), Valid: true}
rowMap["is_co_primary"] = sqlutils.CellData{String: fmt.Sprintf("%v", info.IsCoPrimary), Valid: true}
rowMap["is_downtimed"] = sqlutils.CellData{String: fmt.Sprintf("%v", info.IsDowntimed), Valid: true}
rowMap["is_failing_to_connect_to_primary"] = sqlutils.CellData{String: fmt.Sprintf("%v", info.IsFailingToConnectToPrimary), Valid: true}
rowMap["is_invalid"] = sqlutils.CellData{String: fmt.Sprintf("%v", info.IsInvalid), Valid: true}
rowMap["is_last_check_valid"] = sqlutils.CellData{String: fmt.Sprintf("%v", info.LastCheckValid), Valid: true}
rowMap["is_primary"] = sqlutils.CellData{String: fmt.Sprintf("%v", info.IsPrimary), Valid: true}
Expand All @@ -143,7 +136,6 @@ func (info *InfoForRecoveryAnalysis) ConvertToRowMap() sqlutils.RowMap {
rowMap["primary_timestamp"] = sqlutils.CellData{String: fmt.Sprintf("%v", info.PrimaryTimestamp), Valid: true}
rowMap["read_only"] = sqlutils.CellData{String: fmt.Sprintf("%v", info.ReadOnly), Valid: true}
rowMap["region"] = sqlutils.CellData{String: info.Region, Valid: true}
rowMap["replication_depth"] = sqlutils.CellData{String: fmt.Sprintf("%v", info.ReplicationDepth), Valid: true}
rowMap["replication_stopped"] = sqlutils.CellData{String: fmt.Sprintf("%v", info.ReplicationStopped), Valid: true}
rowMap["semi_sync_primary_clients"] = sqlutils.CellData{String: fmt.Sprintf("%v", info.SemiSyncPrimaryClients), Valid: true}
rowMap["semi_sync_primary_enabled"] = sqlutils.CellData{String: fmt.Sprintf("%v", info.SemiSyncPrimaryEnabled), Valid: true}
Expand Down

0 comments on commit 4f7e411

Please sign in to comment.