Patroni: reinitialize-replica command
Summary
There are certain circumstances that can make Patroni instance decouple from the current cluster (like a series of actions when the instance is in a split-brain scenario).
That prevents that instance from catching up with the existing cluster when they are brought up back. It can also happen when migrating from a non-patroni cluster to a patroni cluster, that you need to re-initialize some instances.
Patroni has support for the reinit
command (from patroni-ctl
). This is also exposed via the REST API endpoint: https://patroni.readthedocs.io/en/latest/rest_api.html?highlight=reinit#reinitialize-endpoint
To perform this change manually in an existing Omnibus based setup, we need to perform the following command:
# Usage: patronictl reinit [OPTIONS] CLUSTER_NAME [MEMBER_NAMES]...
#
# Reinitialize cluster member
#
# Options:
# --force Do not ask for confirmation at any point
# --wait Wait until reinitialization completes
# --help Show this message and exit.
/opt/gitlab/embedded/bin/patronictl -c /var/opt/gitlab/patroni/patroni.yaml reinit postgresql-ha
This will also ask to to point which members you want to reinitialize.
Proposal
Create the equivalent command in gitlab-ctl
as gitlab-ctl patroni reinitialize-replica
and expose the options that are useful to us.