19 Commits

Author SHA1 Message Date
Ian Barwick
7bde686796 standby clone: handle missing "postgresql.auto.conf"
In PostgreSQL 12 and later we need to append replication configuration
to "postgresql.auto.conf" to guarantee it will be read last, and hence
override any preceding replication configuration which may be haunting
the configuration files.

We've been assuming that "postgresql.auto.conf" will always be present,
but at least one corner case has been observed where that was not the
case on the node being cloned from. Moreover it's perfectly acceptable
that this file does not exist (it will be recreated the next time
ALTER SYSTEM is executed), so we should be prepared to handle that case.

In passing, improve handling of more unlikely errors which might be
encountered when processing "postgresql.auto.conf".
2020-10-30 12:25:03 +09:00
Ian Barwick
725e9f9851 Remove more unused code 2020-10-15 11:03:18 +09:00
Ian Barwick
00bf4d61fa Remove unused code 2020-10-15 10:54:18 +09:00
Ian Barwick
b7475792e7 configuration: add maximum nesting depth
As with ff4771ab, this is the same behaviour as core PostgreSQL.
2020-05-14 16:27:35 +09:00
Ian Barwick
5c16e94672 configuration: clean up unneeded code and comments 2020-05-14 16:27:22 +09:00
Ian Barwick
ff4771ab02 configuration: reject direct recursion
Ensure a configuration file can't include itself.

This is the same behaviour as core PostgreSQL.
2020-05-14 15:32:04 +09:00
Ian Barwick
d59cadd5f6 Remove old configuration handling code
This expunges two large and cumbersome sets of if/else statements and
the T_CONFIGURATION_OPTIONS_INITIALIZER macro, all of which needed to
be kept in sync when adding/modifying configuration file parameters.
2020-05-14 11:57:16 +09:00
Ian Barwick
3dde8f1386 "retire" old configuration handling code 2020-05-14 11:57:00 +09:00
Ian Barwick
4a1855fabe Place configuration settings struct in separate file 2020-05-14 11:56:45 +09:00
Ian Barwick
2071fa8c7e Initial implementation of an iterable configuration item list
This implements storing the configuration file parameter definitions in
an iterable list. This will replace the existing way of populating the
configuration struct, which is a long and cumbersome if/else structure,
and will make it possible to later dump the imported configuration.
2020-05-14 11:56:38 +09:00
Ian Barwick
9945a3a4a8 Handle "include_dir" 2020-05-14 11:56:35 +09:00
Ian Barwick
0df0db1281 Handle "include_if_exists" 2020-05-14 11:56:30 +09:00
Ian Barwick
682ec9184a Handle "include" 2020-05-14 11:56:26 +09:00
Ian Barwick
fdc6f61257 Pass base configuration file directory to configuration parser
If provided, the parser will use this to process include directives
with unqualified filenames.
2020-05-14 11:56:23 +09:00
Ian Barwick
f5018e42f3 Initial refactoring of configuration file parsing
Have the configuration file parsing routine itself open the respective
configuration file, rather than passing a file pointer from the original
caller. This is required for handling include directives, which we'll
want to do for sanity-checking the PostgreSQL configuration on a freshly
cloned, unstarted standby.
2020-05-14 11:56:19 +09:00
Ian Barwick
f5044465cb Add function to safely modify postgresql.auto.conf
This is required for PostgreSQL 12 and later.
2019-08-14 16:57:42 +09:00
Ian Barwick
8d55cab25e Convert configuration file parsing to use flex
Previously, repmgr was using a very simple ad-hoc string-based parser,
which had various limitations and allowed configuration files to be
created in a way which could cause confusion and/or unexpected
behaviour.

For example, it accepted strings enclosed in single quotes, but treated
strings enclosed in double quotes literally. A node_name defined thusly:

    node_name="somenode"

would result in the literal value '"somenode"' being used, which could
lead to unobvious errors along the lines of:

    no record found for ""somenode""

The configuration file parser has been adapted from the one used by
PostgreSQL itself, so behaves more-or-less identically (though some
functions such as file inclusion are not supported in repmgr).

This makes configuration parsing more robust and consistent;
additionally, error reporting will be more precise.

Note this does mean that some repmgr.conf items previously accepted
as valid by repmgr will now be rejected; in particular this includes
strings containing spaces which are not enclosed in single quotes.
2019-08-01 10:17:20 +09:00
Ian Barwick
5bf9605286 Revert "Convert configuration file parsing to use flex"
This reverts commit c6ca183247.

Backing out this patch for now as the Debian build system doesn't
seem to like it, even though it builds just fine on Debian itself.
2019-07-18 10:19:18 +09:00
Ian Barwick
c6ca183247 Convert configuration file parsing to use flex
Previously, repmgr was using a very simple ad-hoc string-based parser,
which had various limitations and allowed configuration files to be
created in a way which could cause confusion and/or unexpected
behaviour.

For example, it accepted strings enclosed in single quotes, but treated
strings enclosed in double quotes literally. A node_name defined thusly:

    node_name="somenode"

would result in the literal value '"somenode"' being used, which could
lead to unobvious errors along the lines of:

    no record found for ""somenode""

The configuration file parser has been adapted from the one used by
PostgreSQL itself, so behaves more-or-less identically (though some
functions such as file inclusion are not supported in repmgr).

This makes configuration parsing more robust and consistent;
additionally, error reporting will be more precise.

Note this does mean that some repmgr.conf items previously accepted
as valid by repmgr will now be rejected; in particular this includes
strings containing spaces which are not enclosed in single quotes.
2019-07-03 12:18:01 +09:00