def process_sync_replication_prepromote(self) -> bool:
        """Handle sync replication state before promote.

        If quorum replication is requested, and we can keep syncing to enough nodes satisfying the quorum invariant
        we can promote immediately and let normal quorum resolver process handle any membership changes later.
        Otherwise, we will just reset DCS state to ourselves and add replicas as they connect.

        :returns: ``True`` if on success or ``False`` if failed to update /sync key in DCS.
        """
        if not self.is_synchronous_mode():
            self.disable_synchronous_replication()
            return True

        if self.quorum_commit_mode_is_active():
            sync = CaseInsensitiveSet(self.cluster.sync.members)
            numsync = len(sync) - self.cluster.sync.quorum - 1
            if self.state_handler.name not in sync:  # Node outside voters achieved quorum and got leader
                numsync += 1
            else:
                sync.discard(self.state_handler.name)
        else:
            sync = CaseInsensitiveSet()
            numsync = global_config.min_synchronous_nodes

        if not self.is_quorum_commit_mode() or not self.state_handler.supports_multiple_sync and numsync > 1:
            sync = CaseInsensitiveSet()
            numsync = global_config.min_synchronous_nodes

            # Just set ourselves as the authoritative source of truth for now. We don't want to wait for standbys
            # to connect. We will try finding a synchronous standby in the next cycle.
            if not self.dcs.write_sync_state(self.state_handler.name, None, 0, version=self.cluster.sync.version):
                return False

        self.state_handler.sync_handler.set_synchronous_standby_names(sync, numsync)
        return True
Handle sync replication state before promote.

        If quorum replication is requested, and we can keep syncing to enough nodes satisfying the quorum invariant
        we can promote immediately and let normal quorum resolver process handle any membership changes later.
        Otherwise, we will just reset DCS state to ourselves and add replicas as they connect.

        :returns: ``True`` if on success or ``False`` if failed to update /sync key in DCS.
        
patroni/ha.py