Commit Graph

89 Commits

Author SHA1 Message Date
Ian Barwick
058c8168e1 repmgrd: fix syntax 2018-08-30 15:54:31 +09:00
Ian Barwick
0468e47ef3 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:47:49 +09:00
Ian Barwick
25f68bb283 repmgrd: report version number *after* logger initialisation
This ensures the version number always makes it into the log destination.

Implements GitHub #487.
2018-08-08 15:45:48 +09:00
Ian Barwick
388ac2f392 repmgrd: enable package to supply default PID file path
Also add documentation for packagers about paths which can be patched
as default package values.
2018-07-13 10:26:47 +09:00
Ian Barwick
a194cf56b3 repmgr: exit with an error if an unrecognised command line option is provided.
This matches the behaviour of other PostgreSQL utilities such as psql, though
repmgr will only abort once all command line options are parsed, so as many
errors as possible are found and displayed. If a repmgr "command" (e.g.
"repmgr primary ..." was provided, a hint about the relevant command
help section (e.g. "repmgr primary --help") will be provided alongside
the generic help command (i.e. "repmgr --help").

Addresses GitHub #464, with further improvements.
2018-07-04 11:02:50 +09:00
Ian Barwick
802755fd60 repmgrd: daemonize process by default
It's hard to imagine a use case where this isn't desirable, but
in case, for whatever reason, the user does not wish to daemonize the
process, the command line option "--daemonize=false" can be provided.

Implements GitHub #458.
2018-06-29 22:01:49 +09:00
Ian Barwick
8d636690bd repmgrd: create pid file by default
Traditionally repmgrd will only write a pidfile if explicitly requested with
-p/--pid-file. However it's normally desirable to have a pidfile, and it's
preferable to have one used by default to prevent accidentally starting a second
repmgrd instance.

Following changes made:

 - add configuration file parameter "repmgrd_pid_file" (initially overridden by
   -p/--pid-file for backwards compatibility, though eventually we'll want to
   drop -p/--pid-file altogether)
 - add command line option --no-pid-file
 - if neither "repmgrd_pid_file" nor -p/--pid-file is set, create the pid file
   in a temporary directory

Implements GitHub #457.
2018-06-29 14:36:24 +09:00
Ian Barwick
6f315c1b3c repmgrd: don't explicitly close connections on shutdown 2018-05-01 10:21:10 +09:00
Ian Barwick
73982859f6 repmgrd: improve log output
- emit explicit startup NOTICE
- emit NOTICE when falling back to degraded monitoring on a primary node
- improve log message and event notification details when monitoring
  a former primary which has been reconnected as a standby
2018-04-03 14:37:06 +09:00
Ian Barwick
a403da67bc Consolidate connection closure calls 2018-03-27 16:43:59 +09:00
Ian Barwick
0219f4c91f Always set "connect_timeout" when pinging a PostgreSQL instance
Insert "connect_timeout=2" into the connection parameters, if not
explicitly set by the user. This will prevent excessive wait time
for the host operating system to report a connection timeout.
2018-03-21 11:48:57 +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
e38a9ec7e1 repmgrd: fix main monitoring loop for witness server
Missing "break" was breaking it when following a new primary.
2018-03-02 11:04:22 +09:00
Ian Barwick
64d85587de repmgrd: check "repmgr" extension is installed before starting
Implements GitHub #361.
2018-02-12 11:38:31 +09:00
Ian Barwick
ec068e38a2 Remove --bdr-only configuration option
This was required for a specific use case during pre-release
development and is no longer needed now the physical streaming
replication handling is implemented.
2018-01-25 10:48:09 +09:00
Ian Barwick
26a9e848fd Update copyright notices to 2018 2018-01-02 10:19:46 +09:00
Ian Barwick
a6cc4d80f0 Add "witness register" functionality 2017-11-15 13:47:45 +09:00
Ian Barwick
aa089820ab repmgrd: check shared library is loaded
If this isn't the case, "repmgrd" will appear to run but not handle
failover correctly.

Address GitHub #337.
2017-11-10 14:35:17 +09:00
Ian Barwick
d6c27f8938 Standardize quoting in log messages 2017-10-04 09:34:59 +09:00
Ian Barwick
e288d1ae3c repmgrd: clarify comment about configuration file parsing
There's no requirement to provide a configuration file, but if not,
one must be available in one of the default locations.
2017-09-20 09:35:09 +09:00
Martín Marqués
64cebb8b26 When searching for the path of the config file we were using config_file
which is the value the user passes with the -f option. If the user didn't
pass a value, this variable will have a value of NULL.
The variable which has the correct path is config_file_path, which will
have the same value provided by config_file if it's a valid file, or
the file if found in one of the default locations.
2017-09-20 09:22:04 +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
c1ed248fb1 Handle "event_notifications" when reloading configuration 2017-08-25 23:07:07 +09:00
Ian Barwick
fcd111ac4c Improve logging output during failover process 2017-08-24 22:44:03 +09:00
Ian Barwick
a659132ea4 repmgrd: write monitoring statistics 2017-08-24 11:49:44 +09:00
Ian Barwick
44d1b96bc3 repmgrd: fix log output 2017-08-22 13:21:16 +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
fed6fba4ef repmgrd: more fixes for BDR node recovery 2017-07-27 14:13:39 +09:00
Ian Barwick
0dcd479322 Store node status in node record struct 2017-07-17 13:50:17 +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
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
d653888c65 Support pre-10 WAL functions 2017-07-14 10:40:11 +09:00
Ian Barwick
d77e8d4d22 repmgrd: split physical and BDR functionality into separate files 2017-07-13 17:21:29 +09:00
Ian Barwick
2962ffe605 repmgrd: initial BDR monitoring support 2017-07-10 23:58:59 +09:00
Ian Barwick
941ed343f8 repmgrd: additional location check
If only one promotion candidate is available, check it is in the
same location as the primary.
2017-07-10 15:20:43 +09:00
Ian Barwick
5fbcf3e476 Remove witness server references 2017-07-10 09:31:31 +09:00
Ian Barwick
9e3d942917 Handle various (unlikely) failure states 2017-07-10 09:00:18 +09:00
Ian Barwick
5bf7098139 repmgrd: consolidate clear_node_info_list() calls 2017-07-09 11:10:49 +09:00
Ian Barwick
2787994a6e Make repmgrd failover settings configurable 2017-07-07 21:11:22 +09:00
Ian Barwick
35df85e67d repmgrd: improve handling of "degraded monitoring"
In some cases, the monitored upstream may not be available for a while
(e.g. network split), in which case it makes sense to have repmgrd
keep running and trying to reconnect. Previously it would just keel
over and quit.
2017-07-06 17:19:55 +09:00
Ian Barwick
6b82ecbafc repmgrd: check for visibility of primary location
Also support degraded monitoring status
2017-07-06 11:45:04 +09:00
Ian Barwick
ff4cc64a67 repmgrd: refresh upstream node record from upstream itself 2017-07-05 13:23:42 +09:00
Ian Barwick
3c45853b6f Fixes for cascaded standby failover 2017-07-05 12:43:35 +09:00
Ian Barwick
a31d66f826 repmgr standby follow: add event details
Useful to have a confirmation of which node was followed.
2017-07-05 11:36:30 +09:00
Ian Barwick
2f2a983272 Fixes for cascaded standby monitoring 2017-07-05 11:26:09 +09:00