Skip to content

feat: introduce controlled switchover of a replica cluster - #4411

Merged
gbartolini merged 30 commits into
mainfrom
dev/3790
Jun 19, 2024
Merged

gbartolini merged 30 commits into
mainfrom
dev/3790

Conversation

@armru

@armru armru commented Apr 30, 2024 •

Copy link
Copy Markdown
Member

Introduce support for the controlled demotion of a primary cluster and the subsequent promotion of a replica cluster (typically in another region) without the need to re-clone the former primary.

This operation will necessarily result in a downtime, which is typically scheduled and expected.

Demotion of a primary cluster is currently triggered by changing replica.enabled from false to true and includes:

  • Shutting down the PostgreSQL server.
  • Performing an extraordinary archival of the checkpoint REDO WAL file, containing the shutdown checkpoint, as a .partial file in the WAL archive.
  • Generating the demotionToken in the Cluster status, containing information in base64-encoded JSON format retrieved from pg_controldata (this includes the database system identifier, latest checkpoint's TimeLineID, latest checkpoint's REDO location, latest checkpoint's REDO WAL file, and the time of the latest checkpoint).

Currently, promoting a replica cluster to a primary cluster is triggered by simultaneously:

  • Adding the replica.promotionToken and setting its value to the demotionToken returned by the former primary cluster.
  • Changing replica.enabled from true to false.

The patch includes validating the submitted token (it is the user's responsibility to set the correct value to ensure self-healing).

After waiting for the designated primary to replicate all the WAL information until the desired LSN (contained in the token) is reached, the promotion process is started.

Closes #3790
Closes #3944
Closes #4586

@github-actions github-actions Bot added backport-requested ◀️ This pull request should be backported to all supported releases release-1.21 labels Apr 30, 2024
@github-actions

Copy link
Copy Markdown
Contributor

❗ By default, the pull request is configured to backport to all release branches.

  • To stop backporting this pr, remove the label: backport-requested ◀️ or add the label 'do not backport'
  • To stop backporting this pr to a certain release branch, remove the specific branch label: release-x.y

@armru

armru commented May 1, 2024

Copy link
Copy Markdown
Member Author

/test limit=local

@github-actions

github-actions Bot commented May 1, 2024

Copy link
Copy Markdown
Contributor

@armru
armru marked this pull request as ready for review May 3, 2024 10:27
@armru

armru commented May 6, 2024

Copy link
Copy Markdown
Member Author

/test limit=local

@github-actions

github-actions Bot commented May 6, 2024

Copy link
Copy Markdown
Contributor

@armru

armru commented May 7, 2024

Copy link
Copy Markdown
Member Author

/test limit=local

@github-actions

github-actions Bot commented May 7, 2024

Copy link
Copy Markdown
Contributor

@armru

armru commented May 7, 2024

Copy link
Copy Markdown
Member Author

/test limit=local

@github-actions

github-actions Bot commented May 7, 2024

Copy link
Copy Markdown
Contributor

@armru armru removed backport-requested ◀️ This pull request should be backported to all supported releases release-1.21 labels May 7, 2024
@leonardoce
leonardoce requested a review from jsilvela as a code owner May 17, 2024 09:45
armru and others added 23 commits June 19, 2024 12:04
Signed-off-by: Armando Ruocco <[email protected]>
Co-authored-by: Gabriele Bartolini <[email protected]>
Signed-off-by: Leonardo Cecchi <[email protected]>
Signed-off-by: Leonardo Cecchi <[email protected]>
Signed-off-by: Leonardo Cecchi <[email protected]>
Signed-off-by: Leonardo Cecchi <[email protected]>
Signed-off-by: Leonardo Cecchi <[email protected]>
Signed-off-by: Gabriele Bartolini <[email protected]>
Signed-off-by: Gabriele Bartolini <[email protected]>
Signed-off-by: Gabriele Bartolini <[email protected]>
@leonardoce

Copy link
Copy Markdown
Contributor

/ok-to-merge

@gbartolini gbartolini added ok to merge 👌 This PR can be merged and removed always push images This PR will continuously push a container image every time a new commit is pushed labels Jun 19, 2024
@gbartolini
gbartolini merged commit f2b876e into main Jun 19, 2024
@gbartolini
gbartolini deleted the dev/3790 branch June 19, 2024 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ok to merge 👌 This PR can be merged

Projects

None yet

4 participants