Commit Graph

920 Commits

Author SHA1 Message Date
Ian Barwick 01a33198fd Add configuration file parameter for pg_basebackup
"pg_basebackup_options"
  Enable custom options to be passed to pg_basebackup
  (e.g. --max-rate, --checkpoint, --xlogdir)

"tablespace_mapping"
  Analogue to pg_basebackup's (9.4 and later) -T/--tablespace-mapping
  option.

  Tablespace mapping could also be passed via "pg_basebackup_options",
  however by providing a separate parameter it makes the configuration
  file easier to read and allows us to verify the specified tablespaces
  exist (pg_basebackup won't do this, which can lead to undesired
  behaviour, i.e. attempting to create the tablespace in the original
  path).
2015-02-09 10:31:06 +09:00
Ian Barwick 1d28a2d08e runtime_options.wal_keep_segments is prepopulated with default value
Explicitly track if setting came from command line parameter.
2015-02-05 11:55:52 +09:00
Ian Barwick d4578e023e Mention use_replication_slots in sample config file 2015-02-05 11:19:54 +09:00
Ian Barwick 9ceef937eb Emit warning if -w/--wal-keep-segments used when use_replication_slots set 2015-02-05 11:17:23 +09:00
Ian Barwick f047ec9526 Use DEFAULT_WAL_KEEP_SEGMENTS in help output instead of hard-coded number 2015-02-04 14:08:55 +09:00
Ian Barwick a3f0e89a05 Improve pg_bindir parameter handling
Previously, the pg_bindir parameter was mandatory and could only be
provided in the repmgr.conf file, which was leading to the slightly
bizarre situation that e.g. for "clone standby", repmgr was complaining
that it didn't want the configuration file when it actually did.

pg_bindir is now optional - if not provided, it will use the default
path. It can be provided in the repmgr.conf file, or as a command
line parameter; the latter overrides the former.
2015-02-04 14:04:04 +09:00
Ian Barwick 3d9d0d98af Improve repmgr configuration file handling
Previous behaviour was somewhat counterintuitive, with an error
message being logged if no configuration file provided or found,
even though this is not actually an error.

Configuration files now handled like this:

- if a configuration file is explicitly provided (-f), error out
  if not found.

- if no configuration file explicitly provided, attempt to open
  default configuration file; if this does not exist, log
  notice and continue with default values.

Also, for 9.4 and later add a hint about replication slot usage
if 'use_replication_slots' not set.
2015-02-04 09:57:51 +09:00
Ian Barwick 49debcdf92 Add version check if replication slot usage requested
Replication slots require 9.4 or greater
2015-02-02 22:16:04 +09:00
Ian Barwick 7a760c32ff Store slot name in repl_nodes table 2015-02-02 17:57:15 +09:00
Ian Barwick b4b5e6cd30 do_standby_clone(): rename conn to primary_conn
For clarity.
2015-02-02 16:53:35 +09:00
Ian Barwick 2ece014952 Initial support for physical replication slots
Todo:
 - if slots specified in repmgr.conf, verify server version
 - store generated slot name in `repl_nodes` table
