Commit Graph

1798 Commits

Author SHA1 Message Date
Ian Barwick
36a8dfcf4f Standardize code style 2020-10-30 11:06:46 +09:00
Ian Barwick
94612a336a config: fix parsing of "replication_type"
This is a legacy parameter which can currently only contain one value,
"physical" (the default).

It can be safely omitted.

Addresses GitHub #672.
2020-10-30 10:17:03 +09:00
Ian Barwick
de567d584f doc: update README 2020-10-22 21:21:16 +09:00
Ian Barwick
0fb3432398 Finalize release date v5.2.0 2020-10-22 17:15:37 +09:00
Ian Barwick
5e59e543d6 Additional fix to upgrade script
Drop old "repl_events" table.
2020-10-22 12:36:31 +09:00
Ian Barwick
4f6b642320 Fix extension script for unpackaged upgrades to 5.2
Apparently "ALTER TABLE" (which we were using to convert the
"repl_events" table) does not mark the table as being part of the
extension. Instead, we need to create the new table and copy the
data, as is done with the other tables.
v5.2.0rc2
2020-10-22 11:18:03 +09:00
Ian Barwick
c1973438f7 doc: add missing "unpackaged" reference 2020-10-21 17:31:22 +09:00
Ian Barwick
fe5904e04e standby clone: improve Barman source server check
Use "remote_command()" to execute the remote psql command, and
provide the -X option to psql to ensure it doesn't read ~/.psqlrc.
v5.2.0rc1
2020-10-20 17:21:17 +09:00
Ian Barwick
2cb1f4f728 doc: update release notes 2020-10-20 14:05:25 +09:00
Ian Barwick
5b90842c55 Bump version to 5.2.0
Also update the minimum version check to PostgreSQL 9.4.
2020-10-20 13:34:16 +09:00
Ian Barwick
397e0ed5be Silence potential compiler complaint
*We* know the target buffer is sufficiently sized to accept the
source string, but the compiler doesn't.
2020-10-20 09:51:49 +09:00
Ian Barwick
8f3994b071 doc: update "repmgr standby clone" reference
Clarify which replication configuration parameters will be written
for which PostgreSQL version.
2020-10-20 09:35:22 +09:00
Ian Barwick
f7c232b393 Only write "recovery_target_timeline" for PostgreSQL 11 and earlier
"recovery_target_timeline" defaults to "latest" from PostgreSQL 12
(see core commit 2dedf4d9) so no need to write it explicitly.
2020-10-20 09:18:29 +09:00
Ian Barwick
ac2feba380 Improve capture of pg_rewind stderr output
As it seems redirecting stderr to stdin (2>&1) when executing
system commands results in a SIGPIPE (141) return code, making
it impossible to determine the actual return code, redirect
stderr to a temporary file and collate the output from that.

There are possibly better ways of doing this which could
be revisited at a future date.
2020-10-15 14:01:18 +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
338c4d3f8a node rejoin: rename variable for clarity 2020-10-14 17:57:20 +09:00
Ian Barwick
250c6291df node rejoin: fix Pg13+ "standby.signal" handling with pg_rewind 2020-10-14 17:51:57 +09:00
Ian Barwick
773159a9e8 standby clone: move check for --waldir pg_basebackup option
When cloning from Barman, and --no-upstream-connection was supplied,
the server version number will not be available at this point in the
code. It will however later be extracted from the Barman metadata,
so move the check for the --waldir pg_basebackup option to after
this point.

Also add an explicit check that a server version number has been
obtained (and fall back to extracting it from the cloned data
directory), as subsequent operations depend on knowing this to
be performed correctly.
2020-10-13 14:27:46 +09:00
Ian Barwick
5f986bc981 node rejoin: handle unclean shutdown in Pg13
From PostgreSQL 13, pg_rewind will automatically handle an unclean
shutdown itself, so as long as --force-rewind was provided, so there
is no need to fail with an error.

Note that pg_rewind handles the unclean shutdown by starting PostgreSQL
in single user mode, which it does before performing any checks as
to whether a rewind is actually necessary.

However pg_rewind doesn't take into account the possible presence
of a standby.signal file, so we remove that and recreate it after
pg_rewind was executed.
2020-10-13 10:18:55 +09:00
Ian Barwick
d62743ddf4 Make repmgr metadata tables dumpable
This makes it easier to extract data for troubleshooting.
2020-10-12 10:02:52 +09:00
Ian Barwick
b195547525 Remove hack to create pre-9.4 monitoring history table
The pg_lsn datatype was introduced in PostgreSQL 9.4, and we no
longer need to support earlier versions.
2020-10-12 09:32:37 +09:00
Ian Barwick
758c18985c node rejoin: better document unrecoverable situation
If two diverged nodes are on the same timeline, currently there's
no way of establishing the divergence point and pg_rewind
is ineffective.

Clarify the log messages to make this clearer.
2020-10-08 21:09:51 +09:00
Ian Barwick
7969dc4800 Enable "node rejoin" to join a target with a lower timeline
This has been possible since PostgreSQL 9.6, but the node rejoin/follow
check did not consider this possibility.
2020-10-08 16:51:16 +09:00
Ian Barwick
0fc8c6c79c Add some break statements to silence compiler warnings 2020-10-08 13:10:00 +09:00
Ian Barwick
e7acb6809b standby clone: improve error logging
When executing "repmgr standby clone" in Barman mode, and --waldir
is set in pg_basebackup options, properly report an error if the
target WAL directory could not be created or is not empty.
2020-10-08 10:46:20 +09:00
Ian Barwick
4b524c52b6 standby clone: honour --waldir setting when cloning from Barman
By setting --waldir in "pg_basebackup_options", standbys cloned using
pg_basebackup would have their WAL directory set to the specified
location and symlinked from the data directory.

