vitabaks / postgresql_cluster

PostgreSQL High-Availability Cluster (based on Patroni). Automating with Ansible.
https://postgresql-cluster.org
MIT License
1.69k stars 411 forks source link

Fix add_pgnode.yml: Clear the data directory for the new node for bootstrapping #527

Closed vitabaks closed 10 months ago

vitabaks commented 10 months ago

This Pull Request introduces an important update to the conditions used for clearing the PostgreSQL data and custom WAL directories in our Ansible deployment scripts. The adjustment ensures that the directories are properly prepared not only for master nodes but also for replica nodes, specifically addressing scenarios where pgbackrest is used or when deploying new nodes.

Changes

Note: When performing PITR, we do not clear the directory if pgbackrest is used to be able to use the '--delta' restore option.

Fixed:

Dec 11 12:02:57 mds-pgnode04 patroni[405558]: 2023-12-11 12:02:57,446 CRITICAL: system ID mismatch, node mds-pgnode04 belongs to a different cluster: 7174171621869448735 != 7311>
Dec 11 12:02:57 mds-pgnode04 systemd[1]: patroni.service: Main process exited, code=exited, status=1/FAILURE
Dec 11 12:02:57 mds-pgnode04 systemd[1]: patroni.service: Failed with result 'exit-code'.
Dec 11 12:02:57 mds-pgnode04 systemd[1]: patroni.service: Scheduled restart job, restart counter is at 1.
Dec 11 12:02:57 mds-pgnode04 systemd[1]: Stopped Runners to orchestrate a high-availability PostgreSQL - Patroni.