-
Notifications
You must be signed in to change notification settings - Fork 935
Add structure warning to replication-analysis
when all masters are read_only
#878
Changes from 16 commits
f2f7402
0848d25
bd7d8e8
2739486
48ed4eb
eed30fc
895a011
b3ccd73
4a5b67f
1977891
65d83f9
ff13e0b
fa8c923
a1b3080
f0078eb
eb75598
e45511a
a2bbdce
7943eac
42f0747
940cc59
b7e0df8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,6 +57,7 @@ func GetReplicationAnalysis(clusterName string, hints *ReplicationAnalysisHints) | |
|
||
args := sqlutils.Args(ValidSecondsFromSeenToLastAttemptedCheck(), config.Config.ReasonableReplicationLagSeconds, clusterName) | ||
analysisQueryReductionClause := `` | ||
|
||
if config.Config.ReduceReplicationAnalysisCount { | ||
analysisQueryReductionClause = ` | ||
HAVING | ||
|
@@ -90,15 +91,17 @@ func GetReplicationAnalysis(clusterName string, hints *ReplicationAnalysisHints) | |
SELECT | ||
master_instance.hostname, | ||
master_instance.port, | ||
MIN(master_instance.data_center) AS data_center, | ||
MIN(master_instance.physical_environment) AS physical_environment, | ||
master_instance.read_only AS read_only, | ||
SUM(master_instance.is_co_master) AS co_master_count, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this will be either |
||
MIN(master_instance.data_center) AS data_center, | ||
MIN(master_instance.physical_environment) AS physical_environment, | ||
MIN(master_instance.master_host) AS master_host, | ||
MIN(master_instance.master_port) AS master_port, | ||
MIN(master_instance.cluster_name) AS cluster_name, | ||
MIN(IFNULL(cluster_alias.alias, master_instance.cluster_name)) AS cluster_alias, | ||
MIN( | ||
master_instance.last_checked <= master_instance.last_seen | ||
and master_instance.last_attempted_check <= master_instance.last_seen + interval ? second | ||
master_instance.last_checked <= master_instance.last_seen | ||
and master_instance.last_attempted_check <= master_instance.last_seen + interval ? second | ||
) = 1 AS is_last_check_valid, | ||
MIN(master_instance.last_check_partial_success) as last_check_partial_success, | ||
MIN(master_instance.master_host IN ('' , '_') | ||
|
@@ -241,6 +244,8 @@ func GetReplicationAnalysis(clusterName string, hints *ReplicationAnalysisHints) | |
is_cluster_master DESC, | ||
count_replicas DESC | ||
`, analysisQueryReductionClause) | ||
|
||
coMasterROCount := 0 | ||
err := db.QueryOrchestrator(query, args, func(m sqlutils.RowMap) error { | ||
a := ReplicationAnalysis{ | ||
Analysis: NoProblem, | ||
|
@@ -296,6 +301,10 @@ func GetReplicationAnalysis(clusterName string, hints *ReplicationAnalysisHints) | |
a.CountDelayedReplicas = m.GetUint("count_delayed_replicas") | ||
a.CountLaggingReplicas = m.GetUint("count_lagging_replicas") | ||
|
||
if a.IsCoMaster && m.GetUint("read_only") == 1 { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please read |
||
coMasterROCount++ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This look can iterate over multiple clusters. You only want to count the number of co masters per cluster. So this trick of A cluster with two co-masters appears in So, as I'm writing this, I'm rethinking our earlier discussion. if the master is a |
||
} | ||
|
||
if !a.LastCheckValid { | ||
analysisMessage := fmt.Sprintf("analysis: IsMaster: %+v, LastCheckValid: %+v, LastCheckPartialSuccess: %+v, CountReplicas: %+v, CountValidReplicatingReplicas: %+v, CountLaggingReplicas: %+v, CountDelayedReplicas: %+v, ", | ||
a.IsMaster, a.LastCheckValid, a.LastCheckPartialSuccess, a.CountReplicas, a.CountValidReplicatingReplicas, a.CountLaggingReplicas, a.CountDelayedReplicas, | ||
|
@@ -477,6 +486,14 @@ func GetReplicationAnalysis(clusterName string, hints *ReplicationAnalysisHints) | |
if a.MaxReplicaGTIDErrant != "" { | ||
a.StructureAnalysis = append(a.StructureAnalysis, ErrantGTIDStructureWarning) | ||
} | ||
|
||
if a.IsMaster && m.GetUint("read_only") == 1 && m.GetString("master_host") == "" { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given earlier discussion, I think we can skip the check about |
||
a.StructureAnalysis = append(a.StructureAnalysis, NoWriteableMasterStructureWarning) | ||
} | ||
if a.IsCoMaster && coMasterROCount == m.GetInt("co_master_count") { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Given earlier discussion, I think we can skip this block altogether. |
||
a.StructureAnalysis = append(a.StructureAnalysis, NoWriteableMasterStructureWarning) | ||
} | ||
|
||
} | ||
appendAnalysis(&a) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