Repository navigation
Default to Synchronous Replication #10783
Replies: 14 comments 24 replies
|
I think we also need to make changes to the default settings of startup, readiness and liveness probes. I would honestly start with new clusters. Touching existing clusters might be complicated. |
|
In general, we should encourage users to adopt tools like Kyverno to define defaults. After all, PostgreSQL comes with a default 128MB shared buffer settings, yet I have never used that value in production. ;) |
|
👍 I vote for synchronous replication as a default. I think we should default to safe/sane defaults. If you're running 3 instances, you more than likely care about data durability/reliability/availability and may be surprised if you could still encounter data loss. If you can tolerate data loss I think that should be opt-in. Not to compare CNPG to MongoDB, but there was a time when What are the counter arguments in terms of what a "sane default" is?@gbartolini I found about about Kyverno later in my k8s journey than I would have liked. I think pushing folks in that direction makes a ton of sense. It's not a shape of tool I would have intuitively known to look for. However, in the spirit of Postgres being safe/reliable/sturdy, I think defaulting to safe defaults is in the spirit of the project/mascot 🐘 . This thread makes me want to dust off the CNPG setup wizard at some point, which of course included |
|
I'm not sure making default replication synchronous is a good idea. There are many situations, where synchronous impact on a performance is just too big. Besides, I'm not a fan of a concept where technology thinks instead of a user. An attempt to rely on defaults (however good they are) it is asking for troubles. |
|
I like the idea of the operator have a good, opinionated default for general use and then being able to modify it, if you need to. I already set synchronous replication as a default with I have not set failoverQuorum as the default yet as i have not had time to test it out but was going to once i ran it thru some tests. |
|
I agree with the sentiment of defaulting to sync replication when the user has more than one instance. Users might be surprised by data loss in a 2+ replica setup. A few suggestions:
|
|
Great discussion. I agree with the direction — sync should be the default for a platform that manages cluster topology on behalf of users. When someone declares Building on the points raised above — especially @gbartolini's caution about existing clusters and @ardentperf's push for safer defaults — here's a concrete rollout path that could get us there incrementally: Phase 1: Visibility (Current Release)Make the risk visible without changing behavior:
This costs nothing operationally but surfaces the risk. Phase 2: Explicit Intent (Next Release)Eliminate the silent default — force users to declare their choice.
This is the key step. Once the choice is explicit in the YAML, platform/security teams can find every async cluster and ask "is this intentional?" Phase 3: Default Flip (Major Release)
This follows the same pattern Kubernetes uses for API deprecations: Warn → Make explicit → Change the default. It respects existing users while moving the ecosystem toward safety. Re: the Kyverno/Crossplane suggestions — those are great interim solutions for sophisticated teams. But the users most at risk are small teams deploying CNPG directly from the docs. They won't have a policy layer. They'll deploy |
|
An other important aspect to consider is to disable PDB if instances is 1. But then, what to do if you scale to 2? (PDB will be disabled at that point). |
|
example of someone who saw data loss because they were not running sync repl |
|
Warning came up earlier, but maybe it would make sense to emit a warning today if someone has replica but no sync mode? |
|
👍 I vote for synchronous replication as a default. Here is a feedback/ feature request, expecting to speed up the switchover duration. The proposal asks if Currently using async physical replication, we may update to at least 1 sync physical replication (on 2 replicas). Setting physical replication to synchronous is aligned with PostgreSQL standard configuration, but it is a major change and must be clearly documented. |
|
Another important default change is to make pod anti affinity required instead of preferred, in order to ensure that primary and standbys always land on different nodes. |
|
Since this thread proposes 1. Quorum failover can promote a standby that is missing acknowledged commits (#8790). @GellertBabel, your commit GellertBabel/cloudnative-pg@1ccc058 2. @gbartolini @leonardoce, could #8790 and #10547 be reopened, and could #10549 get a review? For context: we run 2-node SQL Server Availability Groups and are moving to CloudNativePG. |
|
This is also another related issue as a change for a default value of smartShutdownTimeout: #11943 |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Curious what others think about the following proposal:
If
synchronousblock is not specified, then:instances >= 3... default tomethod: anyandnumber: <instances-2>anddataDurability: requiredinstances = 2... default tomethod: anyandnumber: 1anddataDurability: preferredinstances = 1... (doesn't really matter)edit 6/17 few good suggestions in discussion: (1)
instances >= 3... default tonumber: <just over half of replicas>(2) also include pod disruption budget config? (3) is there other config that should be included in scope of this discussion?my proposal is to make a lot of noise about this change in default behavior, and introduce it in a new release. my opinion is that behavior should change for existing postgres clusters when the operator is upgraded.
this would be a major change in behavior. i'm opinionated; i think it's the right thing to do for users.
this means there also needs to be a way to retain the async behavior if desired. at present, the only way to have async replication is for the
synchronousblock to be absent. we would need to add explicit syntax - maybe something likespec.postgresql.synchronous.method: none_async- or maybespec.postgresql.synchronous.number: 0(
methodis probably a better choice thannumber; just in the remote chancenumber=0could become a valid postgres config someday for some use case like defining a cluster without requiring sync replication)Additional questions:
failoverQuorum: falsefor now, but consider defaulting totruein a future version? or defaultfailoverQuorumnow too?failoverQuorumlogic whenfailoverQuorum = true? ie. report failure ifreachable_replicas < Rinstead ofreachable_replicas = 0?All reactions