From 4e5246f210ed83c4897ce3200c7ae149e25257a4 Mon Sep 17 00:00:00 2001 From: Mario Gonzalez Date: Mon, 28 Oct 2024 10:08:33 -0300 Subject: [PATCH] Bump repmgr version 5.5.0 --- Makefile.in | 4 +- README.md | 5 +- configure.in | 4 +- repmgr--5.4--5.5.sql | 2 + repmgr--5.5.sql | 191 +++++++++++++++++++++++++++++++++++++++++++ repmgr_version.h.in | 12 +-- 6 files changed, 207 insertions(+), 11 deletions(-) create mode 100644 repmgr--5.4--5.5.sql create mode 100644 repmgr--5.5.sql diff --git a/Makefile.in b/Makefile.in index ef048f3e..07a0ba81 100644 --- a/Makefile.in +++ b/Makefile.in @@ -32,7 +32,9 @@ DATA = \ repmgr--5.2--5.3.sql \ repmgr--5.3.sql \ repmgr--5.3--5.4.sql \ - repmgr--5.4.sql + repmgr--5.4.sql \ + repmgr--5.4--5.5.sql \ + repmgr--5.5.sql REGRESS = repmgr_extension diff --git a/README.md b/README.md index 285eff5c..250a9b3c 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,9 @@ replication capabilities with utilities to set up standby servers, monitor replication, and perform administrative tasks such as failover or switchover operations. -The most recent `repmgr` version (5.4.1) supports all PostgreSQL versions from -10 to 16. +The most recent `repmgr` version (5.5.x) supports all PostgreSQL versions from +13 to 17. Despite it could be used with some older ones, some features might not +be available, however, it's strongly recommended to use the latest version. `repmgr` is distributed under the GNU GPL 3 and maintained by EnterpriseDB. diff --git a/configure.in b/configure.in index 860d5698..746472b2 100644 --- a/configure.in +++ b/configure.in @@ -1,6 +1,6 @@ -AC_INIT([repmgr], [5.4.0], [repmgr@googlegroups.com], [repmgr], [https://repmgr.org/]) +AC_INIT([repmgr], [5.5.0], [repmgr@googlegroups.com], [repmgr], [https://repmgr.org/]) -AC_COPYRIGHT([Copyright (c) 2010-2021, EnterpriseDB Corporation]) +AC_COPYRIGHT([Copyright (c) 2010-2024, EnterpriseDB Corporation]) AC_CONFIG_HEADER(config.h) diff --git a/repmgr--5.4--5.5.sql b/repmgr--5.4--5.5.sql new file mode 100644 index 00000000..02901de5 --- /dev/null +++ b/repmgr--5.4--5.5.sql @@ -0,0 +1,2 @@ +-- complain if script is sourced in psql, rather than via CREAT EXTENSION +\echo Use "CREATE EXTENSION repmgr" to load this file. \quit diff --git a/repmgr--5.5.sql b/repmgr--5.5.sql new file mode 100644 index 00000000..072b07b2 --- /dev/null +++ b/repmgr--5.5.sql @@ -0,0 +1,191 @@ +-- 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 +); + +SELECT pg_catalog.pg_extension_config_dump('repmgr.nodes', ''); + +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 +); + +SELECT pg_catalog.pg_extension_config_dump('repmgr.events', ''); + +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 +); + +CREATE INDEX idx_monitoring_history_time + ON repmgr.monitoring_history (last_monitor_time, standby_node_id); + +SELECT pg_catalog.pg_extension_config_dump('repmgr.monitoring_history', ''); + +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; + +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', 'repmgr_set_local_node_id' + LANGUAGE C STRICT; + +CREATE FUNCTION get_local_node_id() + RETURNS INT + AS 'MODULE_PATHNAME', 'repmgr_get_local_node_id' + LANGUAGE C STRICT; + +CREATE FUNCTION standby_set_last_updated() + RETURNS TIMESTAMP WITH TIME ZONE + AS 'MODULE_PATHNAME', 'repmgr_standby_set_last_updated' + LANGUAGE C STRICT; + +CREATE FUNCTION standby_get_last_updated() + RETURNS TIMESTAMP WITH TIME ZONE + AS 'MODULE_PATHNAME', 'repmgr_standby_get_last_updated' + LANGUAGE C STRICT; + +CREATE FUNCTION set_upstream_last_seen(INT) + RETURNS VOID + AS 'MODULE_PATHNAME', 'repmgr_set_upstream_last_seen' + LANGUAGE C STRICT; + +CREATE FUNCTION get_upstream_last_seen() + RETURNS INT + AS 'MODULE_PATHNAME', 'repmgr_get_upstream_last_seen' + LANGUAGE C STRICT; + +CREATE FUNCTION get_upstream_node_id() + RETURNS INT + AS 'MODULE_PATHNAME', 'repmgr_get_upstream_node_id' + LANGUAGE C STRICT; + +CREATE FUNCTION set_upstream_node_id(INT) + RETURNS VOID + AS 'MODULE_PATHNAME', 'repmgr_set_upstream_node_id' + LANGUAGE C STRICT; + +/* failover functions */ + +CREATE FUNCTION notify_follow_primary(INT) + RETURNS VOID + AS 'MODULE_PATHNAME', 'repmgr_notify_follow_primary' + LANGUAGE C STRICT; + +CREATE FUNCTION get_new_primary() + RETURNS INT + AS 'MODULE_PATHNAME', 'repmgr_get_new_primary' + LANGUAGE C STRICT; + +CREATE FUNCTION reset_voting_status() + RETURNS VOID + AS 'MODULE_PATHNAME', 'repmgr_reset_voting_status' + 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 CALLED ON NULL INPUT; + +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 FUNCTION get_wal_receiver_pid() + RETURNS INT + AS 'MODULE_PATHNAME', 'repmgr_get_wal_receiver_pid' + LANGUAGE C STRICT; + + + + +/* views */ + +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_version.h.in b/repmgr_version.h.in index dae2fa4d..b122a680 100644 --- a/repmgr_version.h.in +++ b/repmgr_version.h.in @@ -1,7 +1,7 @@ -#define REPMGR_VERSION_DATE "" -#define REPMGR_VERSION "5.4dev" -#define REPMGR_VERSION_NUM 50400 -#define REPMGR_EXTENSION_VERSION "5.4" -#define REPMGR_EXTENSION_NUM 50400 -#define REPMGR_RELEASE_DATE "2022-XX-XX" +#define REPMGR_VERSION_DATE "2024-11-20" +#define REPMGR_VERSION "5.5.0" +#define REPMGR_VERSION_NUM 50500 +#define REPMGR_EXTENSION_VERSION "5.5.0" +#define REPMGR_EXTENSION_NUM 50500 +#define REPMGR_RELEASE_DATE "2024-XX-XX" #define PG_ACTUAL_VERSION_NUM