@transactional_session
def bulk_add_bad_replicas(replicas, account, state=BadFilesStatus.TEMPORARY_UNAVAILABLE, reason=None, expires_at=None, session=None):
    '\n    Bulk add new bad replicas.\n\n    :param replicas: the list of bad replicas.\n    :param account: The account who declared the bad replicas.\n    :param state: The state of the file (SUSPICIOUS, BAD or TEMPORARY_UNAVAILABLE).\n    :param session: The database session in use.\n\n    :returns: True is successful.\n    '
    for replica in replicas:
        insert_new_row = True
        if (state == BadFilesStatus.TEMPORARY_UNAVAILABLE):
            query = session.query(models.BadReplicas).filter_by(scope=replica['scope'], name=replica['name'], rse_id=replica['rse_id'], state=state)
            if query.count():
                query.update({'state': BadFilesStatus.TEMPORARY_UNAVAILABLE, 'updated_at': datetime.utcnow(), 'account': account, 'reason': reason, 'expires_at': expires_at}, synchronize_session=False)
                insert_new_row = False
        if insert_new_row:
            new_bad_replica = models.BadReplicas(scope=replica['scope'], name=replica['name'], rse_id=replica['rse_id'], reason=reason, state=state, account=account, bytes=None, expires_at=expires_at)
            new_bad_replica.save(session=session, flush=False)
    try:
        session.flush()
    except IntegrityError as error:
        raise exception.RucioException(error.args)
    except DatabaseError as error:
        raise exception.RucioException(error.args)
    except FlushError as error:
        if match('New instance .* with identity key .* conflicts with persistent instance', error.args[0]):
            raise exception.DataIdentifierAlreadyExists('Data Identifier already exists!')
        raise exception.RucioException(error.args)
    return True
Bulk add new bad replicas.

:param replicas: the list of bad replicas.
:param account: The account who declared the bad replicas.
:param state: The state of the file (SUSPICIOUS, BAD or TEMPORARY_UNAVAILABLE).
:param session: The database session in use.

:returns: True is successful.
@transactional_session
def bulk_add_bad_replicas(replicas, account, state=BadFilesStatus.TEMPORARY_UNAVAILABLE, reason=None, expires_at=None, session=None):
    '\n    Bulk add new bad replicas.\n\n    :param replicas: the list of bad replicas.\n    :param account: The account who declared the bad replicas.\n    :param state: The state of the file (SUSPICIOUS, BAD or TEMPORARY_UNAVAILABLE).\n    :param session: The database session in use.\n\n    :returns: True is successful.\n    '
    for replica in replicas:
        insert_new_row = True
        if (state == BadFilesStatus.TEMPORARY_UNAVAILABLE):
            query = session.query(models.BadReplicas).filter_by(scope=replica['scope'], name=replica['name'], rse_id=replica['rse_id'], state=state)
            if query.count():
                query.update({'state': BadFilesStatus.TEMPORARY_UNAVAILABLE, 'updated_at': datetime.utcnow(), 'account': account, 'reason': reason, 'expires_at': expires_at}, synchronize_session=False)
                insert_new_row = False
        if insert_new_row:
            new_bad_replica = models.BadReplicas(scope=replica['scope'], name=replica['name'], rse_id=replica['rse_id'], reason=reason, state=state, account=account, bytes=None, expires_at=expires_at)
            new_bad_replica.save(session=session, flush=False)
    try:
        session.flush()
    except IntegrityError as error:
        raise exception.RucioException(error.args)
    except DatabaseError as error:
        raise exception.RucioException(error.args)
    except FlushError as error:
        if match('New instance .* with identity key .* conflicts with persistent instance', error.args[0]):
            raise exception.DataIdentifierAlreadyExists('Data Identifier already exists!')
        raise exception.RucioException(error.args)
    return True