kuroda.diffs
application/octet-stream
Filename: kuroda.diffs
Type: application/octet-stream
Part: 0
diff --git a/src/backend/replication/logical/slotsync.c b/src/backend/replication/logical/slotsync.c
index 4359120165e..94063f67369 100644
--- a/src/backend/replication/logical/slotsync.c
+++ b/src/backend/replication/logical/slotsync.c
@@ -282,6 +282,9 @@ update_local_synced_slot(RemoteSlot *remote_slot, Oid remote_dbid,
slot->data.catalog_xmin = remote_slot->catalog_xmin;
SpinLockRelease(&slot->mutex);
+ /* Synchronization happened, update the slot sync skip reason */
+ update_slot_sync_skip_stats(slot, SS_SKIP_NONE);
+
if (found_consistent_snapshot)
*found_consistent_snapshot = true;
}
@@ -290,6 +293,14 @@ update_local_synced_slot(RemoteSlot *remote_slot, Oid remote_dbid,
LogicalSlotAdvanceAndCheckSnapState(remote_slot->confirmed_lsn,
found_consistent_snapshot);
+ /* Update the slot sync skip reason if snapshot could be created */
+ if (SnapBuildSnapshotExists(remote_slot->restart_lsn))
+ {
+ Assert(!found_consistent_snapshot ||
+ *found_consistent_snapshot);
+ update_slot_sync_skip_stats(slot, SS_SKIP_NONE);
+ }
+
/* Sanity check */
if (slot->data.confirmed_flush != remote_slot->confirmed_lsn)
ereport(ERROR,
@@ -358,15 +369,6 @@ update_local_synced_slot(RemoteSlot *remote_slot, Oid remote_dbid,
ReplicationSlotsComputeRequiredLSN();
}
- /*
- * If found_consistent_snapshot is not NULL and a consistent snapshot is
- * found set the slot sync skip reason to none. Else, if consistent
- * snapshot is not found the stats will be updated in the function
- * update_and_persist_local_synced_slot
- */
- if (!found_consistent_snapshot || *found_consistent_snapshot)
- update_slot_sync_skip_stats(slot, SS_SKIP_NONE);
-
return updated_config || updated_xmin_or_lsn;
}