summaryrefslogtreecommitdiff
path: root/src/backend/replication/slotfuncs.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/replication/slotfuncs.c')
-rw-r--r--src/backend/replication/slotfuncs.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/src/backend/replication/slotfuncs.c b/src/backend/replication/slotfuncs.c
index 06e4955de73..3fc54cb9bab 100644
--- a/src/backend/replication/slotfuncs.c
+++ b/src/backend/replication/slotfuncs.c
@@ -283,6 +283,7 @@ pg_get_replication_slots(PG_FUNCTION_ARGS)
bool nulls[PG_GET_REPLICATION_SLOTS_COLS];
WALAvailability walstate;
XLogSegNo last_removed_seg;
+ XLogRecPtr targetLSN;
int i;
if (!slot->in_use)
@@ -342,7 +343,15 @@ pg_get_replication_slots(PG_FUNCTION_ARGS)
else
nulls[i++] = true;
- walstate = GetWALAvailability(slot_contents.data.restart_lsn);
+ /*
+ * Report availability from invalidated_at when the slot has been
+ * invalidated; otherwise slots would appear as invalid without any
+ * more clues as to what happened.
+ */
+ targetLSN = XLogRecPtrIsInvalid(slot_contents.data.restart_lsn) ?
+ slot_contents.data.invalidated_at :
+ slot_contents.data.restart_lsn;
+ walstate = GetWALAvailability(targetLSN);
switch (walstate)
{