Commit Graph

38 Commits

Author SHA1 Message Date
Ian Barwick
a8d560860d Ensure BDR-specific code only runs on BDR 2.x
The BDR support in repmgr is for a specific BDR 2.x use case, and
is not suitable for more recent BDR versions.
2019-04-05 14:37:49 +09:00
Ian Barwick
9164d3931b repmgrd: clean up PQExpBuffer handling
Unless the PQExpBuffer is required for the duration of the function,
ensure it's always a variable local to the relevant code block. This
mitigates the risk of accidentally accessing a generically named
PQExpBuffer which hasn't been initialised or was previously terminated.
2019-03-26 13:15:25 +09:00
Ian Barwick
efe4a9c344 repmgrd: log receipt of SIGINT/SIGTERM 2019-01-23 13:44:59 +09:00
Ian Barwick
7dce3ed234 Update copyright notices to 2019 2019-01-21 14:54:35 +09:00
Ian Barwick
b0a2ee2259 get_all_node_records(): display any error encountered and return success status
In many cases we'll want to bail out with an error if the node list can't
be retrieved for any reason. This saves some repetitive coding.
2018-09-13 10:14:43 +09:00
Ian Barwick
17e75f6b31 repmgrd: improve reconnection handling
Previously, if the server being monitored was not available, repmgrd
would always close the existing connection handle and open a new one.

However, in some cases, e.g. a brief network outage, the existing
connection handle is still good and does not need to be reopened.

This could be particularly problematic if monitoring_history is on,
as this risks leaving orphan sessions on the primary which (given
a sufficiently unstable network) could lead to all available backends
being occupied.

Instead, during an outage we now use a new connection to verify
the server is accessible; if the old connection is still available
(e.g. following a short network interruption) we continue using that;
if  not (e.g. the server was restarted), we use the new one.
2018-08-30 15:46:08 +09:00
Ian Barwick
44a224ad92 repmgrd: fix configuration file reloading
Don't allow "promote_command" or "follow_command" to be empty.

GitHub #486.
2018-08-02 16:35:26 +09:00
Ian Barwick
26b565dff2 Improve repmgrd logging in BDR mode
Also ensure interval status log line is shown as intended
2018-04-03 14:38:32 +09:00
Ian Barwick
bad034f7ee repmgrd: remove duplicate local record check in BDR mode 2018-03-07 19:21:33 +09:00
Ian Barwick
cdb504d700 Add event "repmgrd_shutdown"
Implements GitHub #393
2018-03-06 11:00:03 +09:00
Ian Barwick
842a610e84 Fix call to is_active_bdr_node() in BDR repmgrd
Following the fix to "is_active_bdr_node()" in 841f03ae, it turns out
the call in repmgrd-bdr.c was only accidentally working; explicitly
test for a false return value.
2018-01-04 21:03:36 +09:00
Ian Barwick
26a9e848fd Update copyright notices to 2018 2018-01-02 10:19:46 +09:00
Ian Barwick
b8b991398a Escape double-quotes in strings passed to an event notification script
The string in question will be generated internally by repmgr as a simple
one-line string with no control characters etc., so all that needs to be
escaped at the moment are any double quotes.
2017-11-16 10:36:48 +09:00
Ian Barwick
d6c27f8938 Standardize quoting in log messages 2017-10-04 09:34:59 +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
e0888c1f62 repmgrd: handle SIGHUP 2017-08-29 12:55:13 +09:00
Ian Barwick
10ef30096c "node check": add server role check 2017-08-14 22:57:09 +09:00
Ian Barwick
8d7d83347a repmgrd: add log line to indicate node recovery detected 2017-07-31 09:58:13 +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
4cf66c33db repmgrd: more fixes to BDR recovery handling 2017-07-27 16:33:41 +09:00
Ian Barwick
fed6fba4ef repmgrd: more fixes for BDR node recovery 2017-07-27 14:13:39 +09:00
Ian Barwick
dc24d62009 repmgrd: improve BDR recovery handling 2017-07-27 11:53:55 +09:00
Ian Barwick
eff26b496c repmgrd: updates for BDR monitoring 2017-07-27 09:49:53 +09:00
Ian Barwick
d3c2a0f505 repmgrd: record bdr_recovery event on the node which was up
Attempting to write on the recovered node may result in an
error if it hadn't already started up.
2017-07-24 18:56:18 +09:00
Ian Barwick
8f2dde3bde repmgrd: log BDR node recovery on the running node, not the recovered node
The recovered node might still be starting up.
2017-07-24 12:50:51 +09:00
Ian Barwick
2c8dd49831 repmgrd: additional check to ensure only one node handles failover
It's possible the "failover" is completed by one repmgrd before the
other has a chance to react, in which case the am_bdr_failover_handler()
check will not apply. Instead check if the node record has already been
set to "inactive".
2017-07-17 16:47:42 +09:00
Ian Barwick
48a0aa3bf7 repmgrd: improve failover handling
Make retry frequency/interval configurable as per streaming replication.
2017-07-17 14:56:52 +09:00
Ian Barwick
0dcd479322 Store node status in node record struct 2017-07-17 13:50:17 +09:00
Ian Barwick
a29bc3e0fa Rename config.[ch] to configfile.[ch] 2017-07-16 09:41:26 +09:00
Ian Barwick
b1051bfca2 Minor fixes to BDR code 2017-07-16 08:27:07 +09:00
Ian Barwick
c93eb10ad3 Handle node recovery 2017-07-14 16:15:10 +09:00
Ian Barwick
951c7dbd07 repmgrd: in BDR mode, have each repmgrd monitor each node
This will cover both the case when an entire node including
repmgrd goes down, and when one PostgreSQL instance goes down
but repmgrd is still up (in which case only one of the repmgrds
will handle the failover).
2017-07-14 15:01:18 +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
dfcf85a62f repmgrd: further BDR sanity checks 2017-07-14 10:27:28 +09:00
Ian Barwick
875cdf5102 repmgrd: don't run in BDR mode on a node marked as inactive 2017-07-14 09:59:56 +09:00
Ian Barwick
aeba2e31f1 repmgrd: fix BDR sanity check 2017-07-14 09:54:34 +09:00
Ian Barwick
d77e8d4d22 repmgrd: split physical and BDR functionality into separate files 2017-07-13 17:21:29 +09:00