def sync_replication_slots(self, cluster: Cluster, tags: Tags) -> List[str]:
        """During the HA loop read, check and alter replication slots found in the cluster.

        Read physical and logical slots from ``pg_replication_slots``, then compare to those configured in the DCS.
        Drop any slots that do not match those required by configuration and are not configured as permanent.
        Create any missing physical slots, or advance their position according to feedback stored in DCS.
        If we are the primary then create logical slots, otherwise if logical slots are known and active create
        them on replica nodes by copying slot files from the primary.

        :param cluster: object containing stateful information for the cluster.
        :param tags: reference to an object implementing :class:`Tags` interface.

        :returns: list of logical replication slots names that should be copied from the primary.
        """
        ret = []
        if self._postgresql.major_version >= 90400 and cluster.config:
            try:
                self.load_replication_slots()

                slots = cluster.get_replication_slots(self._postgresql, tags, show_error=True)

                self._drop_incorrect_slots(cluster, slots)

                # We don't want to clean physical replication slots with xmin feedback if:
                # - cluster has no leader
                # - current node is a leader, but still running as a standby
                clean_inactive_physical_slots = not cluster.is_unlocked() and \
                    (cluster.leader and cluster.leader.name != self._postgresql.name or self._postgresql.is_primary())
                self._ensure_physical_slots(slots, clean_inactive_physical_slots)

                if self._postgresql.is_primary():
                    self._logical_slots_processing_queue.clear()
                    self._ensure_logical_slots_primary(slots)
                else:
                    self.check_logical_slots_readiness(cluster, tags)
                    ret = self._ensure_logical_slots_replica(slots)

                self._replication_slots = slots
            except Exception:
                logger.exception('Exception when changing replication slots')
                self._schedule_load_slots = True
        return ret
During the HA loop read, check and alter replication slots found in the cluster.

        Read physical and logical slots from ``pg_replication_slots``, then compare to those configured in the DCS.
        Drop any slots that do not match those required by configuration and are not configured as permanent.
        Create any missing physical slots, or advance their position according to feedback stored in DCS.
        If we are the primary then create logical slots, otherwise if logical slots are known and active create
        them on replica nodes by copying slot files from the primary.

        :param cluster: object containing stateful information for the cluster.
        :param tags: reference to an object implementing :class:`Tags` interface.

        :returns: list of logical replication slots names that should be copied from the primary.
        
patroni/postgresql/slots.py