diff options
| author | Amit Kapila <akapila@postgresql.org> | 2025-11-28 05:21:35 +0000 |
|---|---|---|
| committer | Amit Kapila <akapila@postgresql.org> | 2025-11-28 05:21:35 +0000 |
| commit | e68b6adad96d414fdf24e072fdb1d41fb4b8f0b7 (patch) | |
| tree | 36cbdc3befc3b490893d4daa2184aa664ca46adb /src/backend/replication/slotfuncs.c | |
| parent | 9ccc049dfe655ca9927f7c62559ec32f4d1f94dd (diff) | |
Add slotsync_skip_reason column to pg_replication_slots view.
Introduce a new column, slotsync_skip_reason, in the pg_replication_slots
view. This column records the reason why the last slot synchronization was
skipped. It is primarily relevant for logical replication slots on standby
servers where the 'synced' field is true. The value is NULL when
synchronization succeeds.
Author: Shlok Kyal <shlok.kyal.oss@gmail.com>
Reviewed-by: shveta malik <shveta.malik@gmail.com>
Reviewed-by: Hayato Kuroda <kuroda.hayato@fujitsu.com>
Reviewed-by: Ashutosh Sharma <ashu.coek88@gmail.com>
Reviewed-by: Hou Zhijie <houzj.fnst@fujitsu.com>
Reviewed-by: Amit Kapila <amit.kapila16@gmail.com>
Discussion: https://postgr.es/m/CAE9k0PkhfKrTEAsGz4DjOhEj1nQ+hbQVfvWUxNacD38ibW3a1g@mail.gmail.com
Diffstat (limited to 'src/backend/replication/slotfuncs.c')
| -rw-r--r-- | src/backend/replication/slotfuncs.c | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/backend/replication/slotfuncs.c b/src/backend/replication/slotfuncs.c index 0478fc9c977..7647f051581 100644 --- a/src/backend/replication/slotfuncs.c +++ b/src/backend/replication/slotfuncs.c @@ -25,6 +25,17 @@ #include "utils/pg_lsn.h" /* + * Map SlotSyncSkipReason enum values to human-readable names. + */ +static const char *SlotSyncSkipReasonNames[] = { + [SS_SKIP_NONE] = "none", + [SS_SKIP_WAL_NOT_FLUSHED] = "wal_not_flushed", + [SS_SKIP_WAL_OR_ROWS_REMOVED] = "wal_or_rows_removed", + [SS_SKIP_NO_CONSISTENT_SNAPSHOT] = "no_consistent_snapshot", + [SS_SKIP_INVALID] = "slot_invalidated" +}; + +/* * Helper function for creating a new physical replication slot with * given arguments. Note that this function doesn't release the created * slot. @@ -235,7 +246,7 @@ pg_drop_replication_slot(PG_FUNCTION_ARGS) Datum pg_get_replication_slots(PG_FUNCTION_ARGS) { -#define PG_GET_REPLICATION_SLOTS_COLS 20 +#define PG_GET_REPLICATION_SLOTS_COLS 21 ReturnSetInfo *rsinfo = (ReturnSetInfo *) fcinfo->resultinfo; XLogRecPtr currlsn; int slotno; @@ -443,6 +454,11 @@ pg_get_replication_slots(PG_FUNCTION_ARGS) values[i++] = BoolGetDatum(slot_contents.data.synced); + if (slot_contents.slotsync_skip_reason == SS_SKIP_NONE) + nulls[i++] = true; + else + values[i++] = CStringGetTextDatum(SlotSyncSkipReasonNames[slot_contents.slotsync_skip_reason]); + Assert(i == PG_GET_REPLICATION_SLOTS_COLS); tuplestore_putvalues(rsinfo->setResult, rsinfo->setDesc, |
