mirror of
https://github.com/featurebasedb/featurebase.git
synced 2026-09-12 15:51:01 +00:00
make sure cluster gets into DEGRADED state when adding nodes
previously, losing a node could cause the cluster to go from NORMAL->DEGRADED, but adding a node would not cause it to go from STARTING->DEGRADED. Cody brought this up in code review.
This commit is contained in:
parent
6e99a8757d
commit
1901ffada6
2 changed files with 5 additions and 11 deletions
12
cluster.go
12
cluster.go
|
|
@ -456,12 +456,7 @@ func (c *cluster) receiveNodeState(nodeID string, state string) error {
|
|||
c.Topology.mu.Unlock()
|
||||
c.logger.Printf("received state %s (%s)", state, nodeID)
|
||||
|
||||
// Set cluster state to NORMAL.
|
||||
if c.haveTopologyAgreement() && c.allNodesReady() {
|
||||
return c.unprotectedSetStateAndBroadcast(ClusterStateNormal)
|
||||
}
|
||||
|
||||
return nil
|
||||
return c.unprotectedSetStateAndBroadcast(c.determineClusterState())
|
||||
}
|
||||
|
||||
// determineClusterState is unprotected.
|
||||
|
|
@ -1573,11 +1568,6 @@ func (c *cluster) considerTopology() error {
|
|||
return fmt.Errorf("coordinator %s is not in topology: %v", c.Node.ID, c.Topology.nodeIDs)
|
||||
}
|
||||
|
||||
// If local node is the only thing in .topology, continue.
|
||||
//if len(c.Topology.NodeIDs) == 1 {
|
||||
// return nil
|
||||
//}
|
||||
|
||||
// Keep the cluster in state "STARTING" until hearing from all nodes.
|
||||
// Topology contains 2+ hosts.
|
||||
return nil
|
||||
|
|
|
|||
|
|
@ -489,6 +489,10 @@ func TestClusteringNodesReplica2(t *testing.T) {
|
|||
t.Fatalf("restarting node 2: %v", err)
|
||||
}
|
||||
|
||||
if cluster[0].API.State() != pilosa.ClusterStateDegraded {
|
||||
t.Fatalf("expected state to be DEGRADED, but got %s", cluster[0].API.State())
|
||||
}
|
||||
|
||||
// Create new main with the same config.
|
||||
config = cluster[1].Command.Config
|
||||
// config.Bind = cluster[1].API.Node().URI.HostPort()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue