From 88089fc216a467cea937e33229454ea3168a9f76 Mon Sep 17 00:00:00 2001
From: Christoph Berg <christoph.berg@credativ.de>
Date: Wed, 24 Jun 2020 16:08:32 +0200
Subject: [PATCH 4/4] Fix check_replication_slots on recently promoted servers
Addresses parts of #163.
---
check_postgres.pl | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/check_postgres.pl b/check_postgres.pl
index 8646133..8784508 100755
--- a/check_postgres.pl
+++ b/check_postgres.pl
@@ -5707,7 +5707,11 @@ sub check_replication_slots {
WITH slots AS (SELECT slot_name,
slot_type,
coalesce(restart_lsn, '0/0'::pg_lsn) AS slot_lsn,
- coalesce(pg_xlog_location_diff(coalesce(pg_last_xlog_receive_location(), pg_current_xlog_location()), restart_lsn),0) AS delta,
+ coalesce(
+ pg_xlog_location_diff(
+ case when pg_is_in_recovery() then pg_last_xlog_receive_location() else pg_current_xlog_location() end,
+ restart_lsn),
+ 0) AS delta,
active
FROM pg_replication_slots)
SELECT *, pg_size_pretty(delta) AS delta_pretty FROM slots;
@@ -10989,6 +10993,10 @@ Items not specifically attributed are by GSM (Greg Sabino Mullane).
=over 4
+=item B<Version 2.25.1> Released ??, 2020
+
+ Fix check_replication_slots on recently promoted servers (Christoph Berg)
+
=item B<Version 2.25.0> Released February 3, 2020
Allow same_schema objects to be included or excluded with --object and --skipobject
--
2.26.2