Commit Graph

226 Commits

Author SHA1 Message Date
Ian Barwick
eff26b496c repmgrd: updates for BDR monitoring 2017-07-27 09:49:53 +09:00
Ian Barwick
a9b0c16b3c Add "cluster matrix" and "cluster crosscheck" actions 2017-07-26 11:24:33 +09:00
Ian Barwick
c3083a0ba0 repmgr node status: add "raw" data columns too 2017-07-25 12:06:42 +09:00
Ian Barwick
2a08317984 repmgr node status: optional CSV output 2017-07-25 11:26:09 +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
cbe19d5868 repmgr node status: collate output into list
To make output in different formats (e.g. CSV) easier.
2017-07-25 09:27:21 +09:00
Ian Barwick
a793e951b6 Remove unused function
PQExpBuffers used to generate SQL, no need to worry about maximum
query length and more flexible for generating dynamic queries.
2017-07-25 08:22:21 +09:00
Ian Barwick
8a2e4db1bc Add "repmgr node status"
Outputs an overview of a node's status, and emits warnings if any
issues detected.
2017-07-25 00:39:04 +09:00
Ian Barwick
93c35618a2 Use bdr.bdr_is_active_in_db() when checking for BDR presence 2017-07-24 19:09:09 +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
e9cdf1c870 Add note 2017-07-20 23:57:28 +09:00
Ian Barwick
1a45287e76 Misc updates and fixes 2017-07-20 21:15:55 +09:00
Ian Barwick
b99443b0c8 Improvements to repmgr cluster show
Add documentation; show recovery status in --csv mode.
2017-07-20 10:25:13 +09:00
Ian Barwick
a5c5d9fa40 Show BDR status in "repmgr cluster show" output 2017-07-20 09:23:24 +09:00
Ian Barwick
38730033d4 Miscellaneous code cleanup 2017-07-20 09:11:38 +09:00
Ian Barwick
8dcfbfc313 Improve "repmgr cluster show" display
Rather than simply emit "FAILED" for an unreachable node,
indicate whether its state matches that expected by repmgr.

E.g. following output:

   ID | Name  | Role    | Status               | Upstream | Connection string
  ----+-------+---------+----------------------+----------+----------------------------------------------------
   1  | node1 | primary | * running            |          | host=localhost dbname=repmgr user=repmgr port=5501
   2  | node2 | standby | ? unreachable        | node1    | host=localhost dbname=repmgr user=repmgr port=5502
   3  | node3 | standby | ! running as primary | node1    | host=localhost dbname=repmgr user=repmgr port=5503

is for a cluster where "node2" has been manually stopped, and "node3"
manually promoted.
2017-07-19 23:16:16 +09:00
Ian Barwick
076934558d Allow "CLUSTER EVENTS" as synonym for "CLUSTER EVENT" 2017-07-19 22:08:22 +09:00
Ian Barwick
b79a514660 Improve "repmgr cluster event" output 2017-07-19 22:06:54 +09:00
Ian Barwick
f7d5621941 Improve "repmgr cluster show" output generation 2017-07-19 21:34:53 +09:00
Ian Barwick
49ac9cf9ca Add "repmgr cluster show" 2017-07-19 17:36:21 +09:00
Ian Barwick
d3776ad13e repmgrd: consolidate some code 2017-07-19 15:28:25 +09:00
Ian Barwick
a7b7d86ecc repmgrd: handle manual failover mode correctly 2017-07-19 14:01:01 +09:00
Ian Barwick
23e6440dfd repmgrd: initiate primary monitoring when local node is promoted manually 2017-07-19 11:15:38 +09:00
Ian Barwick
9558d0d3b8 repmgrd: prevent promotion of sole candidate if priority set to zero 2017-07-19 09:38:32 +09:00
Ian Barwick
6e270b2faf repmgrd: catch cases where more than one node has initiated voting
The node(s) with higher ID will "yield", leaving the decision making
up to the node with the lower ID.

This happens very rarely, usually when the random delay is close
enough on two or mode nodes that vote initiation is simultaneous.
2017-07-18 17:04:24 +09:00
Ian Barwick
248525ccba Remove unused PQexpBuffer
It was being referenced without being initialised, but the output
which would have been placed there is not used anyway, so discard
completely.
2017-07-18 12:06:26 +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
a56bb41891 Remove redundant fields from node record struct 2017-07-17 14:11:14 +09:00
Ian Barwick
0dcd479322 Store node status in node record struct 2017-07-17 13:50:17 +09:00
Ian Barwick
46acf75286 Fix usage of get_primary_node_record() 2017-07-17 12:12:59 +09:00
Ian Barwick
437cb26b7e Fixes to function request_vote() 2017-07-17 12:04:56 +09:00
Ian Barwick
ec554e5694 Improve connection handling
Set "connect_timeout" and "fallback_application_name" if not present.
2017-07-17 11:10:37 +09:00
Ian Barwick
084e0429fc Disable non-BDR functions for BDR-only buils 2017-07-17 08:44:49 +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
a6f8d59f77 Initial support for BDR-only build 2017-07-16 17:18:23 +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
91c7013024 Remove erroneously added file 2017-07-14 11:25:37 +09:00
Ian Barwick
d653888c65 Support pre-10 WAL functions 2017-07-14 10:40: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
Ian Barwick
0320f409aa Detect BDR capability via presence of extension 2017-07-13 14:13:46 +09:00
Ian Barwick
2594a46a4f Limit repmgr installation on a BDR cluster to two nodes 2017-07-13 14:10:08 +09:00