Skip to content

Commit

Permalink
pg_replication_slots in standby (#147)
Browse files Browse the repository at this point in the history
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.

Co-authored-by: Jiří Čtvrtka <[email protected]>
Co-authored-by: Nurlan Moldomurov <[email protected]>
  • Loading branch information
3 people authored Jan 10, 2024
1 parent 58dd345 commit 69eb75f
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cmd/postgres_exporter/queries.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,15 @@ 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
`,
},
{
semver.MustParseRange(">=10.0.0"),
`
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
`,
},
},
Expand Down

0 comments on commit 69eb75f

Please sign in to comment.