pgBackRest: Fix timeline divergence after PITR #820
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is intended to be fixed during PITR, when at the end of the playbook, the replicas were on a timeline different from the master node.
The first solution that helped fix the error on the timeline was to restart patroni on replica nodes, which causes pg_rewind to run between replicas and the master, and the replicas received the necessary WAL files from the master node to align the timeline. But it didn't look like the right decision.
Also, when replicas were in the first timeline after recovery, errors were observed in the logs on the master node that a replication slot could not be created for the replica node:
The official documentation says that if target-action=shutdown is used, the recovery.signal file is not deleted, which prevents subsequent PostgreSQL launches in the cluster, since the server will wait for further recovery from the WAL repository, where the necessary files are missing, since after recovery it is necessary to make a new backup. A simple intervention with deleting the recovery.signal file before running patroni on replicas does not help solve the problem with the missing timeline.
The solution is to change the target-action for replicas from shutdown to pause, in this case the replica starts as a ready-made PostgreSQL instance and immediately connects to the master node and pulls the necessary WALs from it for the desired timeline.