This commit causes repmgr to honour that setting even when cloning
from Barman.
2020-10-07 15:13:52 +09:00
Ian Barwick
b3b9281253 Parse pg_basebackup option --waldir/--xlogdir 2020-10-07 15:13:50 +09:00
Ian Barwick
679cfe0852 doc: update release notes
Note PostgreSQL 13 support as a general feature.
2020-10-06 14:17:16 +09:00
Ian Barwick
e10d9fd393 EXPERIMENTAL: synchronise try_primary_reconnect()'s reconnection loop
Per proposal in GitHub #662, this patch attempts to synchronise each
repmgrd's primary reconnection attempts to prevent potential race
conditions. This relies on each node's clock being correcly
synchronised.

Currently this change is experimental and is not enabled by default.
It can be enabled by setting the repmgr.conf parameter
"reconnect_loop_sync".
2020-10-06 13:35:49 +09:00
Ian Barwick
467d19bcd4 Use atoll() to parse system_identifier on 32bit systems
Addresses issue in GitHub #665.
2020-10-06 09:44:31 +09:00
Ian Barwick
be244e2155 Fix typo
s/paremeter/parameter/
2020-10-05 17:06:52 +09:00
Ian Barwick
42283bf344 repmgrd: check local connection after promoting local node
In theory the local connection should not be affected by the node's
promotion. However we're handing over control to an external command
which is usually just "repmgr standby promote", but could potentially
be a user-defined script with unknowable side effects. So it's
better to be safe than sorry.
2020-10-05 16:50:41 +09:00
Ian Barwick
5b254a1be9 repmgrd: add parameter "failover_delay"
This parameter is not documented and intended for use during testing.
It should not be used in production.
2020-10-05 16:43:06 +09:00
Ian Barwick
9aaf7d79a2 standby switchover: in Pg13 and later, promotion overrides paused WAL replay
Preventing a switchover in this case no longer makes sense, so we apply
the checks to PostgreSQL 12 and earlier only.
2020-09-30 15:15:11 +09:00
Ian Barwick
e86c035242 standby promote: in Pg13 and later, promotion overrides paused WAL replay
Aborting in this case no longer makes sense, so we apply the checks
to PostgreSQL 12 and earlier only.
2020-09-30 15:15:07 +09:00
Ian Barwick
73d2088a85 standby follow: don't restart server (PostgreSQL 13 and later)
As of PostgreSQL 13, changes to the fundamental replication
configuration can be applied with a simple SIGHUP, no restart
required.

In case the old behaviour is desired, i.e. a full restart to apply
the configuration changes, the new configuration parameter
"standby_follow_restart" can be set. This parameter has no effect
in PostgreSQL 12 and earlier.
2020-09-29 17:53:51 +09:00
Ian Barwick
48f95f9a39 Fix typo in comment 2020-09-29 15:26:28 +09:00
Ian Barwick
ce229beff8 repmgrd: add configuration option "always_promote"
In certain corner cases, it's possible repmgrd may end up monitoring
a standby which was a former primary, but the node record has not
yet been updated.

Previously repmgrd would abort the promotion with a cryptic message
about being unable to find a node record for node_id -1 (the
default value for an unknown node id).

This commit addes a new configuration option "always_promote", which
determines whether repmgrd should promote the node in this case.
The default is "false", to effectively maintain the existing behaviour.

Logging output has also been improved to make it clearer what has
happened when this situation occurs.
2020-09-29 14:18:00 +09:00
Ian Barwick
16eeae700c repmgrd: minor log message tweak 2020-09-29 10:23:31 +09:00
Ian Barwick
70061c51aa Further improve handling of possible pg_control read errors
Builds on changes in commit 147f454, and ensures appropriate
action is taken if a value cannot be read from pg_control.
2020-09-28 13:59:34 +09:00
houzj.fnst
3ffeffbd8b Remove redundant condition
GitHub #655.
2020-09-28 13:08:18 +09:00
Ian Barwick
147f454d32 Minor sanity check for control file extraction functions
If the control file couldn't be parsed for whatever reason, return
the default value for the requested parameter.

It'd be better to have the caller pass in a pointer to the parameter
and have the function return bool so the caller doesn't assume the
control file was read successfully. This is important for handling
DBState, where no "value unknown" default is available.
2020-09-28 10:47:56 +09:00
Ian Barwick
26b5664741 repmgr: enable "primary unregister --force" to unregister an active primary
The primary must have no registered standby nodes.

Also document usage when unregistering a primary node which is actually
running as a standby.
2020-09-23 15:12:19 +09:00
Ian Barwick
cb86180f4f doc: document include directives 2020-09-18 16:27:52 +09:00
Ian Barwick
1f3e098104 Add option "--dump-config"
This is initially intended for verifying the configuration parsing
mechanism and is currently undocumented.
2020-09-18 15:12:22 +09:00
Ian Barwick
4670515285 config: fix parsing of event_notifications list 2020-09-18 14:36:56 +09:00
Ian Barwick
bccc2673b6 doc: update compatibility matrix 2020-09-18 11:40:47 +09:00
Ian Barwick
158008c5c5 doc: update release notes 2020-09-18 11:29:07 +09:00
Ian Barwick
5f3d1cdeb6 doc: note removal of PostgreSQL 9.3 support 2020-09-17 16:05:16 +09:00