-
Notifications
You must be signed in to change notification settings - Fork 937
Add structure warning to replication-analysis
when all masters are read_only
#878
Conversation
… cluster are read_only
go/inst/analysis.go
Outdated
@@ -64,6 +64,7 @@ const ( | |||
DifferentGTIDModesStructureWarning = "DifferentGTIDModesStructureWarning" | |||
ErrantGTIDStructureWarning = "ErrantGTIDStructureWarning" | |||
NoFailoverSupportStructureWarning = "NoFailoverSupportStructureWarning" | |||
NoWriteableNodesWarning = "NoWriteableNodesStructureWarning" |
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.
We should be concerned with non-writable master, for sure. The rest of the nodes are practically irrelevant (that is, we expect them to be read-only anyhow).
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.
I'd name this: NonWritableMasterWarning
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.
@shlomi-noach Make sense, I've updated to warn if the current master is read-only
.
To elaborate, on a normal topology, we only expect the master to be writable. Right now we're interested in a scenario where the master is read-only. We normally expect (and hope) for replicas to be read-only, too, but I've seen cases out there where intermediate master could be taking writes. Since we're aiming at the global audience, my suggestion is to let go of looking into the replicas. So we should only care if we have a read-only master. Another thing is that we want to check is the case where we have co-masters. In a co-master (circular master-master) setup, it's OK if one of the co-masters is read-only. It's also OK (though generally discouraged) if both co-masters are writable. It's not OK if both are read-only... |
I'l take a look at the co-master scenarios as well |
@shlomi-noach I've updated the PR body. I've tested new logic to omit warnings on |
go/inst/analysis_dao.go
Outdated
@@ -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, |
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.
👍
go/inst/analysis_dao.go
Outdated
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 comment
The reason will be displayed to describe this comment to others. Learn more.
this will be either 0
or 1
, not what you'd expect. See later discussion.
go/inst/analysis_dao.go
Outdated
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Please read m.GetUint("read_only")
into a variable first. In fact, it's really interesting information, make that a member in the ReplicationAnalysis
struct
go/inst/analysis_dao.go
Outdated
@@ -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 { | |||
coMasterROCount++ |
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.
This look can iterate over multiple clusters. You only want to count the number of co masters per cluster. So this trick of coMasterROCount++
won't work.
A cluster with two co-masters appears in orchestrator
as a single cluster, not as two clusters. One of the two co-masters is deemed to be the "primary" master. If one is read-only and another is writable, it's the writable. If both are read-only or both are writable, I believe the choice is alphabetic.
So, as I'm writing this, I'm rethinking our earlier discussion. if the master is a co_master
and is read_only
, then the other co-master is also read_only
(or else IT would have been the primary master!). This simplifies things and you can get rid of coMasterROCount
.
go/inst/analysis_dao.go
Outdated
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
"master_host"
is already read in a.AnalyzedInstanceMasterKey
. You can ask if a.AnalyzedInstanceMasterKey.IsValid()
(== non empty)
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.
Given earlier discussion, I think we can skip the check about master_host
altogether.
go/inst/analysis_dao.go
Outdated
if a.IsMaster && m.GetUint("read_only") == 1 && m.GetString("master_host") == "" { | ||
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 comment
The reason will be displayed to describe this comment to others. Learn more.
Given earlier discussion, I think we can skip this block altogether.
replication-analysis
when all nodes are read_onlyreplication-analysis
when all masters are read_only
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.
This looks good to me! Let's deploy to our staging environment and experiment
go/inst/analysis_dao.go
Outdated
@@ -90,6 +91,7 @@ func GetReplicationAnalysis(clusterName string, hints *ReplicationAnalysisHints) | |||
SELECT | |||
master_instance.hostname, | |||
master_instance.port, | |||
master_instance.read_only AS read_only, |
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.
inconsistent indentation here
Sounds good...as soon as Travis decides to work I can deploy to our test environment. |
Travis is used for our external facing builds; our internal builds are all that is needed (and at this time we will need to kick the build manually). |
…thub/orchestrator into jfudally-ro-structure-warning
Good to go! Identifies a read-only master on a single-master topology. Future PR to handle co-masters. |
Add structure warning to
replication-analysis
when all master nodes are read_onlyA Pull Request should be associated with an Issue.
Related issue: #865
Description
This PR adds
NoWriteableMasterStructureWarning
toreplication-analysis
during scenarios when every master node in the cluster isread_only
, omitting intermediate masters.gofmt
(please avoidgoimports
)./build.sh
go test ./go/...