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

Brittle configuration file backup/restore for external config_dir #2370

Open
mbanck opened this issue Jul 29, 2022 · 0 comments · May be fixed by #2371
Open

Brittle configuration file backup/restore for external config_dir #2370

mbanck opened this issue Jul 29, 2022 · 0 comments · May be fixed by #2371

Comments

@mbanck
Copy link
Contributor

mbanck commented Jul 29, 2022

Describe the bug

  1. Have a primary with config_dir outside the data directory
  2. Patroni (on startup/restart e.g.) copies config_dir/postgresql.base.conf to PGDATA/postgresql.base.conf.backup
  3. On standby bootstrap, basebackup method streams postgresql.base.conf.backup into standby's PGDATA along with the rest
  4. Patroni restores PGDATA/postgresql.base.conf.backup to config_dir/postgresql.base.conf, overwriting the original one (if there was one)
  5. Postgres potentially does not start, in case the new version of postgresql.base.conf has wrong data for the local node (e.g. wrong data_directory)

Expected behavior

I think Patroni should not overwrite local configuration files with a backup from the primary, but I'm not exactly what happens in the general case. One possibility would be to store the .backup files in config_dir as well and then restore them from there (thus avoiding the .backup files in PGDATA), but not sure whether that would break on update or something?

A work-around is to make sure PGDATA/postgresql.base.conf.backup does not exits on the primary before bootstrapping the standby.

Well, or Patroni needs to be more explicit that postgresql.base.conf must be identical on all nodes, which I am not sure is a reasonable requirement seeing how people put e.g. local IP addresses or hostnames into things like syslog_ident etc.

Environment

  • Patroni version: 2.1.4
  • PostgreSQL version: 13.7
  • DCS (and its version): etcd3
mbanck pushed a commit to credativ/patroni that referenced this issue Jul 29, 2022
Before, the .backup files were always stored in the data directory. However, if
there is a distinct configuration directory, it seems logical to put them
there. If config_dir is not configured, it defaults back to the data directory,
so this will not change things for setups where postgresql.conf is in the data
directory.

On the other hand, it will help with setups where postgresql.conf is outside
the data directory and has local changes. In this case, those no longer get
overwritten on boostrap/clone from the primary's backup configuration file that
is streamed to the boostrapped node.

Close zalando#2370
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 a pull request may close this issue.

1 participant