Repository navigation
feat(synchronous): failure domain-aware synchronous replication - #11144
Conversation
253f9ab to
ed50bac
Compare
|
❗ By default, the pull request is configured to backport to all release branches.
|
|
This work can actually be split in 3 different PR. The last one can't be backported. |
|
what is the fallback model, if we need N sync targets but we can't satisfy that number from available replicas based on the current topology? assuming it's just around ordering, that it prioritizes the failure domain compliant replicas above others, but still adds others if needed? |
ed50bac to
9a24ccd
Compare
It is just the same as what the "old" API was doing. Only the replicas that are not in the same failure domain of the primary are listed in synchronous_standby_names - besides of their readiness status. |
9a24ccd to
0e2216b
Compare
|
/test |
|
@leonardoce, here's the link to the E2E on CNPG workflow run: https://github.com/cloudnative-pg/cloudnative-pg/actions/runs/29001588602 |
|
/test |
|
@armru, here's the link to the E2E on CNPG workflow run: https://github.com/cloudnative-pg/cloudnative-pg/actions/runs/29033196846 |
Add a section to the replication page describing podFailureDomainKeys and nodeFailureDomainKeys: the single source each list reads from, the mutual exclusions, the placement preference semantics, the SyncReplicationTopologySatisfied condition, and the automatic topology labels available on pods starting from Kubernetes 1.35. Signed-off-by: Armando Ruocco <[email protected]>
…ication The warning fired on any multi-instance cluster with default configuration, making the webhook end-to-end test fail. The change is independently proposed in cloudnative-pg#11148, where its design is being discussed: this PR stays focused on failure domain-aware synchronous replication. Signed-off-by: Armando Ruocco <[email protected]>
… fully satisfiable With required data durability, a cross-domain standby list shorter than the configured number left synchronous_standby_names asking for more acknowledgments than the listed standbys could ever provide, blocking every synchronous commit: in a three-instance cluster spread over two zones with number set to 2, the filter produced a single name for two required acknowledgments. Apply the constraint only when the cross-domain standbys cover the whole configured number (one is enough with preferred data durability, where the requirement is already capped to the available standbys), falling back to the unfiltered list otherwise. The SyncReplicationTopologySatisfied condition uses the same threshold, so it keeps matching what the replication path elects. Signed-off-by: Armando Ruocco <[email protected]>
The table groups every instance in the extracted topology, while the topology condition only counts electable standbys: a failed cross-domain instance made the table show multiple domains next to a condition reporting they are insufficient. Mark instances that are not ready so the two views cannot be read as contradicting each other. Signed-off-by: Armando Ruocco <[email protected]>
…ances Signed-off-by: Armando Ruocco <[email protected]>
Every other section reporting live instance state in `kubectl cnpg status` is skipped while the cluster is hibernated, since there are no running pods to describe. The Failure Domain Topology section was printed unconditionally, showing the last-known topology grouping and condition as if they were current. Signed-off-by: Gabriele Bartolini <[email protected]> Assisted-by: Claude Sonnet 5 <[email protected]>
Signed-off-by: Gabriele Bartolini <[email protected]>
Signed-off-by: Gabriele Bartolini <[email protected]>
Signed-off-by: Gabriele Bartolini <[email protected]>
Signed-off-by: Gabriele Bartolini <[email protected]>
Signed-off-by: Gabriele Bartolini <[email protected]>
9f55051 to
984972f
Compare
|
/test |
|
@gbartolini, here's the link to the E2E on CNPG workflow run: https://github.com/cloudnative-pg/cloudnative-pg/actions/runs/31391176208 |
…lication The warning was removed from this branch when it was still duplicating an open pull request. That pull request has been merged in the meantime, together with the update to the end-to-end assertion that expected no admission warnings, so the removal now deletes a feature that exists on the main branch. Restore the warning next to the failure domain one, so a cluster can report both. Signed-off-by: Armando Ruocco <[email protected]>
|
/test |
|
@armru, here's the link to the E2E on CNPG workflow run: https://github.com/cloudnative-pg/cloudnative-pg/actions/runs/31392877318 |
|
A few commits on top of this branch change the original design, so, briefly: The cross-domain list is now used only when it can satisfy the requested
The condition uses the same helper as the election, so it can't say "satisfied" Last commit restores the "no synchronous replication configured" warning: it had Feedback welcome, especially on the first point. |
The two functions updating the cluster status decide whether the update is worth an API call by comparing the status against a copy taken before the changes, and that copy was shallow. meta.SetStatusCondition edits an already existing condition through a pointer into the conditions slice, so the copy carried the very change it was supposed to reveal, the comparison found no difference and the update was skipped. Every condition set there used to change together with a plain status field, which produced a difference on its own and kept the problem hidden. SyncReplicationTopologySatisfied breaks that: its outcome also depends on `.spec.postgresql.synchronous.number` and on the data durability level, so raising the number of requested synchronous standbys on an otherwise quiet cluster leaves the condition reporting a satisfied constraint that is no longer applied, until an unrelated field happens to move. The same applies to any reason or message reworded across operator versions, which could never be corrected on an existing condition. Compare against a deep copy, so that a condition edited in place is seen as a change to persist. Signed-off-by: Armando Ruocco <[email protected]>
With preferred data durability the constraint is applied as soon as a single cross-domain standby is available, and the number of required acknowledgments follows the standbys in the list: one cross-domain standby out of two healthy replicas means one acknowledgment instead of two. The documentation attributed that cap to the health of the replicas, and the comment on filterCrossDomainInstances claimed the keys never lower the durability of a commit, which holds for required data durability only. Signed-off-by: Armando Ruocco <[email protected]>
The groups are sorted by the rendered domain value, so two domains rendering the same way, such as a value that is literally "<empty>" and an empty one, were left in an order that depended on the sort implementation. Sort them stably, keeping the order in which the instances appear, and describe the resulting order. Signed-off-by: Armando Ruocco <[email protected]>
wait_for_all_nodes runs on every kind and k3d cluster creation, and exiting when the expected nodes do not all show up within two minutes makes a slow registration the reason a whole test run never starts. The nodes that did register are usable, and a test needing the complete set reports the missing ones on its own, so warn and move on. Signed-off-by: Armando Ruocco <[email protected]>
The end-to-end suite had no spec reading the topology labels the setup scripts now write on every node. The new spec builds its own failure domains, labelling the node of a single standby, so that the outcome does not depend on where the scheduler put the pods: relying on the zone of the underlying cluster would leave the interesting case untested on the clusters whose every node sits in a distinct zone. It then checks both directions of the constraint: the cross-domain standby elected alone while it satisfies the requested number of synchronous replicas, and the whole standby list coming back, with the topology condition reporting the reason, as soon as it does not. Signed-off-by: Armando Ruocco <[email protected]>
|
/test |
|
@armru, here's the link to the E2E on CNPG workflow run: https://github.com/cloudnative-pg/cloudnative-pg/actions/runs/31399386396 |
|
How does this interact with failover quorum? |
This restrict the replicas listed in synchronous_standby_names, and is reflected on the FailoverQuorum custom resource. |
…dnative-pg/cloudnative-pg#11144) Let CloudNativePG restrict synchronous standby selection to instances in a failure domain different from the primary's, such as another availability zone, so a single-zone outage cannot take out the primary and all its synchronous replicas at once. - Add mutually exclusive `podFailureDomainKeys` and `nodeFailureDomainKeys` to `.spec.postgresql.synchronous`: pod labels are resolved without ever consulting the node, while node labels remain available for clusters where pod-level topology labels aren't populated (Kubernetes 1.34 and older, or where the `PodTopologyLabelsAdmission` admission plugin isn't enabled - see KEP4742). - Apply the constraint only when it is fully satisfiable by the configured `number` of synchronous standbys (or, with `preferred` data durability, by a single cross-domain standby); otherwise, fall back to selecting standbys as if the keys were not configured, so write transactions never wait on acknowledgments that cannot arrive. - Add a `SyncReplicationTopologySatisfied` cluster condition reporting whether the placement preference is currently honored, evaluated only against cluster instances (not `standbyNamesPre`/`standbyNamesPost`). - Show a Failure Domain Topology section in `kubectl cnpg status`, grouping instances by domain, marking not-ready instances, and skipping the table for hibernated clusters. - Update the kind/k3d e2e setup scripts to wait for every node to register and label them with distinct `topology.kubernetes.io/region`/`zone` values, so the feature can be exercised locally out of the box. Signed-off-by: Leonardo Cecchi <[email protected]> Signed-off-by: Armando Ruocco <[email protected]> Signed-off-by: Gabriele Bartolini <[email protected]> Co-authored-by: Armando Ruocco <[email protected]> Co-authored-by: Gabriele Bartolini <[email protected]> (cherry picked from commit cloudnative-pg/cloudnative-pg@6b8139c)
Let CloudNativePG restrict synchronous standby selection to instances in a failure domain different from the primary's, such as another availability zone, so a single-zone outage cannot take out the primary and all its synchronous replicas at once.
podFailureDomainKeysandnodeFailureDomainKeysto.spec.postgresql.synchronous: pod labels are resolved without ever consulting the node, while node labels remain available for clusters where pod-level topology labels aren't populated (Kubernetes 1.34 and older, or where thePodTopologyLabelsAdmissionadmission plugin isn't enabled - see KEP4742).numberof synchronous standbys (or, withpreferreddata durability, by a single cross-domain standby); otherwise, fall back to selecting standbys as if the keys were not configured, so write transactions never wait on acknowledgments that cannot arrive.SyncReplicationTopologySatisfiedcluster condition reporting whether the placement preference is currently honored, evaluated only against cluster instances (notstandbyNamesPre/standbyNamesPost).kubectl cnpg status, grouping instances by domain, marking not-ready instances, and skipping the table for hibernated clusters.topology.kubernetes.io/region/zonevalues, so the feature can be exercised locally out of the box.