standby switchover: check replication configuration file ownership

Within a PostgreSQL data directory, all files should have the same
ownership as the data directory itself. PostgreSQL itself expects
this, and ownership of files by another user is likely to cause
problems.

In PostgreSQL 11 or earlier, if "recovery.conf" cannot be moved
by PostgreSQL (because e.g. it is owned by root), it will not be
possible to promote the standby to primary.

In PostgreSQL 12 and later, if "postgresql.auto.conf" on the demotion
candidate (current primary) has incorrect ownership (e.g. owned by
root), repmgr will very likely not be able to modify this file and
write the replication configuration required for the node to rejoin
the cluster as a standby.

Checks added to catch both cases before a switchover is executed.
This commit is contained in:
Ian Barwick
2020-03-04 11:35:52 +09:00
parent 194b6d0948
commit 8f6058c676
5 changed files with 287 additions and 3 deletions

View File

@@ -98,6 +98,7 @@
#define OPT_ENABLE_WAL_RECEIVER 1045
#define OPT_DETAIL 1046
#define OPT_REPMGRD_FORCE_UNPAUSE 1047
#define OPT_REPLICATION_CONFIG_OWNER 1048
/* deprecated since 4.0 */
#define OPT_CHECK_UPSTREAM_CONFIG 999
@@ -185,6 +186,7 @@ static struct option long_options[] =
{"has-passfile", no_argument, NULL, OPT_HAS_PASSFILE},
{"replication-connection", no_argument, NULL, OPT_REPL_CONN},
{"data-directory-config", no_argument, NULL, OPT_DATA_DIRECTORY_CONFIG},
{"replication-config-owner", no_argument, NULL, OPT_REPLICATION_CONFIG_OWNER},
/* "node rejoin" options */
{"config-files", required_argument, NULL, OPT_CONFIG_FILES},