2015-02-02 15:53:53 +09:00
Ian Barwick 01360c3d39 Improve repl_status view. 2015-01-29 15:08:37 +09:00
Ian Barwick 031a726f04 Enable get_master_connection() to accept a null value for master_id
Saves worrying about the purpose of various superfluous ints
2015-01-29 11:25:01 +09:00
Ian Barwick 5c67d47881 Add query result tests 2015-01-28 18:05:19 +09:00
Ian Barwick f40b3ac48a Consolidate node type parsing 2015-01-28 11:57:34 +09:00
Ian Barwick 109269f7fb When writing monitoring info, ensure standby connects to current primary
If the node is a cascaded standby and the primary fails, `primary_conn`
will not be updated automatically; when writing monitoring info,
ensure we connect to the current primary.
2015-01-27 21:19:25 +09:00
Ian Barwick 36d94c88ac Handle empty result set
Should never happen, but just in case.`
2015-01-27 16:28:17 +09:00
Ian Barwick 23ef305afb After promotion or follow, update internal node metadata record 2015-01-27 16:25:58 +09:00
Ian Barwick 99dae5cdcb Function is_witness() no longer required
Node type can be extracted directly from the metadata
2015-01-27 15:32:13 +09:00
Ian Barwick b552710767 Remove global variable my_local_mode
Information now contained in metadata`x
2015-01-27 13:53:36 +09:00
Ian Barwick 7e4c26b8a0 Clarify upstream role in log messages 2015-01-27 12:39:39 +09:00
Ian Barwick f8639a7878 Add TODO note 2015-01-26 22:11:54 +09:00
Ian Barwick f2309bd0a9 Remove redundant comments 2015-01-26 21:25:37 +09:00
Ian Barwick 061e72d7cd Rename connection variable for clarity
Connection will always be the primary
2015-01-26 20:12:34 +09:00
Ian Barwick 0a19bf1e23 Reword notice to make more sense in log output context 2015-01-24 05:03:57 +09:00
Ian Barwick 84a4766f13 Basic failover for cascaded standby nodes
Attempt to attach to the next available upstream node, otherwise
quit monitoring. We'll need to add further options for failover
scenarios, including attempting to attach to another node,
shutting down the server completely etc.
2015-01-24 04:22:40 +09:00
Ian Barwick 3be8bf8e4c Check primary connection
Verify that existing primary connection is valid, and if not
attempt to find and connect to the current primary node.
2015-01-22 12:20:23 +09:00
Ian Barwick 1e6f1a88b0 On local node failure, attempt to update record on primary server 2015-01-22 11:45:01 +09:00
Ian Barwick 4a8912c2b4 Update comments and debugging output 2015-01-22 10:59:33 +09:00
Ian Barwick 3279e9e47e Separate functions for primary and cascading standby failover 2015-01-22 10:12:03 +09:00
Ian Barwick 5c4e77f8e2 do_failover() -> do_primary_failover() 2015-01-16 17:28:51 +09:00
Ian Barwick b09f987341 Add note 2015-01-16 16:59:44 +09:00
Ian Barwick fe758eda9f Update repl_nodes following failover
repl_nodes table updated by each node following failover to
show that either it is the primary, or which primary it has
started to follow.
2015-01-16 16:28:09 +09:00
Ian Barwick c413cff461 Function to update node records 2015-01-16 14:14:04 +09:00
Ian Barwick 609453a848 Handle failover of top-level standby
Cascaded standbys will not go into failover so we need to ignore
these when looking for candidates for promotion.
2015-01-16 12:35:01 +09:00
Ian Barwick a82d37e48a Improve node metadata and upstream connecting mechanism
To handle cascaded replication we're going to have to keep track
of each node's upstream node. Also enumerate the node type
("primary", "standby" or "witness") and mark if active.
2015-01-16 10:28:02 +09:00
Ian Barwick 4b6c097a3e Use AS for consistency 2015-01-16 08:46:28 +09:00
Ian Barwick 3dfa33d01d Store upstream node ID if set
Required to manage cascaded standbys
2015-01-16 00:29:43 +09:00
Ian Barwick a20afe28ec Add upstream_node_id to repl_nodes table 2015-01-15 23:54:07 +09:00
Ian Barwick 692204e381 Consolidate duplicated schema check code 2015-01-15 18:34:51 +09:00
Ian Barwick 2ae27521a3 Some infrastructure for supporting cascading replication
Does not fully work yet.
2015-01-15 15:37:09 +09:00
Ian Barwick d141d2a8aa Remove unused variable 2015-01-14 16:25:24 +09:00
Ian Barwick fc6f5ddaa7 Add function repmgr_get_primary_conninfo() 2015-01-14 16:23:08 +09:00
Ian Barwick 4b7fb70de3 Add current year to copyright 2015-01-14 15:50:42 +09:00
Ian Barwick 5db6489ae5 Initial support for cascaded standbys 2015-01-14 14:18:57 +09:00
Ian Barwick 96f6695a52 Clean up repmgr_get_last_standby_location() polling loop
No need to reconnect on every iteration of the loop. Move conditions
which break out of the loop straight away out of the loop.
2015-01-13 16:08:36 +09:00
Ian Barwick f006a79af9 Clean up log messages for invalid LSNs 2015-01-13 14:53:55 +09:00
Ian Barwick 3a8aa86e0c Remove pointless check 2015-01-13 14:25:58 +09:00
Ian Barwick 9cbac64ad4 Remove pointless check
Witness server can never be considered as a promotion candidate.
2015-01-13 14:24:19 +09:00
Ian Barwick 242fc8416c Consolidate disconnection calls 2015-01-13 13:59:27 +09:00