From 15f8203a5975d6b9b78e2c64e213ed964b50c044 Mon Sep 17 00:00:00 2001 From: Andres Freund Date: Fri, 7 Apr 2023 21:47:25 -0700 Subject: Replace replication slot's invalidated_at LSN with an enum This is mainly useful because the upcoming logical-decoding-on-standby feature adds further reasons for invalidating slots, and we don't want to end up with multiple invalidated_* fields, or check different attributes. Eventually we should consider not resetting restart_lsn when invalidating a slot due to max_slot_wal_keep_size. But that's a user visible change, so left for later. Increases SLOT_VERSION, due to the changed field (with a different alignment, no less). Reviewed-by: "Drouvot, Bertrand" Reviewed-by: Alvaro Herrera Reviewed-by: Melanie Plageman Discussion: https://postgr.es/m/20230407075009.igg7be27ha2htkbt@awork3.anarazel.de --- src/include/replication/slot.h | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/include/replication') diff --git a/src/include/replication/slot.h b/src/include/replication/slot.h index 8872c80cdfe..34ce055dd50 100644 --- a/src/include/replication/slot.h +++ b/src/include/replication/slot.h @@ -37,6 +37,17 @@ typedef enum ReplicationSlotPersistency RS_TEMPORARY } ReplicationSlotPersistency; +/* + * Slots can be invalidated, e.g. due to max_slot_wal_keep_size. If so, the + * 'invalidated' field is set to a value other than _NONE. + */ +typedef enum ReplicationSlotInvalidationCause +{ + RS_INVAL_NONE, + /* required WAL has been removed */ + RS_INVAL_WAL_REMOVED, +} ReplicationSlotInvalidationCause; + /* * On-Disk data of a replication slot, preserved across restarts. */ @@ -72,8 +83,8 @@ typedef struct ReplicationSlotPersistentData /* oldest LSN that might be required by this replication slot */ XLogRecPtr restart_lsn; - /* restart_lsn is copied here when the slot is invalidated */ - XLogRecPtr invalidated_at; + /* RS_INVAL_NONE if valid, or the reason for having been invalidated */ + ReplicationSlotInvalidationCause invalidated; /* * Oldest LSN that the client has acked receipt for. This is used as the -- cgit v1.2.3