[PATCH 16 of 23 cubicweb V2] [database/pool] add new connections-pool-low-load-delay configuration options

Laurent Peuch cortex at worlddomination.be
Fri Jan 17 14:37:13 CET 2020


# HG changeset patch
# User Laurent Peuch <cortex at worlddomination.be>
# Date 1578396410 -3600
#      Tue Jan 07 12:26:50 2020 +0100
# Node ID bbc35c6da843d5a6a834d3705053655ab6b2c9c4
# Parent  966be2fff9c4b6eb8d4bb6dac3aaacdb28299d9a
# Available At https://hg.logilab.org/users/lpeuch/cubicweb
#              hg pull https://hg.logilab.org/users/lpeuch/cubicweb -r bbc35c6da843
[database/pool] add new connections-pool-low-load-delay configuration options

diff --git a/cubicweb/server/repository.py b/cubicweb/server/repository.py
--- a/cubicweb/server/repository.py
+++ b/cubicweb/server/repository.py
@@ -417,10 +417,12 @@ class Repository(object):
             min_pool_size = config['min-connections-pool-size']
             max_pool_timeout = config['max-connections-pool-timeout']
             min_pool_timeout = config['min-connections-pool-timeout']
+            pool_low_load_delay = config['connections-pool-low-load-delay']
         else:
             max_pool_size = cw_init_phase_max_pool_size = None
             min_pool_size = None
             max_pool_timeout, min_pool_timeout = None
+            pool_low_load_delay = None
         # 0. init a cnxset that will be used to fetch bootstrap information from
         #    the database
         self.cnxsets = _CnxSetPool(self.system_source, cw_init_phase_max_pool_size)
@@ -474,7 +476,8 @@ class Repository(object):
         self.cnxsets.close()
         self.cnxsets = _CnxSetPool(self.system_source,
                                    max_size=max_pool_size, min_size=min_pool_size,
-                                   max_timeout=max_pool_timeout, min_timeout=min_pool_timeout)
+                                   max_timeout=max_pool_timeout, min_timeout=min_pool_timeout,
+                                   low_load_delay=pool_low_load_delay)
         # 5. call instance level initialisation hooks
         self.hm.call_hooks('server_startup', repo=self)
 
diff --git a/cubicweb/server/serverconfig.py b/cubicweb/server/serverconfig.py
--- a/cubicweb/server/serverconfig.py
+++ b/cubicweb/server/serverconfig.py
@@ -161,6 +161,13 @@ class ServerConfiguration(CubicWebConfig
                   '(connections-pool-size) hasn\'t been reached yet.',
           'group': 'main', 'level': 3,
           }),
+        ('connections-pool-low-load-delay',
+         {'type': 'int',
+          'default': 30,
+          'help': 'the delay, in secondes, of low load before the connections pool will start to '
+                  'close open database connections if there are more than the minimum numbers',
+          'group': 'main', 'level': 3,
+          }),
         ('rql-cache-size',
          {'type': 'int',
           'default': 3000,



More information about the cubicweb-devel mailing list