Skip to content

[Feature]: Introduce replica.primary and replica.enabled = auto #3942

Closed

Description

@gbartolini

Is there an existing issue already for this feature request/idea?

  • I have searched for an existing issue, and could not find anything. I believe this is a new feature request to be evaluated.

What problem is this feature going to solve? Why should it be added?

Currently, we need to manually transition from replication to primary mode, by setting replica.enabled = true or viceversa.

We should enable users to define a distributed topology, for example in 2 or 3 regions, and coordinate the scheduled promotion of a given cluster at regular intervals. We should also account for circular configurations based on cascading replication.

Describe the solution you'd like

Consider the example in #3796, with the following changes.

In pg1:

  replica:
    primary: pg1
    source: pg2
    enabled: auto
    # self: pg1 # this should be set by default to `metadata.name` (but overridable by users)

In pg2:

  replica:
    primary: pg1
    source: pg1
    enabled: auto
    # self: pg2 # same as above

Similarly to source, the primary option matches a key in the externalClusters section. This option defines which Cluster is defined to be the primary in the distributed PostgreSQL cluster, based on the topology specified in externalClusters.

When primary is set, enabled must be set to auto.

When primary and self match, the cluster is accepting write operations (is a primary), so replica is the equivalent of false. When primary and self don't match, the cluster is in recovery mode from its source, so replica is the equivalent of true.

IMPORTANT: The solution should work with our without streaming replication (so just by relying on WAL shipping if required).

Describe alternatives you've considered

We had thought about using the database to share the topology. We believe that instead we should leverage configuration and rely on the externalClusters section.

Additional context

We must cater for additional clusters. For example, there could be a pg3 cluster in a third region, with the following circular architecture based on cascading replication:

pg1  ->  pg2  -> pg3 -
 ^                   |
  ------------------- 

Backport?

No

Are you willing to actively contribute to this feature?

No

Code of Conduct

  • I agree to follow this project's Code of Conduct

Activity

  1. added
    triage
    on Feb 26, 2024
  2. self-assigned this
    on Feb 26, 2024
  3. added
    enhancement 🪄
    on Feb 26, 2024
  4. added this to the 1.23.0 milestone on Apr 5, 2024
  5. modified the milestones: 1.23.0, 1.24.0 on Apr 15, 2024
  6. added a commit that references this issue on May 6, 2024
    c82032b
  7. added a commit that references this issue on May 27, 2024
    da9c615
  8. added a commit that references this issue on Jun 24, 2024
    ae9a127
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement 🪄triage

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions