[PATCH 08 of 12 cubicweb] [database/pool] add new connections-pool-low-load-delay configuration options

Laurent Peuch cortex at worlddomination.be
Tue Jan 7 13:30:43 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 d86d7a5fb913bede7c8203490075caf191134fca
# Parent  d130990ad5232ac291835920dd1c9542a61231ae
# Available At https://hg.logilab.org/users/lpeuch/cubicweb
#              hg pull https://hg.logilab.org/users/lpeuch/cubicweb -r d86d7a5fb913
[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
@@ -376,10 +376,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)
@@ -433,7 +435,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