Repository: rucio/rucio
Issue: config cache prevents updating a value before expiration

Motivation
----------
```python
config.set('throttler', 'release_strategy', 'fifo')
config.set('throttler', 'release_strategy', 'grouped_fifo')
```
will result in a database duplicate exception because `config.set()` checks if there is already a value which will be `False` if you try to set a new value under the expiration time because it got set to `False` with the first command.


Modification
------------
change the `has_option()` check in `config.set()` to `has_option(use_cache=False)`



Changed files:
lib/rucio/client/baseclient.py, lib/rucio/core/config.py, lib/rucio/client/downloadclient.py

diff --git a/lib/rucio/client/baseclient.py b/lib/rucio/client/baseclient.py
index d1f5ebdd2..3f88e2b0a 100644
--- a/lib/rucio/client/baseclient.py
+++ b/lib/rucio/client/baseclient.py
@@ -357,7 +357,7 @@ class BaseClient(object):
             raise exc_cls(exc_msg)
 
         self.auth_token = result.headers['x-rucio-auth-token']
-        LOG.debug('got new token \\'%s\\'' % self.auth_token)
+        LOG.debug('got new token')
         return True
 
     def __get_token_x509(self):
@@ -418,7 +418,7 @@ class BaseClient(object):
             raise exc_cls(exc_msg)
 
         self.auth_token = result.headers['x-rucio-auth-token']
-        LOG.debug('got new token \\'%s\\'' % self.auth_token)
+        LOG.debug('got new token')
         return True
 
     def __get_token_ssh(self):
@@ -497,7 +497,7 @@ class BaseClient(object):
             raise exc_cls(exc_msg)
 
         self.auth_token = result.headers['x-rucio-auth-token']
-        LOG.debug('got new token \\'%s\\'' % self.auth_token)
+        LOG.debug('got new token')
         return True
 
     def __get_token_gss(self):
@@ -535,7 +535,7 @@ class BaseClient(object):
             raise exc_cls(exc_msg)
 
         self.auth_token = result.headers['x-rucio-auth-token']
-        LOG.debug('got new token \\'%s\\'' % self.auth_token)
+        LOG.debug('got new token')
         return True
 
     def __get_token(self):
@@ -586,7 +586,7 @@ class BaseClient(object):
         except Exception:
             raise
 
-        LOG.debug('read token \\'%s\\' from file' % self.auth_token)
+        LOG.debug('got token from file')
         return True
 
     def __write_token(self):
diff --git a/lib/rucio/client/downloadclient.py b/lib/rucio/client/downloadclient.py
index 7be3ca247..d374d0a96 100644
--- a/lib/rucio/client/downloadclient.py
+++ b/lib/rucio/client/downloadclient.py
@@ -16,7 +16,7 @@
 # - Tomas Javurek <tomasjavurek09@gmail.com>, 2018
 # - Vincent Garonne <vgaronne@gmail.com>, 2018
 # - Joaquin Bogado <jbogado@linti.unlp.edu.ar>, 2018
-# - Nicolo Magini <nicolo.magini@cern.ch>, 2018
+# - Nicolo Magini <nicolo.magini@cern.ch>, 2018-2019
 # - Tobias Wegner <tobias.wegner@cern.ch>, 2018
 # - Hannes Hansen <hannes.jakob.hansen@cern.ch>, 2018-2019
 #
@@ -330,7 +330,9 @@ class DownloadClient:
             dest_file_path = os.path.join(dest_dir_path, did_name)
             item['dest_file_paths'] = [dest_file_path]
             item['temp_file_path'] = '%s.part' % dest_file_path
-            item.setdefault('ignore_checksum', True)
+            options = item.setdefault('merged_options', {})
+            options.setdefault('ignore_checksum', item.pop('ignore_checksum', True))
+            options.setdefault('transfer_timeout', item.pop('transfer_timeout', None))
 
             input_items.append(item)
 
@@ -653,7 +655,7 @@ class DownloadClient:
                 start_time = time.time()
 
                 try:
-                    protocol.get(pfn, temp_file_path, transfer_timeout=item.get('transfer_timeout'))
+                    protocol.get(pfn, temp_file_path, transfer_timeout=item.get('merged_options', {}).get('transfer_timeout'))
                     success = True
                 except Exception as error:
                     logger.debug(error)
@@ -661,7 +663,7 @@ class DownloadClient:
 
                 end_time = time.time()
 
-                if success and not item.get('ignore_checksum', False):
+                if success and not item.get('merged_options', {}).get('ignore_checksum', False):
                     rucio_checksum = item.get('adler32')
                     local_checksum = None
                     if not rucio_checksum:
diff --git a/lib/rucio/core/config.py b/lib/rucio/core/config.py
index 7904e6459..a61f32079 100644
--- a/lib/rucio/core/config.py
+++ b/lib/rucio/core/config.py
@@ -200,7 +200,7 @@ def set(section, option, value, session=None):
     :param session: The database session in use.
     """
 
-    if not has_option(section=section, option=option, session=session):
+    if not has_option(section=section, option=option, use_cache=False, session=session):
         new_option = models.Config(section=section, opt=option, value=value)
         new_option.save(session=session)
     else: