Class UnreachableClusterPolicy
Before this existed the answer was the same everywhere: a failed mutation wrote a cluster off on the
spot, a failed read went into the sliding window, and either way an unhealthy cluster was stripped from
the read rotation and the priority list. That is right for WRITE_SYNC, where a cluster that
missed a write is genuinely behind the others, and wrong for every other mode, where the cluster has
missed nothing and dropping it is a decision only the application can make.
Which mode decides
Read mode and write mode are independent and both always set, so "the mode" is not a single value - it depends on what noticed the failure. A mutation is judged by the write mode, because the write mode is what determined how many clusters that mutation was supposed to reach. A read, and a ping that reaches no further than a read would, are judged by the read mode.The rules
| Detector | Mode | Cluster | Mark | List | Promote |
|---|---|---|---|---|---|
| MUTATION | WRITE_ONCE | active | UNHEALTHY | keep | yes |
| MUTATION | WRITE_ONCE | other | SUSPECT | keep | no |
| MUTATION | WRITE_SYNC | any | UNHEALTHY | unregister | - |
| READ/PING | READ_ACTIVE | active | UNHEALTHY | keep | yes |
| READ/PING | READ_ACTIVE | other | SUSPECT | keep | no |
| READ/PING | READ_ROUND_ROBIN | any | SUSPECT | keep | no |
"active" in the table means the cluster holds a role the detector cares about. A mutation is only
about the active (write) role. A read or ping counts either role: the active cluster, or the
cluster pinned to serve READ_ACTIVE reads when reads and writes are split - and promote
then moves whichever roles that cluster held, each independently of the other.
WRITE_SYNC needs no promote flag: unregistering hands the active role to the next
cluster in failover order and reports the change, so asking for a promotion as well would move it twice.
ClusterHealth.State.SUSPECT here means "start the sliding window", not "stop at suspect".
A cluster that keeps failing still crosses failureThreshold and becomes
ClusterHealth.State.UNHEALTHY, which is what stops traffic reaching it - it just never leaves
the lists on the way.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordThe handling for one unreachable cluster.static enumWhat noticed that the cluster could not be reached. -
Method Summary
Modifier and TypeMethodDescriptiondecide(MultiClusterConfig config, UnreachableClusterPolicy.Detector detector, boolean isActive) Decides how to handle a cluster that could not be reached.
-
Method Details
-
decide
public static UnreachableClusterPolicy.Decision decide(MultiClusterConfig config, UnreachableClusterPolicy.Detector detector, boolean isActive) Decides how to handle a cluster that could not be reached.- Parameters:
config- the configuration in force, for the read and write modesdetector- what noticed the failureisActive- whether the unreachable cluster currently holds a role the detector depends on: the active (write) role for a mutation; for a read or ping, the active role or the pinned read-active role, since either one being dead leavesREAD_ACTIVEtraffic or writes with nowhere to go
-