From 007693f2a3ac2ac19affcb03ad43cdb36ccff5b5 Mon Sep 17 00:00:00 2001 From: Amit Kapila Date: Thu, 4 Jan 2024 08:21:51 +0530 Subject: Track conflict_reason in pg_replication_slots. This patch changes the existing 'conflicting' field to 'conflict_reason' in pg_replication_slots. This new field indicates the reason for the logical slot's conflict with recovery. It is always NULL for physical slots, as well as for logical slots which are not invalidated. The non-NULL values indicate that the slot is marked as invalidated. Possible values are: wal_removed = required WAL has been removed. rows_removed = required rows have been removed. wal_level_insufficient = the primary doesn't have a wal_level sufficient to perform logical decoding. The existing users of 'conflicting' column can get the same answer by using 'conflict_reason' IS NOT NULL. Author: Shveta Malik Reviewed-by: Amit Kapila, Bertrand Drouvot, Michael Paquier Discussion: https://postgr.es/m/ZYOE8IguqTbp-seF@paquier.xyz --- src/backend/replication/slotfuncs.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'src/backend/replication/slotfuncs.c') diff --git a/src/backend/replication/slotfuncs.c b/src/backend/replication/slotfuncs.c index 47e104782c9..cad35dce7fc 100644 --- a/src/backend/replication/slotfuncs.c +++ b/src/backend/replication/slotfuncs.c @@ -406,10 +406,24 @@ pg_get_replication_slots(PG_FUNCTION_ARGS) nulls[i++] = true; else { - if (slot_contents.data.invalidated != RS_INVAL_NONE) - values[i++] = BoolGetDatum(true); - else - values[i++] = BoolGetDatum(false); + switch (slot_contents.data.invalidated) + { + case RS_INVAL_NONE: + nulls[i++] = true; + break; + + case RS_INVAL_WAL_REMOVED: + values[i++] = CStringGetTextDatum("wal_removed"); + break; + + case RS_INVAL_HORIZON: + values[i++] = CStringGetTextDatum("rows_removed"); + break; + + case RS_INVAL_WAL_LEVEL: + values[i++] = CStringGetTextDatum("wal_level_insufficient"); + break; + } } Assert(i == PG_GET_REPLICATION_SLOTS_COLS); -- cgit v1.2.3