From 61e7b9b551f35cceaaa72b35a6849d8ba290d350 Mon Sep 17 00:00:00 2001 From: Francisco Miguel Biete Banon Date: Wed, 30 Aug 2023 10:21:41 +0100 Subject: [PATCH] pg_replication_slots in standby WAL functions cannot be executed in standby servers ``` ERROR: recovery is in progress HINT: WAL control functions cannot be executed during recovery. ``` In PostgreSQL 16 replication slots persist in the standby servers. This is also the case when using extensions like pg_failover_slots that transfer the slot information to the standby. This condition will make those queries to return values only in the primary node avoiding the errors. --- cmd/postgres_exporter/queries.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cmd/postgres_exporter/queries.go b/cmd/postgres_exporter/queries.go index ab87d018f..a82633ab1 100644 --- a/cmd/postgres_exporter/queries.go +++ b/cmd/postgres_exporter/queries.go @@ -119,6 +119,7 @@ var queryOverrides = map[string][]OverrideQuery{ ` SELECT slot_name, database, active, pg_xlog_location_diff(pg_current_xlog_location(), restart_lsn) FROM pg_replication_slots + WHERE pg_is_in_recovery() = False `, }, { @@ -126,6 +127,7 @@ var queryOverrides = map[string][]OverrideQuery{ ` SELECT slot_name, database, active, pg_wal_lsn_diff(pg_current_wal_lsn(), restart_lsn) FROM pg_replication_slots + WHERE pg_is_in_recovery() = False `, }, },