From 5f1bf0fb8fd9607478b52604ccd717565bb2b3dd Mon Sep 17 00:00:00 2001 From: Ian Barwick Date: Fri, 16 Nov 2018 12:36:36 +0900 Subject: [PATCH] Bump master branch to 4.3dev --- Makefile.in | 4 +- configure | 34 ++++---- configure.in | 2 +- repmgr--4.2--4.3.sql | 4 + repmgr--4.3.sql | 197 +++++++++++++++++++++++++++++++++++++++++++ repmgr.control | 2 +- repmgr_version.h.in | 2 +- 7 files changed, 224 insertions(+), 21 deletions(-) create mode 100644 repmgr--4.2--4.3.sql create mode 100644 repmgr--4.3.sql diff --git a/Makefile.in b/Makefile.in index 2f022973..cbe29f51 100644 --- a/Makefile.in +++ b/Makefile.in @@ -15,7 +15,9 @@ DATA = \ repmgr--4.0--4.1.sql \ repmgr--4.1.sql \ repmgr--4.1--4.2.sql \ - repmgr--4.2.sql + repmgr--4.2.sql \ + repmgr--4.2--4.3.sql \ + repmgr--4.3.sql REGRESS = repmgr_extension diff --git a/configure b/configure index 5524b89b..a7100b87 100755 --- a/configure +++ b/configure @@ -1,8 +1,8 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for repmgr 4.2. +# Generated by GNU Autoconf 2.69 for repmgr 4.3. # -# Report bugs to . +# Report bugs to . # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -269,7 +269,7 @@ fi $as_echo "$0: be upgraded to zsh 4.3.4 or later." else $as_echo "$0: Please tell bug-autoconf@gnu.org and -$0: pgsql-bugs@postgresql.org about your system, including +$0: repmgr@googlegroups.com about your system, including $0: any error possibly output before this message. Then $0: install a modern shell, or manually run the script $0: under such a shell if you do have one." @@ -582,10 +582,10 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='repmgr' PACKAGE_TARNAME='repmgr' -PACKAGE_VERSION='4.2' -PACKAGE_STRING='repmgr 4.2' -PACKAGE_BUGREPORT='pgsql-bugs@postgresql.org' -PACKAGE_URL='https://2ndquadrant.com/en/resources/repmgr/' +PACKAGE_VERSION='4.3' +PACKAGE_STRING='repmgr 4.3' +PACKAGE_BUGREPORT='repmgr@googlegroups.com' +PACKAGE_URL='https://repmgr.org/' ac_subst_vars='LTLIBOBJS LIBOBJS @@ -1178,7 +1178,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures repmgr 4.2 to adapt to many kinds of systems. +\`configure' configures repmgr 4.3 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1239,7 +1239,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of repmgr 4.2:";; + short | recursive ) echo "Configuration of repmgr 4.3:";; esac cat <<\_ACEOF @@ -1249,8 +1249,8 @@ Some influential environment variables: Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. -Report bugs to . -repmgr home page: . +Report bugs to . +repmgr home page: . _ACEOF ac_status=$? fi @@ -1313,7 +1313,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -repmgr configure 4.2 +repmgr configure 4.3 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1332,7 +1332,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by repmgr $as_me 4.2, which was +It was created by repmgr $as_me 4.3, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2359,7 +2359,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by repmgr $as_me 4.2, which was +This file was extended by repmgr $as_me 4.3, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -2415,14 +2415,14 @@ $config_files Configuration headers: $config_headers -Report bugs to . -repmgr home page: ." +Report bugs to . +repmgr home page: ." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -repmgr config.status 4.2 +repmgr config.status 4.3 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" diff --git a/configure.in b/configure.in index 61cffba7..3f7a0989 100644 --- a/configure.in +++ b/configure.in @@ -1,4 +1,4 @@ -AC_INIT([repmgr], [4.2], [pgsql-bugs@postgresql.org], [repmgr], [https://2ndquadrant.com/en/resources/repmgr/]) +AC_INIT([repmgr], [4.3], [repmgr@googlegroups.com], [repmgr], [https://repmgr.org/]) AC_COPYRIGHT([Copyright (c) 2010-2018, 2ndQuadrant Ltd.]) diff --git a/repmgr--4.2--4.3.sql b/repmgr--4.2--4.3.sql new file mode 100644 index 00000000..bbb475d2 --- /dev/null +++ b/repmgr--4.2--4.3.sql @@ -0,0 +1,4 @@ +-- complain if script is sourced in psql, rather than via CREATE EXTENSION +\echo Use "CREATE EXTENSION repmgr" to load this file. \quit + +-- XXX add new functions here diff --git a/repmgr--4.3.sql b/repmgr--4.3.sql new file mode 100644 index 00000000..c0567ca3 --- /dev/null +++ b/repmgr--4.3.sql @@ -0,0 +1,197 @@ +-- complain if script is sourced in psql, rather than via CREATE EXTENSION +\echo Use "CREATE EXTENSION repmgr" to load this file. \quit + +CREATE TABLE repmgr.nodes ( + node_id INTEGER PRIMARY KEY, + upstream_node_id INTEGER NULL REFERENCES nodes (node_id) DEFERRABLE, + active BOOLEAN NOT NULL DEFAULT TRUE, + node_name TEXT NOT NULL, + type TEXT NOT NULL CHECK (type IN('primary','standby','witness','bdr')), + location TEXT NOT NULL DEFAULT 'default', + priority INT NOT NULL DEFAULT 100, + conninfo TEXT NOT NULL, + repluser VARCHAR(63) NOT NULL, + slot_name TEXT NULL, + config_file TEXT NOT NULL +); + +CREATE TABLE repmgr.events ( + node_id INTEGER NOT NULL, + event TEXT NOT NULL, + successful BOOLEAN NOT NULL DEFAULT TRUE, + event_timestamp TIMESTAMP WITH TIME ZONE NOT NULL DEFAULT CURRENT_TIMESTAMP, + details TEXT NULL +); + +DO $repmgr$ +DECLARE + DECLARE server_version_num INT; +BEGIN + SELECT setting + FROM pg_catalog.pg_settings + WHERE name = 'server_version_num' + INTO server_version_num; + IF server_version_num >= 90400 THEN + EXECUTE $repmgr_func$ +CREATE TABLE repmgr.monitoring_history ( + primary_node_id INTEGER NOT NULL, + standby_node_id INTEGER NOT NULL, + last_monitor_time TIMESTAMP WITH TIME ZONE NOT NULL, + last_apply_time TIMESTAMP WITH TIME ZONE, + last_wal_primary_location PG_LSN NOT NULL, + last_wal_standby_location PG_LSN, + replication_lag BIGINT NOT NULL, + apply_lag BIGINT NOT NULL +) + $repmgr_func$; + ELSE + EXECUTE $repmgr_func$ +CREATE TABLE repmgr.monitoring_history ( + primary_node_id INTEGER NOT NULL, + standby_node_id INTEGER NOT NULL, + last_monitor_time TIMESTAMP WITH TIME ZONE NOT NULL, + last_apply_time TIMESTAMP WITH TIME ZONE, + last_wal_primary_location TEXT NOT NULL, + last_wal_standby_location TEXT, + replication_lag BIGINT NOT NULL, + apply_lag BIGINT NOT NULL +) + $repmgr_func$; + END IF; +END$repmgr$; + + + +CREATE INDEX idx_monitoring_history_time + ON repmgr.monitoring_history (last_monitor_time, standby_node_id); + +CREATE VIEW repmgr.show_nodes AS + SELECT n.node_id, + n.node_name, + n.active, + n.upstream_node_id, + un.node_name AS upstream_node_name, + n.type, + n.priority, + n.conninfo + FROM repmgr.nodes n +LEFT JOIN repmgr.nodes un + ON un.node_id = n.upstream_node_id; + + +/* XXX update upgrade scripts! */ +CREATE TABLE repmgr.voting_term ( + term INT NOT NULL +); + +CREATE UNIQUE INDEX voting_term_restrict +ON repmgr.voting_term ((TRUE)); + +CREATE RULE voting_term_delete AS + ON DELETE TO repmgr.voting_term + DO INSTEAD NOTHING; + + +/* ================= */ +/* repmgrd functions */ +/* ================= */ + +/* monitoring functions */ + +CREATE FUNCTION set_local_node_id(INT) + RETURNS VOID + AS 'MODULE_PATHNAME', 'set_local_node_id' + LANGUAGE C STRICT; + +CREATE FUNCTION get_local_node_id() + RETURNS INT + AS 'MODULE_PATHNAME', 'get_local_node_id' + LANGUAGE C STRICT; + +CREATE FUNCTION standby_set_last_updated() + RETURNS TIMESTAMP WITH TIME ZONE + AS 'MODULE_PATHNAME', 'standby_set_last_updated' + LANGUAGE C STRICT; + +CREATE FUNCTION standby_get_last_updated() + RETURNS TIMESTAMP WITH TIME ZONE + AS 'MODULE_PATHNAME', 'standby_get_last_updated' + LANGUAGE C STRICT; + +/* failover functions */ + +CREATE FUNCTION notify_follow_primary(INT) + RETURNS VOID + AS 'MODULE_PATHNAME', 'notify_follow_primary' + LANGUAGE C STRICT; + +CREATE FUNCTION get_new_primary() + RETURNS INT + AS 'MODULE_PATHNAME', 'get_new_primary' + LANGUAGE C STRICT; + +CREATE FUNCTION reset_voting_status() + RETURNS VOID + AS 'MODULE_PATHNAME', 'reset_voting_status' + LANGUAGE C STRICT; + +CREATE FUNCTION am_bdr_failover_handler(INT) + RETURNS BOOL + AS 'MODULE_PATHNAME', 'am_bdr_failover_handler' + LANGUAGE C STRICT; + +CREATE FUNCTION unset_bdr_failover_handler() + RETURNS VOID + AS 'MODULE_PATHNAME', 'unset_bdr_failover_handler' + LANGUAGE C STRICT; + +CREATE FUNCTION get_repmgrd_pid() + RETURNS INT + AS 'MODULE_PATHNAME', 'get_repmgrd_pid' + LANGUAGE C STRICT; + +CREATE FUNCTION get_repmgrd_pidfile() + RETURNS TEXT + AS 'MODULE_PATHNAME', 'get_repmgrd_pidfile' + LANGUAGE C STRICT; + +CREATE FUNCTION set_repmgrd_pid(INT, TEXT) + RETURNS VOID + AS 'MODULE_PATHNAME', 'set_repmgrd_pid' + LANGUAGE C STRICT; + +CREATE FUNCTION repmgrd_is_running() + RETURNS BOOL + AS 'MODULE_PATHNAME', 'repmgrd_is_running' + LANGUAGE C STRICT; + +CREATE FUNCTION repmgrd_pause(BOOL) + RETURNS VOID + AS 'MODULE_PATHNAME', 'repmgrd_pause' + LANGUAGE C STRICT; + +CREATE FUNCTION repmgrd_is_paused() + RETURNS BOOL + AS 'MODULE_PATHNAME', 'repmgrd_is_paused' + LANGUAGE C STRICT; + + +CREATE VIEW repmgr.replication_status AS + SELECT m.primary_node_id, m.standby_node_id, n.node_name AS standby_name, + n.type AS node_type, n.active, last_monitor_time, + CASE WHEN n.type='standby' THEN m.last_wal_primary_location ELSE NULL END AS last_wal_primary_location, + m.last_wal_standby_location, + CASE WHEN n.type='standby' THEN pg_catalog.pg_size_pretty(m.replication_lag) ELSE NULL END AS replication_lag, + CASE WHEN n.type='standby' THEN + CASE WHEN replication_lag > 0 THEN age(now(), m.last_apply_time) ELSE '0'::INTERVAL END + ELSE NULL + END AS replication_time_lag, + CASE WHEN n.type='standby' THEN pg_catalog.pg_size_pretty(m.apply_lag) ELSE NULL END AS apply_lag, + AGE(NOW(), CASE WHEN pg_catalog.pg_is_in_recovery() THEN repmgr.standby_get_last_updated() ELSE m.last_monitor_time END) AS communication_time_lag + FROM repmgr.monitoring_history m + JOIN repmgr.nodes n ON m.standby_node_id = n.node_id + WHERE (m.standby_node_id, m.last_monitor_time) IN ( + SELECT m1.standby_node_id, MAX(m1.last_monitor_time) + FROM repmgr.monitoring_history m1 GROUP BY 1 + ); + diff --git a/repmgr.control b/repmgr.control index 9449f399..d7e64515 100644 --- a/repmgr.control +++ b/repmgr.control @@ -1,6 +1,6 @@ # repmgr extension comment = 'Replication manager for PostgreSQL' -default_version = '4.2' +default_version = '4.3' module_pathname = '$libdir/repmgr' relocatable = false schema = repmgr diff --git a/repmgr_version.h.in b/repmgr_version.h.in index 26e797e5..8fe5025e 100644 --- a/repmgr_version.h.in +++ b/repmgr_version.h.in @@ -1,2 +1,2 @@ #define REPMGR_VERSION_DATE "" -#define REPMGR_VERSION "4.2dev" +#define REPMGR_VERSION "4.3dev"