summaryrefslogtreecommitdiff
path: root/src/include
diff options
context:
space:
mode:
authorAmit Kapila <akapila@postgresql.org>2025-11-28 05:21:35 +0000
committerAmit Kapila <akapila@postgresql.org>2025-11-28 05:21:35 +0000
commite68b6adad96d414fdf24e072fdb1d41fb4b8f0b7 (patch)
tree36cbdc3befc3b490893d4daa2184aa664ca46adb /src/include
parent9ccc049dfe655ca9927f7c62559ec32f4d1f94dd (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/include')
-rw-r--r--src/include/catalog/catversion.h2
-rw-r--r--src/include/catalog/pg_proc.dat6
-rw-r--r--src/include/replication/slot.h30
3 files changed, 34 insertions, 4 deletions
diff --git a/src/include/catalog/catversion.h b/src/include/catalog/catversion.h
index ee642e5510d..70320aa0cfb 100644
--- a/src/include/catalog/catversion.h
+++ b/src/include/catalog/catversion.h
@@ -57,6 +57,6 @@
*/
/* yyyymmddN */
-#define CATALOG_VERSION_NO 202511251
+#define CATALOG_VERSION_NO 202511281
#endif
diff --git a/src/include/catalog/pg_proc.dat b/src/include/catalog/pg_proc.dat
index 66431940700..66af2d96d67 100644
--- a/src/include/catalog/pg_proc.dat
+++ b/src/include/catalog/pg_proc.dat
@@ -11519,9 +11519,9 @@
proname => 'pg_get_replication_slots', prorows => '10', proisstrict => 'f',
proretset => 't', provolatile => 's', prorettype => 'record',
proargtypes => '',
- proallargtypes => '{name,name,text,oid,bool,bool,int4,xid,xid,pg_lsn,pg_lsn,text,int8,bool,pg_lsn,timestamptz,bool,text,bool,bool}',
- proargmodes => '{o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o}',
- proargnames => '{slot_name,plugin,slot_type,datoid,temporary,active,active_pid,xmin,catalog_xmin,restart_lsn,confirmed_flush_lsn,wal_status,safe_wal_size,two_phase,two_phase_at,inactive_since,conflicting,invalidation_reason,failover,synced}',
+ proallargtypes => '{name,name,text,oid,bool,bool,int4,xid,xid,pg_lsn,pg_lsn,text,int8,bool,pg_lsn,timestamptz,bool,text,bool,bool,text}',
+ proargmodes => '{o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o,o}',
+ proargnames => '{slot_name,plugin,slot_type,datoid,temporary,active,active_pid,xmin,catalog_xmin,restart_lsn,confirmed_flush_lsn,wal_status,safe_wal_size,two_phase,two_phase_at,inactive_since,conflicting,invalidation_reason,failover,synced,slotsync_skip_reason}',
prosrc => 'pg_get_replication_slots' },
{ oid => '3786', descr => 'set up a logical replication slot',
proname => 'pg_create_logical_replication_slot', provolatile => 'v',
diff --git a/src/include/replication/slot.h b/src/include/replication/slot.h
index 09c69f83d57..28251d86638 100644
--- a/src/include/replication/slot.h
+++ b/src/include/replication/slot.h
@@ -72,6 +72,24 @@ typedef enum ReplicationSlotInvalidationCause
#define RS_INVAL_MAX_CAUSES 4
/*
+ * When the slot synchronization worker is running, or when
+ * pg_sync_replication_slots is executed, slot synchronization may be
+ * skipped. This enum defines the possible reasons for skipping slot
+ * synchronization.
+ */
+typedef enum SlotSyncSkipReason
+{
+ SS_SKIP_NONE, /* No skip */
+ SS_SKIP_WAL_NOT_FLUSHED, /* Standby did not flush the wal corresponding
+ * to confirmed flush of remote slot */
+ SS_SKIP_WAL_OR_ROWS_REMOVED, /* Remote slot is behind; required WAL or
+ * rows may be removed or at risk */
+ SS_SKIP_NO_CONSISTENT_SNAPSHOT, /* Standby could not build a consistent
+ * snapshot */
+ SS_SKIP_INVALID /* Local slot is invalid */
+} SlotSyncSkipReason;
+
+/*
* On-Disk data of a replication slot, preserved across restarts.
*/
typedef struct ReplicationSlotPersistentData
@@ -249,6 +267,18 @@ typedef struct ReplicationSlot
*/
XLogRecPtr last_saved_restart_lsn;
+ /*
+ * Reason for the most recent slot synchronization skip.
+ *
+ * Slot sync skips can occur for both temporary and persistent replication
+ * slots. They are more common for temporary slots, but persistent slots
+ * may also skip synchronization in rare cases (e.g.,
+ * SS_SKIP_WAL_NOT_FLUSHED or SS_SKIP_WAL_OR_ROWS_REMOVED).
+ *
+ * Since, temporary slots are dropped after server restart, persisting
+ * slotsync_skip_reason provides no practical benefit.
+ */
+ SlotSyncSkipReason slotsync_skip_reason;
} ReplicationSlot;
#define SlotIsPhysical(slot) ((slot)->data.database == InvalidOid)