MOCO works well for initial cluster creation and steady-state operation. However, changing replication settings on an existing cluster—especially adjusting the replica count—has rough edges, as outlined below. The proposals that follow aim to significantly improve this experience.
1) Allow scaling replicas down
- Support decreasing
spec.replicas.
Optional: allow scale to 0; delete all Pods but retain the primary’s PVC so data persists and the cluster can be restarted later. - This can be achieved by scaling down the cluster to 1 instance/replica and then setting offline: true.
2) Allow even replica counts
- Allow even values for
spec.replicas.
- Maintain safety with a true majority for semi-sync:
ceil((replicas - 1) / 2) required ACKs.
- Rationale: does not increase fault tolerance vs the previous odd size, but enables controlled scaling under resource constraints or over time.
3) Prevent write stall during scale-up
When scaling up (e.g., 1 → 3), the controller immediately sets rpl_semi_sync_master_enabled=ON and rpl_semi_sync_master_wait_for_slave_count=floor(replicas / 2). While new replicas are being provisioned (PVC provisioning, initial clone & replication), writes do not get processed until rpl_semi_sync_master_wait_for_slave_count is satisfied. Ideally, during transitions, these replication settings should be enabled/set only when replicas are ready to satisfy them (ACK commits).
4) Sequential replica adds on scale-up
When scaling up, add replicas sequentially rather than all at once. Create a single new secondary, wait until it is ready, then create the next. The MySQL Clone plugin doesn’t support concurrent clone provisioning from a single donor anyway.
5) Rename spec.replicas → spec.instances
Rename spec.replicas to spec.instances to better reflect that the field represents the total number of MySQL instances (one primary plus N secondaries), not just replicas. This change clarifies intent and avoids confusion.
I am happy to hear your thoughts. If there’s a green light from the maintainers, I’m willing to implement items 1, 2, 4, and 5; item 3 is probably best handled by someone more familiar with MOCO internals.
MOCO works well for initial cluster creation and steady-state operation. However, changing replication settings on an existing cluster—especially adjusting the replica count—has rough edges, as outlined below. The proposals that follow aim to significantly improve this experience.
1) Allow scaling replicas down
spec.replicas.Optional: allow scale to 0; delete all Pods but retain the primary’s PVC so data persists and the cluster can be restarted later.- This can be achieved by scaling down the cluster to 1 instance/replica and then settingoffline: true.2) Allow even replica counts
spec.replicas.ceil((replicas - 1) / 2)required ACKs.3) Prevent write stall during scale-up
When scaling up (e.g., 1 → 3), the controller immediately sets
rpl_semi_sync_master_enabled=ONandrpl_semi_sync_master_wait_for_slave_count=floor(replicas / 2). While new replicas are being provisioned (PVC provisioning, initial clone & replication), writes do not get processed untilrpl_semi_sync_master_wait_for_slave_countis satisfied. Ideally, during transitions, these replication settings should be enabled/set only when replicas are ready to satisfy them (ACK commits).4) Sequential replica adds on scale-up
When scaling up, add replicas sequentially rather than all at once. Create a single new secondary, wait until it is ready, then create the next. The MySQL Clone plugin doesn’t support concurrent clone provisioning from a single donor anyway.
5) Rename
spec.replicas→spec.instancesRename
spec.replicastospec.instancesto better reflect that the field represents the total number of MySQL instances (one primary plus N secondaries), not just replicas. This change clarifies intent and avoids confusion.I am happy to hear your thoughts. If there’s a green light from the maintainers, I’m willing to implement items 1, 2, 4, and 5; item 3 is probably best handled by someone more familiar with MOCO internals.