mirror of
https://github.com/neondatabase/neon.git
synced 2025-12-26 15:49:58 +00:00
We can't call pg_current_wal_lsn() if we are a standby instance (read replica). Any attempt to call this function while in recovery results in: ERROR: recovery is in progress Signed-off-by: Tristan Partin <tristan@neon.tech>
11 lines
239 B
SQL
11 lines
239 B
SQL
SELECT
|
|
slot_name,
|
|
pg_wal_lsn_diff(
|
|
CASE
|
|
WHEN pg_is_in_recovery() THEN pg_last_wal_replay_lsn()
|
|
ELSE pg_current_wal_lsn()
|
|
END,
|
|
restart_lsn)::FLOAT8 AS retained_wal
|
|
FROM pg_replication_slots
|
|
WHERE active = false;
|