MySQL Router reads the values defined in the metadata field,
v2_router_options.router_options.read_only_targets
,
to retrieve routing information for read-only traffic.
v2_router_options.router_options.read_only_targets
is populated by the AdminAPI method
which sets the routing policy to one of the following values
using the cluster
.setRoutingOption()read_only_targets
option:
all
: all Read Replicas and Secondary cluster members are used for read-only traffic.read_replicas
: only Read Replicas are used for read-only traffic.secondaries
: only Secondary cluster members are used for read-only traffic.
If read_only_targets
is not present, or set
to a value other than all
,
read_replicas
, or
secondaries
, MySQL Router defaults to
secondaries
and logs a warning message.
MySQL Router does not use Read Replicas as a source for Cluster metadata. Also, it is not possible to use a Read Replica in a MySQL Router bootstrap command. An error is returned for any attempt to bootstrap with a Read Replica.
MySQL Router does not route connections to Read Replicas in the following situations:
If there is no quorum in the Cluster.
If all Cluster members are in OFFLINE state.
If no Cluster members can be reached when checking their Group Replication state.
MySQL Router routing policy is affected by configuration in the following ways:
If the Cluster state is INVALID and the
invalidated_cluster_policy
is set todrop_all
, Read Replicas are not used for new read-only connections and all existing connections to the Read Replicas are dropped.If the Cluster state is INVALID and the
invalidated_cluster_policy
is set toallow_ro
, Read Replicas are used for new read-only connections and existing connections to the Read Replicas are unaffected.
MySQL Router uses the standard quarantine mechanism for Read
Replicas, as defined by the
desination_status
configuration parameters.
See
Destination Status Options.