Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 2 commits into from
Dec 13, 2023

Conversation

vitabaks
Copy link
Owner

@vitabaks vitabaks commented Dec 11, 2023

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

  • Modified the conditional logic in the tasks responsible for clearing the PostgreSQL data directory (postgresql_data_dir) and the custom WAL directory (postgresql_wal_dir).
  • The updated conditions now accurately check:
    • If the node is a master and patroni_cluster_bootstrap_method does not use pgbackrest.
    • If the node is not a master, the directory clearance happens either when pgbackrest is not part of the patroni_create_replica_methods, or it is a new node (indicated by the new_node variable).

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.

@vitabaks vitabaks self-assigned this Dec 11, 2023
@vitabaks vitabaks merged commit d95a371 into master Dec 13, 2023
17 checks passed
@vitabaks vitabaks deleted the add-pgnode-clear-directory branch December 13, 2023 10:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant