pg-upgrade-logical: Improvements for multiple slots mode and Reverse logical replication
Multiple slots mode (if pg_publication_count > 1)
What's new
- Added support for a logical replication configuration with multiple publications, slots, and subscriptions in the
switchover.yml
playbook. - In the task "
Wait until the logical replication lag is 0 bytes
", the limit of 10 seconds has been removed since we need to wait for a zero replication lag in order to achieve a consistent state of the database (important if there are multiple publications/subscriptions)- skip if force_mode is true
-
switchover_rollback.yml
: Wait until the logical replication lag is 0 bytes before stop traffic to the new cluster leader and start traffic to the old cluster leader- skip if force_mode is true
- Fix the variable name for the loop for drop_subscription.yml and drop_publication.yml playbooks
- Monitor the locks and terminate the backend blocking the
create publication
query (for more than 15 seconds) - Reverse logical replication.
- if '
enable_reverse_logical_replication
' is 'true' - enabled by default
- if '
- Added a pre-check to prepare a password file (.pgpass) on the Source cluster for reverse logical replication.
- Added new playbook
stop_reverse_replication.yml
for stop reverse logical replication after upgrade- it is executed after a decision is made that a rollback to the old cluster is no longer necessary.
- After switchover, drop publications replicated from the source cluster (details).
- When using multiple publications/slots, switch first the R/W traffic (Primary) and then the R/O traffic (replicas)
- To ensure data consistency at the time of traffic switching to the new cluster.
- Note: Added
switchover_leader.yml
andswitchover_replica.yml
playbooks which are run in the right order based on the value of thepg_publication_count
variable. - Additionally: a minor code refactoring was performed.
- Optimization of "logical replication" tasks to reduce pgbouncer pause time
- Updated README
Edited by Vitaliy Kukharik