From 390725f4d967bbf37c884c9cfb3c375cb7071fd6 Mon Sep 17 00:00:00 2001 From: alterego655 <824662526@qq.com> Date: Wed, 27 May 2026 18:50:51 +0800 Subject: [PATCH] Fix safe_wal_size for slots without restart_lsn pg_replication_slots could report a non-NULL safe_wal_size for a replication slot that had never reserved WAL, when max_slot_wal_keep_size was finite. Such a slot has no restart_lsn, so WAL availability and safe_wal_size are undefined. Return NULL for safe_wal_size when WAL availability is invalid. --- src/backend/replication/slotfuncs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/backend/replication/slotfuncs.c b/src/backend/replication/slotfuncs.c index 16fbd383735..7d238becd49 100644 --- a/src/backend/replication/slotfuncs.c +++ b/src/backend/replication/slotfuncs.c @@ -400,7 +400,7 @@ pg_get_replication_slots(PG_FUNCTION_ARGS) * safe_wal_size is only computed for slots that have not been lost, * and only if there's a configured maximum size. */ - if (walstate == WALAVAIL_REMOVED || max_slot_wal_keep_size_mb < 0) + if (walstate == WALAVAIL_REMOVED || walstate == WALAVAIL_INVALID_LSN || max_slot_wal_keep_size_mb < 0) nulls[i++] = true; else { -- 2.51.0