def METHOD_NAME():
    """Delete indexed deposits that do not exist in the database.
    .. note:: This task exists because of deposit REST API calls sometimes
        failing after the deposit has already been sent for indexing to ES,
        leaving an inconsistent state of a deposit existing in ES and not in
        the database. It should be removed once a proper  signal mechanism has
        been implemented in the ``invenio-records-rest`` and
        ``invenio-deposit`` modules.
    """
    search = RecordsSearch(index='deposits')
    q = (search
         .query('term', **{'_deposit.status': 'draft'})
         .source(['_deposit.id']))
    res = q.scan()
    failed_depids, es_depids_info = [], []
    for d in res:
        try:
            es_depids_info.append((d.to_dict()['_deposit']['id'], d.meta.id,
                                   d.meta.index))
            es_depids = {p[0] for p in es_depids_info}
        except Exception:
            failed_depids.append(d.meta.id)
    db_depids_query = PersistentIdentifier.query.filter(
        PersistentIdentifier.pid_type == 'depid',
        PersistentIdentifier.pid_value.in_(es_depids))
    db_depids = {d.pid_value for d in db_depids_query}
    missing_db_depids = filter(lambda d: d[0] not in db_depids, es_depids_info)
    indexer = RecordIndexer()
    for _, deposit_id, index in missing_db_depids:
        indexer.client.delete(id=str(deposit_id), index=index)
    if failed_depids:
        current_app.logger.warning(
            'Missing depids from metadata',
            extra={'failed deposits': failed_depids}
        )