internlm/SWE-Fixer-Train-110K huggingface dataset:
Repository: rucio/rucio

Issue:
Add NO_INDEX_FFS(CONTENTS CONTENTS_PK) hint to reaper queries
A `NO_INDEX_FFS(CONTENTS CONTENTS_PK)` hint needs to be added to some reaper queries. Possibly some of the queries need to be transformed to the new sqlalchemy syntax, in order to be able to use `prefix_with` commands.

https://github.com/rucio/rucio/blob/86b27bcb485f92759eae25b93b9efb9f7e4103c0/lib/rucio/core/replica.py#L1741


Discussion:

Resolving patch:
diff --git a/lib/rucio/core/replica.py b/lib/rucio/core/replica.py
--- a/lib/rucio/core/replica.py
+++ b/lib/rucio/core/replica.py
@@ -1738,11 +1738,19 @@ def __cleanup_after_replica_deletion(rse_id, files, session=None):
         child_did_condition, tmp_parent_condition = [], []
         for chunk in chunks(parent_condition, 10):
 
-            query = session.query(models.DataIdentifierAssociation.scope, models.DataIdentifierAssociation.name,
-                                  models.DataIdentifierAssociation.did_type,
-                                  models.DataIdentifierAssociation.child_scope, models.DataIdentifierAssociation.child_name).\
-                filter(or_(*chunk))
-            for parent_scope, parent_name, did_type, child_scope, child_name in query:
+            stmt = select(
+                models.DataIdentifierAssociation.scope,
+                models.DataIdentifierAssociation.name,
+                models.DataIdentifierAssociation.did_type,
+                models.DataIdentifierAssociation.child_scope,
+                models.DataIdentifierAssociation.child_name,
+            ).prefix_with(
+                "/*+ NO_INDEX_FFS(CONTENTS CONTENTS_PK) */",
+                dialect='oracle',
+            ).where(
+                or_(*chunk)
+            )
+            for parent_scope, parent_name, did_type, child_scope, child_name in session.execute(stmt):
 
                 # Schedule removal of child file/dataset/container from the parent dataset/container
                 child_did_condition.append(


Test patch:
Repository: rucio/rucio

Issue:
`bring_online` parameter is submitted as a string, instead of int, to FTS
Motivation
----------
https://github.com/rucio/rucio/blob/e2ed93b6d315091cf4960f76b4253ce8fad27a6c/lib/rucio/daemons/conveyor/submitter.py#L107
Loads the value as a string. Later on in the workflow this is submitted to FTS as a string in the dictionary, which the new FTS3 REST interface on fts3-pilot does not like.

Modification
------------
This should be cast to int, or better loaded with `config_get_int`. Also applies to the stager.



Discussion:

Resolving patch:
diff --git a/lib/rucio/daemons/conveyor/stager.py b/lib/rucio/daemons/conveyor/stager.py
--- a/lib/rucio/daemons/conveyor/stager.py
+++ b/lib/rucio/daemons/conveyor/stager.py
@@ -40,7 +40,7 @@
 
 import rucio.db.sqla.util
 from rucio.common import exception
-from rucio.common.config import config_get, config_get_bool
+from rucio.common.config import config_get, config_get_bool, config_get_int
 from rucio.common.logging import setup_logging
 from rucio.core.monitor import record_counter, record_timer
 from rucio.core import transfer as transfer_core
@@ -68,7 +68,7 @@ def stager(once=False, rses=None, bulk=100, group_bulk=1, group_policy='rule',
         failover_scheme = None
 
     try:
-        bring_online = config_get('conveyor', 'bring_online')
+        bring_online = config_get_int('conveyor', 'bring_online')
     except NoOptionError:
         bring_online = 43200
 
diff --git a/lib/rucio/daemons/conveyor/submitter.py b/lib/rucio/daemons/conveyor/submitter.py
--- a/lib/rucio/daemons/conveyor/submitter.py
+++ b/lib/rucio/daemons/conveyor/submitter.py
@@ -48,7 +48,7 @@
 
 import rucio.db.sqla.util
 from rucio.common import exception
-from rucio.common.config import config_get, config_get_bool
+from rucio.common.config import config_get, config_get_bool, config_get_int
 from rucio.common.logging import setup_logging
 from rucio.common.schema import get_schema_value
 from rucio.common.utils import PriorityQueue
@@ -104,7 +104,7 @@ def submitter(once=False, rses=None, partition_wait_time=10,
         timeout = None
 
     try:
-        bring_online = config_get('conveyor', 'bring_online')
+        bring_online = config_get_int('conveyor', 'bring_online')
     except NoOptionError:
         bring_online = 43200
 


Test patch:
Repository: rucio/rucio

Issue:
Download Schema validation errors
Motivation
----------
Incoming traces such as:
```
{
"eventVersion": "api_1.25.5", 
"protocol": "root", 
"datasetScope": "user.****", 
"eventType": 
"download", 
"dataset": "user.****", 
"account": "****", 
"uuid": "****", 
"hostname": "****", 
"remoteSite": "TAIWAN-LCG2_SCRATCHDISK", 
"filename": "****", 
"filesize": ****, 
"localSite": "CERN-PROD", 
"stateReason": "The requested service is not available at the moment.\\nDetails: An unknown exception occurred.\\nDetails: Error on XrdCl::CopyProcess::Run(): [ERROR] Server responded with an error: [3010] permission denied", 
"scope": "user.****", 
"clientState": "ServiceUnavailable", 
"traceTimeentry": "2022-01-19T09:22:56.700310", "traceTimeentryUnix": 1642584176.70031, "traceIp": "2001:1458:301:23::100:42", "traceId": "****"}
```
Raise the following errors:
```
Details: 'ServiceUnavailable' is not one of ['DONE', 'FAILED', 'PROCESSING', 'ALREADY_DONE', 'FILE_NOT_FOUND', 'FOUND_IN_PCACHE', 'DOWNLOAD_ATTEMPT', 'FAIL_VALIDATE', 'FOUND_ROOT' 

{'description': 'Client state',
  'enum': ['DONE',
           'FAILED',
           'PROCESSING',
           'ALREADY_DONE',
           'FILE_NOT_FOUND',
           'FOUND_IN_PCACHE',
           'DOWNLOAD_ATTEMPT',
           'FAIL_VALIDATE',
           'FOUND_ROOT'],
  'type': 'string'}

On instance['clientState']:
 'ServiceUnavailable'
```

Modification
------------

Add `ServiceUnavailable` as one of the possible `clientState` values.




Discussion:

Resolving patch:
diff --git a/lib/rucio/common/schema/generic.py b/lib/rucio/common/schema/generic.py
--- a/lib/rucio/common/schema/generic.py
+++ b/lib/rucio/common/schema/generic.py
@@ -197,7 +197,7 @@
     "description": "Client state",
     "type": "string",
     "enum": ['DONE', 'FAILED', 'PROCESSING', 'ALREADY_DONE', 'FILE_NOT_FOUND', 'FOUND_IN_PCACHE', 'DOWNLOAD_ATTEMPT',
-             'FAIL_VALIDATE', 'FOUND_ROOT']
+             'FAIL_VALIDATE', 'FOUND_ROOT', 'ServiceUnavailable']
 }
 
 RULE = {"description": "Replication rule",


Test patch:
Repository: rucio/rucio

Issue:
make geoip database expiration delay configurable
Motivation
----------
May be practical if keeping the geoip database always up to date is not desire/not possible.




Discussion:

Resolving patch:
diff --git a/lib/rucio/core/replica_sorter.py b/lib/rucio/core/replica_sorter.py
--- a/lib/rucio/core/replica_sorter.py
+++ b/lib/rucio/core/replica_sorter.py
@@ -40,7 +40,7 @@
 
 from rucio.common import utils
 from rucio.common.cache import make_region_memcached
-from rucio.common.config import config_get, config_get_bool
+from rucio.common.config import config_get, config_get_bool, config_get_int
 from rucio.common.exception import InvalidRSEExpression
 from rucio.core.rse_expression_parser import parse_expression
 
@@ -94,13 +94,13 @@ def __download_geoip_db(destination):
 
 def __geoip_db():
     db_path = Path(f'/tmp/{GEOIP_DB_EDITION}.mmdb')
-    db_expire_delay = timedelta(days=30)
+    db_expire_delay = timedelta(days=config_get_int('core', 'geoip_expire_delay', raise_exception=False, default=30))
 
     must_download = False
     if not db_path.is_file():
         print('%s does not exist. Downloading it.' % db_path)
         must_download = True
-    elif datetime.fromtimestamp(db_path.stat().st_mtime) < datetime.now() - db_expire_delay:
+    elif db_expire_delay and datetime.fromtimestamp(db_path.stat().st_mtime) < datetime.now() - db_expire_delay:
         print('%s is too old. Re-downloading it.' % db_path)
         must_download = True
 


Test patch:
Repository: rucio/rucio

Issue:
exception in submitter on intermediate hop creation
Motivation
----------
```
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/rucio/daemons/conveyor/submitter.py", line 199, in submitter
    logger=logger,
  File "/usr/local/lib/python3.6/site-packages/rucio/db/sqla/session.py", line 374, in new_funct
    result = function(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/rucio/core/transfer.py", line 1259, in next_transfers_to_submit
    session=session,
  File "/usr/local/lib/python3.6/site-packages/rucio/core/transfer.py", line 1504, in __assign_paths_to_transfertool_and_create_hops
    transfer_path, default_tombstone_delay, logger=logger, session=session
  File "/usr/local/lib/python3.6/site-packages/rucio/db/sqla/session.py", line 388, in new_funct
    result = function(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/rucio/core/transfer.py", line 1601, in create_missing_replicas_and_requests
    if datetime.datetime.utcnow() - CONCURRENT_SUBMISSION_TOLERATION_DELAY < existing_request['requested_at']:
TypeError: '<' not supported between instances of 'datetime.datetime' and 'NoneType'
```




Discussion:

Resolving patch:
diff --git a/lib/rucio/core/transfer.py b/lib/rucio/core/transfer.py
--- a/lib/rucio/core/transfer.py
+++ b/lib/rucio/core/transfer.py
@@ -1598,7 +1598,8 @@ def create_missing_replicas_and_requests(
             creation_successful = False
 
             existing_request = get_request_by_did(rws.scope, rws.name, rws.dest_rse.id, session=session)
-            if datetime.datetime.utcnow() - CONCURRENT_SUBMISSION_TOLERATION_DELAY < existing_request['requested_at']:
+            if existing_request['requested_at'] and \
+                    datetime.datetime.utcnow() - CONCURRENT_SUBMISSION_TOLERATION_DELAY < existing_request['requested_at']:
                 concurrent_submission_detected = True
 
             break


Test patch:
Repository: rucio/rucio

Issue:
Bug in the filter_thread_work algorithm for Postgres backend
Motivation
----------
The partitioning algorithm sometimes fails with `Details: (psycopg2.errors.NumericValueOutOfRange) integer out of range` for Postgres backend, e.g. : 
```
rucio=> select abs(('x'||md5(requests.id::text))::bit(64)::int) from requests limit 1;
ERROR:  integer out of range
rucio=> select abs(('x'||md5(requests.id::text))::bit(64)::bigint) from requests limit 1;
         abs         
---------------------
 9096650785057471382
(1 row)
```






Discussion:

Resolving patch:
diff --git a/lib/rucio/db/sqla/__init__.py b/lib/rucio/db/sqla/__init__.py
--- a/lib/rucio/db/sqla/__init__.py
+++ b/lib/rucio/db/sqla/__init__.py
@@ -1,8 +1,24 @@
-# Copyright European Organization for Nuclear Research (CERN)
+# -*- coding: utf-8 -*-
+# Copyright 2013-2022 CERN
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
-# You may not use this file except in compliance with the License.
-# You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#    http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+# Authors:
+# - Vincent Garonne <vincent.garonne@cern.ch>, 2013-2015
+# - Brandon White <bjwhite@fnal.gov>, 2019
+# - Martin Barisits <martin.barisits@cern.ch>, 2020
+# - Radu Carpa <radu.carpa@cern.ch>, 2021
+# - Cedric Serfon <cedric.serfon@cern.ch>, 2022
 
 from sqlalchemy.sql.expression import bindparam, text
 
@@ -23,7 +39,7 @@ def filter_thread_work(session, query, total_threads, thread_id, hash_variable=N
                 query = query.filter(text('mod(md5(%s), %s) = %s' % (hash_variable, total_threads, thread_id)))
         elif session.bind.dialect.name == 'postgresql':
             if not hash_variable:
-                query = query.filter(text('mod(abs((\'x\'||md5(id::text))::bit(32)::int), %s) = %s' % (total_threads, thread_id)))
+                query = query.filter(text('mod(abs((\'x\'||md5(id::text))::bit(32)::bigint), %s) = %s' % (total_threads, thread_id)))
             else:
-                query = query.filter(text('mod(abs((\'x\'||md5(%s::text))::bit(32)::int), %s) = %s' % (hash_variable, total_threads, thread_id)))
+                query = query.filter(text('mod(abs((\'x\'||md5(%s::text))::bit(32)::bigint), %s) = %s' % (hash_variable, total_threads, thread_id)))
     return query


Test patch:
Repository: rucio/rucio

Issue:
Add query hint to list_dids query
Motivation
----------
The query generated at https://github.com/rucio/rucio/blob/84819ff3ee623c43f6419c484172f66b88a02c5c/lib/rucio/core/did.py#L1562 creates a slow query plan. 

Modification
------------
Add `/*+ NO_EXPAND */` query hint to it. 


Discussion:

Resolving patch:
diff --git a/lib/rucio/core/did.py b/lib/rucio/core/did.py
--- a/lib/rucio/core/did.py
+++ b/lib/rucio/core/did.py
@@ -15,7 +15,7 @@
 #
 # Authors:
 # - Vincent Garonne <vincent.garonne@cern.ch>, 2013-2018
-# - Martin Barisits <martin.barisits@cern.ch>, 2013-2021
+# - Martin Barisits <martin.barisits@cern.ch>, 2013-2022
 # - Cedric Serfon <cedric.serfon@cern.ch>, 2013-2021
 # - Ralph Vigne <ralph.vigne@cern.ch>, 2013
 # - Mario Lassnig <mario.lassnig@cern.ch>, 2013-2020
@@ -1571,6 +1571,7 @@ def list_dids(scope, filters, did_type='collection', ignore_case=False, limit=No
             (models.DataIdentifier.suppressed, operator.ne, true()),
         ]
     )
+    query.with_hint(models.DataIdentifier, 'NO_EXPAND', 'oracle')
 
     if limit:
         query = query.limit(limit)


Test patch:
Repository: rucio/rucio

Issue:
Add query hints to three queries
Motivation
----------
With the 19c optimizer, three queries produce ineffecient query plans and need to be stabilized:

```
- 1amjw3stz5arm
- 3855f7t9cxjam 
- 14h8ggsxu9pm4 
```

Modification
------------

Add `USE_CONCAT` hint to these



Discussion:

Resolving patch:
diff --git a/lib/rucio/core/replica.py b/lib/rucio/core/replica.py
--- a/lib/rucio/core/replica.py
+++ b/lib/rucio/core/replica.py
@@ -17,7 +17,7 @@
 # - Vincent Garonne <vincent.garonne@cern.ch>, 2013-2018
 # - Cedric Serfon <cedric.serfon@cern.ch>, 2013-2021
 # - Ralph Vigne <ralph.vigne@cern.ch>, 2013-2014
-# - Martin Barisits <martin.barisits@cern.ch>, 2013-2021
+# - Martin Barisits <martin.barisits@cern.ch>, 2013-2022
 # - Mario Lassnig <mario.lassnig@cern.ch>, 2014-2021
 # - David Cameron <david.cameron@cern.ch>, 2014
 # - Thomas Beermann <thomas.beermann@cern.ch>, 2014-2021
@@ -40,7 +40,7 @@
 # - Gabriele Fronzé <sucre.91@hotmail.it>, 2021
 # - David Población Criado <david.poblacion.criado@cern.ch>, 2021
 # - Joel Dierkes <joel.dierkes@cern.ch>, 2021
-# - Christoph Ames <cames@cern.ch>, 2021
+# - Christoph Ames <christoph.ames@physik.uni-muenchen.de>, 2021
 
 from __future__ import print_function
 
@@ -1743,7 +1743,7 @@ def __cleanup_after_replica_deletion(rse_id, files, session=None):
                 models.DataIdentifierAssociation.child_scope,
                 models.DataIdentifierAssociation.child_name,
             ).prefix_with(
-                "/*+ NO_INDEX_FFS(CONTENTS CONTENTS_PK) */",
+                "/*+ USE_CONCAT NO_INDEX_FFS(CONTENTS CONTENTS_PK) */",
                 dialect='oracle',
             ).where(
                 or_(*chunk)


Test patch:
Repository: rucio/rucio

Issue:
allow use of memcached for the auth tokens
Motivation
----------

All other caches were moved from in-memory python dicts to memcached some time ago https://github.com/rucio/rucio/pull/5162 . The auth tokens were still kept in memory due to security concerns. Especially for people who may use a separate memcached instance and would be surprised that such information is now leacked. 

Modification
------------
Allow setting auth tokens in memcached, but this should be configurable and default to false. 




Discussion:

Resolving patch:
diff --git a/lib/rucio/core/authentication.py b/lib/rucio/core/authentication.py
--- a/lib/rucio/core/authentication.py
+++ b/lib/rucio/core/authentication.py
@@ -1,5 +1,5 @@
 # -*- coding: utf-8 -*-
-# Copyright 2012-2021 CERN
+# Copyright 2012-2022 CERN
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -27,7 +27,8 @@
 # - Benedikt Ziemons <benedikt.ziemons@cern.ch>, 2020-2021
 # - Rahul Chauhan <omrahulchauhan@gmail.com>, 2021
 # - David Población Criado <david.poblacion.criado@cern.ch>, 2021
-# - Joel Dierkes <joel.dierkes@cern.ch>, 2021
+# - jdierkes <joel.dierkes@cern.ch>, 2021
+# - Radu Carpa <radu.carpa@cern.ch>, 2022
 
 import datetime
 import hashlib
@@ -37,10 +38,12 @@
 from base64 import b64decode
 
 import paramiko
-from dogpile.cache import make_region
 from dogpile.cache.api import NO_VALUE
+from dogpile.cache import make_region
 from sqlalchemy import and_, or_, select, delete
 
+from rucio.common.cache import make_region_memcached
+from rucio.common.config import config_get_bool
 from rucio.common.exception import CannotAuthenticate, RucioException
 from rucio.common.utils import chunks, generate_uuid
 from rucio.core.account import account_exists
@@ -59,12 +62,10 @@ def generate_key(token, session=None):
     return generate_key
 
 
-TOKENREGION = make_region(
-    function_key_generator=token_key_generator
-).configure(
-    'dogpile.cache.memory',
-    expiration_time=3600
-)
+if config_get_bool('cache', 'use_external_cache_for_auth_tokens', default=False):
+    TOKENREGION = make_region_memcached(expiration_time=900, function_key_generator=token_key_generator)
+else:
+    TOKENREGION = make_region(function_key_generator=token_key_generator).configure('dogpile.cache.memory', expiration_time=900)
 
 
 @transactional_session


Test patch:
Repository: rucio/rucio

Issue:
Upload broken for cloud resources
Motivation
----------
There was a regression in the uploadclient in 1.27.6 that prevent upload to cloud resources





Discussion:

Resolving patch:
diff --git a/lib/rucio/client/uploadclient.py b/lib/rucio/client/uploadclient.py
--- a/lib/rucio/client/uploadclient.py
+++ b/lib/rucio/client/uploadclient.py
@@ -17,7 +17,7 @@
 # - Ralph Vigne <ralph.vigne@cern.ch>, 2012-2015
 # - Thomas Beermann <thomas.beermann@cern.ch>, 2012-2021
 # - Vincent Garonne <vincent.garonne@cern.ch>, 2012-2018
-# - Martin Barisits <martin.barisits@cern.ch>, 2017-2021
+# - Martin Barisits <martin.barisits@cern.ch>, 2017-2022
 # - Tobias Wegner <twegner@cern.ch>, 2018
 # - Joaquín Bogado <jbogado@linti.unlp.edu.ar>, 2018
 # - Nicolo Magini <nicolo.magini@cern.ch>, 2018
@@ -41,6 +41,7 @@
 # - David Población Criado <david.poblacion.criado@cern.ch>, 2021
 # - Joel Dierkes <joel.dierkes@cern.ch>, 2021
 # - Nicholas Smith <nick.smith@cern.ch>, 2021
+# - Cedric Serfon <cedric.serfon@cern.ch>, 2022
 
 import copy
 import json
@@ -594,7 +595,7 @@ def _upload_item(self, rse_settings, rse_attributes, lfn, source_dir=None, domai
         logger = self.logger
 
         # Construct protocol for write operation.
-        # IMPORTANT: All upload stat() checks are always done with the write_protocol
+        # IMPORTANT: All upload stat() checks are always done with the write_protocol EXCEPT for cloud resources (signed URL for write cannot be used for read)
         protocol_write = self._create_protocol(rse_settings, 'write', force_scheme=force_scheme, domain=domain, impl=impl)
 
         base_name = lfn.get('filename', lfn['name'])
@@ -625,8 +626,15 @@ def _upload_item(self, rse_settings, rse_attributes, lfn, source_dir=None, domai
         pfn_tmp = '%s.rucio.upload' % pfn if protocol_write.renaming else pfn
 
         # Either DID eixsts or not register_after_upload
-        if protocol_write.overwrite is False and delete_existing is False and protocol_write.exists(pfn):
-            raise FileReplicaAlreadyExists('File %s in scope %s already exists on storage as PFN %s' % (name, scope, pfn))  # wrong exception ?
+        if protocol_write.overwrite is False and delete_existing is False:
+            if sign_service:
+                # Construct protocol for read ONLY for cloud resources and get signed URL for GET
+                protocol_read = self._create_protocol(rse_settings, 'read', domain=domain, impl=impl)
+                readpfn = self.client.get_signed_url(rse_settings['rse'], sign_service, 'read', pfn)    # NOQA pylint: disable=undefined-variable
+                if protocol_read.exists(readpfn):
+                    raise FileReplicaAlreadyExists('File %s in scope %s already exists on storage as PFN %s' % (name, scope, pfn))  # wrong exception ?
+            if not sign_service and protocol_write.exists(pfn):
+                raise FileReplicaAlreadyExists('File %s in scope %s already exists on storage as PFN %s' % (name, scope, pfn))  # wrong exception ?
 
         # Removing tmp from earlier attempts
         if protocol_write.exists(pfn_tmp):


Test patch:
Repository: rucio/rucio

Issue:
geoip database is always downloaded, even if no URL configured/License key given
Motivation
----------
Currently, the replicas endpoint always tries to download the geoip database, even if no download URL is given, or no license key is given, which leads to the server always trying to download it from maxmindb and consequently failing, thus wasting time.

Modification
------------
If no URL or license key is set, this should just fallback to the exception and thus setting moon distances.
This needs to be backported to `1.26-LTS` as well.


Discussion:

Resolving patch:
diff --git a/lib/rucio/core/replica_sorter.py b/lib/rucio/core/replica_sorter.py
--- a/lib/rucio/core/replica_sorter.py
+++ b/lib/rucio/core/replica_sorter.py
@@ -75,7 +75,9 @@ def __download_geoip_db(destination):
     download_url = config_get('core', 'geoip_download_url', raise_exception=False, default=None)
     verify_tls = config_get_bool('core', 'geoip_download_verify_tls', raise_exception=False, default=True)
     if not download_url:
-        licence_key = config_get('core', 'geoip_licence_key', raise_exception=False, default='NOLICENCE')
+        licence_key = config_get('core', 'geoip_licence_key', raise_exception=False, default=None)
+        if not licence_key:
+            raise Exception('Cannot download GeoIP database: licence key not provided')
         download_url = 'https://download.maxmind.com/app/geoip_download?edition_id=%s&license_key=%s&suffix=tar.gz' % (edition_id, licence_key)
 
     result = requests.get(download_url, stream=True, verify=verify_tls)


Test patch:
Repository: rucio/rucio

Issue:
Enforce timeout on VP calls
Motivation
----------
Not all queries to the external VP service have a timeout enforced which can lead to several session issues.

Modification
------------
Include a timeout.




Discussion:

Resolving patch:
diff --git a/lib/rucio/core/replica.py b/lib/rucio/core/replica.py
--- a/lib/rucio/core/replica.py
+++ b/lib/rucio/core/replica.py
@@ -1028,7 +1028,7 @@ def get_multi_cache_prefix(cache_site, filename, logger=logging.log):
     x_caches = REGION.get('CacheSites')
     if x_caches is NO_VALUE:
         try:
-            response = requests.get('{}/serverRanges'.format(vp_endpoint), verify=False)
+            response = requests.get('{}/serverRanges'.format(vp_endpoint), timeout=1, verify=False)
             if response.ok:
                 x_caches = response.json()
                 REGION.set('CacheSites', x_caches)


Test patch: