Commit Graph

53 Commits

Author SHA1 Message Date
Ian Barwick
20b79f998c Define some previously magic numbers 2019-02-01 19:14:16 +09:00
Ian Barwick
9273e7af73 "standby switchover": avoid potential race condition with WAL location check
Immediately after the demotion candidate (primary) has shut down, we can't
be absolutely sure that the walreceiver has flushed all WAL to disk, so
checking pg_last_wal_receive_lsn() at that point might not reflect
the actual last available WAL location.

To handle this, we'll loop for a while (timeout controlled by configuration
parameter "wal_receive_check_timeout") before finally deciding whether
the standby is still behind the shut-down primary.

Addresses issue raised in GitHub #518.
2019-02-01 12:06:22 +09:00
Ian Barwick
70e4243a1d Clean up calls to repmgr_atoi()
In some places we were still providing "false" from the original implementation,
which was intended to indicate whether a negative value was allowed.

This has not been a problem, as it merely means we have been providing "0",
which is the same thing; however we can finer-tune some of the calls
(e.g. node ID must be or greater).
2019-01-30 11:43:43 +09:00
Ian Barwick
7dce3ed234 Update copyright notices to 2019 2019-01-21 14:54:35 +09:00
Ian Barwick
2491b8ae52 Add functionality to "pause" repmgrd
In some circumstances, e.g. while performing a switchover, it is essential
that repmgrd does not take any kind of failover action, as this will put
the cluster into an incorrect state.

Previously it was necessary to stop repmgrd on all nodes (or at least
those nodes which repmgrd would consider as promotion candidates), however
this is a cumbersome and potentially risk-prone operation, particularly if the
replication cluster contains more than a couple of servers.

To prevent this issue from occurring, this patch introduces the ability
to "pause" repmgrd on all nodes wth a single command ("repmgr daemon pause")
which notifies repmgrd not to take any failover action until the node
is "unpaused" ("repmgr daemon unpause").

"repmgr daemon status" provides an overview of each node and whether repmgrd
is running, and if so whether it is paused.

"repmgr standby switchover" has been modified to automatically pause repmgrd
while carrying out the switchover.

See documentation for further details.
2018-09-27 16:42:10 +09:00
Ian Barwick
38e3aae053 repmgr: add parameter "shutdown_check_timeout"
Previously, "repmgr standby switchover" used the configuration file parameters
"reconnect_interval" and "reconnect_attempts" to define a timeout to determine
whether the current primary (demotion candidate) has shut down.

However, these parameters are intended for primary failure detection and are
generally lower in value, while a controlled shutdown may take longer, resulting
in the switchover being aborted as repmgr was not waiting long enough.

To prevent this happening, parameter "shutdown_check_timeout" has been added.
This complements the existing "standby_reconnect_timeout" parameter used
by "repmgr standby switchover".

Implements GitHub #504.
2018-09-25 11:34:06 +09:00
Ian Barwick
b2081dca52 De-overload configuration file parameter "standby_reconnect_timeout"
Currently the (very generic sounding) "standby_reconnect_timeout" configuration
file parameter is used in several different contexts and it would be useful
to have more granular control over the different timeouts it's used to configure.

This patch introduces "node_rejoin_timeout", used in place of "standby_reconnect_timeout"
(which wasn't documented) when "repmgr node rejoin" is executed, to determine
how long to wait for the node to rejoin the replication cluster.

Additionally "repmgrd_standby_startup_timeout" is introduced as a timeout for
failover situations, when repmgrd executes "repmgr standby follow" to follow
a new primary, and waits for the standby to restart and become available
for connections.

"standby_reconnect_timeout" is now only relevant for "repmgr standby switchover".

Implements GitHub #454.
2018-06-28 18:00:55 +09:00
Ian Barwick
bf0d67c60a Add repmgr.nodes to the BDR replication set 2018-06-15 14:29:08 +09:00
Ian Barwick
4f642f8332 Detect and store BDR major version number when executing "is_bdr_db()"
BDR3 metadata structure is very different to BDR1/2, so we'll need to
generate queries according to version.
2018-06-15 14:25:55 +09:00
Ian Barwick
efc388065e standby follow: check node has connect to new primary
After restarting the standby, poll pg_stat_replication on the upstream
until the standby connects, and exit with an error if it doesn't by the
timeout defined in "standby_follow_timeout".

Implments GitHub #444.
2018-06-07 15:04:45 +09:00
Ian Barwick
55441f2729 repmgrd: add configuration file parameter "standby_reconnect_timeout"
This is used for determining a timeout when reconnecting to the standby
after executing the "follow_command". This will normally not need to be
set explicitly, but maybe useful in cases where the standby's startup
phase can last longer than usual.
2018-03-02 11:04:56 +09:00
Ian Barwick
b705127a34 "repmgr standby register": add --wait-start option
Implements GitHub #356.
2018-01-04 14:56:08 +09:00
Ian Barwick
26a9e848fd Update copyright notices to 2018 2018-01-02 10:19:46 +09:00
Ian Barwick
472d703d2e repmgr: initialise "voting_term" in "repmgr primary register"
This previously happened in the extension SQL code, which could
potentially cause replay problems if installing on a BDR cluster.

As this table is only required for streaming replication failover,
move the initialisation to "repmgr primary register".

Addresses GitHub #344 .
2017-11-28 11:08:12 +09:00
Ian Barwick
a6cc4d80f0 Add "witness register" functionality 2017-11-15 13:47:45 +09:00
Christoph Moench-Tegeder
a89084c6b5 include sys/wait.h for wait() and friends
the wait()-macros (WEXITSTATUS etc.) live in sys/wait.h as per
1003.1, and on some platforms (notably FreeBSD) compilation will
fail if wait.h isn't included explicitely.
2017-09-19 17:31:49 +02:00
Ian Barwick
687c8b4e27 Initial changes for 9.3 support 2017-09-15 10:27:37 +09:00
Ian Barwick
a9f4a027a7 pgindent run 2017-09-11 11:14:13 +09:00
Ian Barwick
e4f7dc8234 Add copyright notices 2017-09-08 13:27:39 +09:00
Ian Barwick
ed16c32fe7 Check minimum server version for pg_rewind 2017-08-31 13:30:59 +09:00
Ian Barwick
b1ba476241 Rename "archiver" check etc. to "archive-ready"
Gives a better indication of what's being checked.
2017-08-17 12:23:56 +09:00
Ian Barwick
eabd56f3be "standby follow": check node system identifiers match 2017-08-14 11:45:08 +09:00
Ian Barwick
b95b3e50e3 Return system identification information with appropriate data types 2017-08-14 08:50:54 +09:00
Ian Barwick
50b82f785e Add function to execute "IDENTIFY_SYSTEM" 2017-08-11 22:01:02 +09:00
Ian Barwick
8a50a72dc5 Additional "node status" output 2017-08-10 17:18:08 +09:00
Ian Barwick
4f2161bd83 Cleanup various #defines 2017-08-10 15:11:53 +09:00
Ian Barwick
970ed5d959 Bump minimum supported version to 9.5
We assume availability of pg_rewind.
2017-08-10 15:07:32 +09:00
Ian Barwick
f2cf46bba3 Check replication lag before attempting switchover 2017-08-08 10:16:47 +09:00
Ian Barwick
2499b42ef8 switchover: check for pending archive files on the demotion candidate
If the current primary (demotion candidate) still has any files to archive,
it will delay the shutdown until all files are archived. If there is a
substantial number of files, and/or the archive command executes slowly,
this will probably lead to an unwelcome delay in the switchover process.
2017-08-08 00:37:20 +09:00
Ian Barwick
7cf3b9b618 repmgrd: improve logging of BDR monitoring
Also always log information about event_notification command
2017-07-27 21:12:41 +09:00
Ian Barwick
eff26b496c repmgrd: updates for BDR monitoring 2017-07-27 09:49:53 +09:00
Ian Barwick
56b2e9bb84 Rename/add configuration file options
In previous versions of repmgr, some options had ambiguous meanings,
and/or were used for slightly different purposes. This way we end
up with a couple more options (most of which probably won't need
adjusting) but greater clarity and flexibility.

Removed:

  master_reponse_timeout:
    renamed to "async_query_timeout", as this was its main usage

  retry_promote_interval_secs:
    replaced by "primary_notification_timeout"

Added:
  async_query_timeout:
    timeout (in seconds) when executing asynchronous queries

  primary_notification_timeout:
    number of seconds to wait for notification from the new primary
    after a failover

  primary_follow_timeout:
    number of seconds to wait for the new primary to become available
    when executing "repmgr standby follow"
2017-07-25 11:13:32 +09:00
Ian Barwick
ec00202a31 Add configure option --with-bdr-only
Builds repmgr with only BDR functionality; other code is disabled
at critical points.
2017-07-16 17:18:34 +09:00
Ian Barwick
a29bc3e0fa Rename config.[ch] to configfile.[ch] 2017-07-16 09:41:26 +09:00
Ian Barwick
e3b3fb65f0 repmgrd: restrict BDR monitoring to two node setup
It's not safe to have more than two nodes with this kind of
"failover", so we don't need to select alternative nodes by
priority.
2017-07-14 12:56:11 +09:00
Ian Barwick
5fbcf3e476 Remove witness server references 2017-07-10 09:31:31 +09:00
Ian Barwick
2787994a6e Make repmgrd failover settings configurable 2017-07-07 21:11:22 +09:00
Ian Barwick
0d226867b4 Add "location" column 2017-07-06 01:17:00 +09:00
Ian Barwick
ded8d95e5a interim commit 2017-06-28 16:38:41 +09:00
Ian Barwick
7845a1fb47 Minimum supported version is currently 9.4 2017-06-25 21:46:50 +09:00
Ian Barwick
5ab2ac0e9a Convert configuration file parmeter "failover_mode" to an enum
We might want to add more modes in the future.
2017-06-21 09:53:41 +09:00
Ian Barwick
94a88326ef repmgrd: further code ported 2017-06-20 09:17:29 +09:00
Ian Barwick
dc347f1484 Additional "standby clone" code
We'll break up the unwieldy "do_standby_clone()" function into discrete
unit for easier maintenance.
2017-04-28 22:00:26 +09:00
Ian Barwick
bcf55b4f72 Split "action" functions to individual files
repmgr3's repmgr.c file was not far off 10,000 lines - this will make
it easier to manage individual parts of the code.
2017-04-26 22:58:21 +09:00
Ian Barwick
18c2cfda0b Fix tabulation 2017-04-22 09:06:42 +09:00
Ian Barwick
001d887e8d Initial database functions 2017-04-21 15:12:33 +09:00
Ian Barwick
0b0a0c69fc Implement config file parsing 2017-04-21 12:11:00 +09:00
Ian Barwick
f9dfcb20b4 Initial config file structure definition and initialisation 2017-04-20 16:42:56 +09:00
Ian Barwick
0fb4876256 Initial config file infrastructure
Also unify command line option structure/parsing so everything's
in the same order in the code.
2017-04-20 09:41:50 +09:00
Ian Barwick
8968cfe735 Add logging and repmgr command sanity checks 2017-04-20 00:32:04 +09:00