Hi,
Currently, pg_replication_slots can report a non-null safe_wal_size
for a replication slot that has never reserved WAL, if
max_slot_wal_keep_size is finite.
Such a slot has restart_lsn = NULL and wal_status = NULL. safe_wal_size is
derived from restart_lsn, so it's not meaningful in this state. The
current code handles WALAVAIL_REMOVED but not WALAVAIL_INVALID_LSN
before computing safe_wal_size, leading arithmetic on InvalidXLogRecPtr.
Fix this by returning NULL for safe_wal_size when WAL availability is
WALAVAIL_INVALID_LSN.
--
Regards,
Xuneng Zhou
HighGo Software Co., Ltd.