diff --git a/src/backend/replication/logical/logical.c b/src/backend/replication/logical/logical.c index b969caae72e..3541fc793e4 100644 --- a/src/backend/replication/logical/logical.c +++ b/src/backend/replication/logical/logical.c @@ -1910,8 +1910,14 @@ LogicalConfirmReceivedLocation(XLogRecPtr lsn) SpinLockRelease(&MyReplicationSlot->mutex); ReplicationSlotsComputeRequiredXmin(false); - ReplicationSlotsComputeRequiredLSN(); } + + /* + * Now that the new restart_lsn is safely on disk, recompute the + * global WAL retention requirement. + */ + if (updated_restart) + ReplicationSlotsComputeRequiredLSN(); } else {