def METHOD_NAME(self, cleanup_batch_size, sync=False):
    """Remove deleted metrics.
    :param cleanup_batch_size: The amount of metrics to delete in one
                               run.
    :param sync: If True, then delete everything synchronously and raise
                 on error
    :type sync: bool
    """
    metrics_to_expunge = self.index.list_metrics(status='delete',
                                                 limit=cleanup_batch_size)
    metrics_by_id = {m.id: m for m in metrics_to_expunge}
    for sack, metric_ids in self.incoming.group_metrics_by_sack(
            metrics_by_id.keys()):
        try:
            lock = self.get_sack_lock(sack)
            if not lock.acquire(blocking=sync):
                # Retry later
                LOG.debug(
                    "Sack %s is locked, cannot expunge metrics", sack)
                continue
            # NOTE(gordc): no need to hold lock because the metric has been
            # already marked as "deleted" in the indexer so no measure
            # worker is going to process it anymore.
            lock.release()
        except Exception:
            if sync:
                raise
            LOG.error("Unable to lock sack %s for expunging metrics",
                      sack, exc_info=True)
        else:
            for metric_id in metric_ids:
                metric = metrics_by_id[metric_id]
                LOG.debug("Deleting metric %s", metric)
                try:
                    self.incoming.delete_unprocessed_measures_for_metric(
                        metric.id)
                    self.storage._delete_metric(metric)
                    try:
                        self.index.expunge_metric(metric.id)
                    except indexer.NoSuchMetric:
                        # It's possible another process deleted or is
                        # deleting the metric, not a big deal
                        pass
                except Exception:
                    if sync:
                        raise
                    LOG.error("Unable to expunge metric %s from storage",
                              metric, exc_info=True)