From e4d1ee85b02a2f2f4eb9fcd6f92dbde4630500a4 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 4 Nov 2022 08:01:48 +0000 Subject: [PATCH] Allow revive a lost replication slot when WAL to catch up exceeds max_slot_wal_keep_size. --- src/backend/replication/slot.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/backend/replication/slot.c b/src/backend/replication/slot.c index c036a2c37b..7fba6ff163 100644 --- a/src/backend/replication/slot.c +++ b/src/backend/replication/slot.c @@ -1265,7 +1265,7 @@ InvalidatePossiblyObsoleteSlot(ReplicationSlot *s, XLogRecPtr oldestLSN, * If the slot is already invalid or is fresh enough, we don't need to * do anything. */ - if (XLogRecPtrIsInvalid(restart_lsn) || restart_lsn >= oldestLSN) + if (!XLogRecPtrIsInvalid(s->data.invalidated_at) || restart_lsn >= oldestLSN) { SpinLockRelease(&s->mutex); if (released_lock) @@ -1286,7 +1286,6 @@ InvalidatePossiblyObsoleteSlot(ReplicationSlot *s, XLogRecPtr oldestLSN, MyReplicationSlot = s; s->active_pid = MyProcPid; s->data.invalidated_at = restart_lsn; - s->data.restart_lsn = InvalidXLogRecPtr; /* Let caller know */ *invalidated = true; -- 2.25.1