@read_session
def list_bad_replicas(limit=10000, thread=None, total_threads=None, session=None):
    "\n    List RSE File replicas with no locks.\n\n    :param limit: The maximum number of replicas returned.\n    :param thread: The assigned thread for this necromancer.\n    :param total_threads: The total number of threads of all necromancers.\n    :param session: The database session in use.\n\n    :returns: a list of dictionary {'scope' scope, 'name': name, 'rse_id': rse_id, 'rse': rse}.\n    "
    schema_dot = (('%s.' % DEFAULT_SCHEMA_NAME) if DEFAULT_SCHEMA_NAME else '')
    if (session.bind.dialect.name == 'oracle'):
        query = session.query(models.RSEFileAssociation.scope, models.RSEFileAssociation.name, models.RSEFileAssociation.rse_id).with_hint(models.RSEFileAssociation, '+ index(replicas REPLICAS_STATE_IDX)', 'oracle').filter(text(("CASE WHEN (%sreplicas.state != 'A') THEN %sreplicas.rse_id END IS NOT NULL" % (schema_dot, schema_dot)))).filter((models.RSEFileAssociation.state == ReplicaState.BAD))
    else:
        query = session.query(models.RSEFileAssociation.scope, models.RSEFileAssociation.name, models.RSEFileAssociation.rse_id).filter((models.RSEFileAssociation.state == ReplicaState.BAD))
    query = filter_thread_work(session=session, query=query, total_threads=total_threads, thread_id=thread, hash_variable=('%sreplicas.name' % schema_dot))
    query = query.join(models.DataIdentifier, and_((models.DataIdentifier.scope == models.RSEFileAssociation.scope), (models.DataIdentifier.name == models.RSEFileAssociation.name))).filter((models.DataIdentifier.availability != DIDAvailability.LOST))
    query = query.limit(limit)
    rows = []
    for (scope, name, rse_id) in query.yield_per(1000):
        rows.append({'scope': scope, 'name': name, 'rse_id': rse_id, 'rse': get_rse_name(rse_id=rse_id, session=session)})
    return rows
List RSE File replicas with no locks.

:param limit: The maximum number of replicas returned.
:param thread: The assigned thread for this necromancer.
:param total_threads: The total number of threads of all necromancers.
:param session: The database session in use.

:returns: a list of dictionary {'scope' scope, 'name': name, 'rse_id': rse_id, 'rse': rse}.
@read_session
def list_bad_replicas(limit=10000, thread=None, total_threads=None, session=None):
    "\n    List RSE File replicas with no locks.\n\n    :param limit: The maximum number of replicas returned.\n    :param thread: The assigned thread for this necromancer.\n    :param total_threads: The total number of threads of all necromancers.\n    :param session: The database session in use.\n\n    :returns: a list of dictionary {'scope' scope, 'name': name, 'rse_id': rse_id, 'rse': rse}.\n    "
    schema_dot = (('%s.' % DEFAULT_SCHEMA_NAME) if DEFAULT_SCHEMA_NAME else )
    if (session.bind.dialect.name == 'oracle'):
        query = session.query(models.RSEFileAssociation.scope, models.RSEFileAssociation.name, models.RSEFileAssociation.rse_id).with_hint(models.RSEFileAssociation, '+ index(replicas REPLICAS_STATE_IDX)', 'oracle').filter(text(("CASE WHEN (%sreplicas.state != 'A') THEN %sreplicas.rse_id END IS NOT NULL" % (schema_dot, schema_dot)))).filter((models.RSEFileAssociation.state == ReplicaState.BAD))
    else:
        query = session.query(models.RSEFileAssociation.scope, models.RSEFileAssociation.name, models.RSEFileAssociation.rse_id).filter((models.RSEFileAssociation.state == ReplicaState.BAD))
    query = filter_thread_work(session=session, query=query, total_threads=total_threads, thread_id=thread, hash_variable=('%sreplicas.name' % schema_dot))
    query = query.join(models.DataIdentifier, and_((models.DataIdentifier.scope == models.RSEFileAssociation.scope), (models.DataIdentifier.name == models.RSEFileAssociation.name))).filter((models.DataIdentifier.availability != DIDAvailability.LOST))
    query = query.limit(limit)
    rows = []
    for (scope, name, rse_id) in query.yield_per(1000):
        rows.append({'scope': scope, 'name': name, 'rse_id': rse_id, 'rse': get_rse_name(rse_id=rse_id, session=session)})
    return rows