From be87200efd9308ccfe217ce8828f316e93e370da Mon Sep 17 00:00:00 2001 From: Andres Freund Date: Fri, 7 Apr 2023 22:40:27 -0700 Subject: Support invalidating replication slots due to horizon and wal_level MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Needed for logical decoding on a standby. Slots need to be invalidated because of the horizon if rows required for logical decoding are removed. If the primary's wal_level is lowered from 'logical', logical slots on the standby need to be invalidated. The new invalidation methods will be used in a subsequent commit. Logical slots that have been invalidated can be identified via the new pg_replication_slots.conflicting column. See 6af1793954e for an overall design of logical decoding on a standby. Bumps catversion for the addition of the new pg_replication_slots column. Author: "Drouvot, Bertrand" Author: Andres Freund Author: Amit Khandekar (in an older version) Reviewed-by: "Drouvot, Bertrand" Reviewed-by: Andres Freund Reviewed-by: Robert Haas Reviewed-by: Fabrízio de Royes Mello Reviewed-by: Bharath Rupireddy Reviewed-by: Amit Kapila Reviewed-by: Melanie Plageman Reviewed-by: Alvaro Herrera Discussion: https://postgr.es/m/20230407075009.igg7be27ha2htkbt@awork3.anarazel.de --- src/backend/access/transam/xlog.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'src/backend/access/transam/xlog.c') diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 18e16ae5b3e..23903445293 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -6809,7 +6809,9 @@ CreateCheckPoint(int flags) */ XLByteToSeg(RedoRecPtr, _logSegNo, wal_segment_size); KeepLogSeg(recptr, &_logSegNo); - if (InvalidateObsoleteReplicationSlots(_logSegNo)) + if (InvalidateObsoleteReplicationSlots(RS_INVAL_WAL_REMOVED, + _logSegNo, InvalidOid, + InvalidTransactionId)) { /* * Some slots have been invalidated; recalculate the old-segment @@ -7253,7 +7255,9 @@ CreateRestartPoint(int flags) replayPtr = GetXLogReplayRecPtr(&replayTLI); endptr = (receivePtr < replayPtr) ? replayPtr : receivePtr; KeepLogSeg(endptr, &_logSegNo); - if (InvalidateObsoleteReplicationSlots(_logSegNo)) + if (InvalidateObsoleteReplicationSlots(RS_INVAL_WAL_REMOVED, + _logSegNo, InvalidOid, + InvalidTransactionId)) { /* * Some slots have been invalidated; recalculate the old-segment -- cgit v1.2.3