[PATCH 17 of 23 cubicweb V2] [database/pool] add new connections-pool-close-delay configuration option

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


# HG changeset patch
# User Laurent Peuch <cortex at worlddomination.be>
# Date 1578398224 -3600
#      Tue Jan 07 12:57:04 2020 +0100
# Node ID 76eba6b498e83a3bb9a85f82ff20673b8c63fe73
# Parent  bbc35c6da843d5a6a834d3705053655ab6b2c9c4
# Available At https://hg.logilab.org/users/lpeuch/cubicweb
#              hg pull https://hg.logilab.org/users/lpeuch/cubicweb -r 76eba6b498e8
[database/pool] add new connections-pool-close-delay configuration option

diff --git a/cubicweb/server/repository.py b/cubicweb/server/repository.py
--- a/cubicweb/server/repository.py
+++ b/cubicweb/server/repository.py
@@ -418,11 +418,13 @@ class Repository(object):
             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']
+            pool_close_delay = config['connections-pool-close-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
+            pool_close_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)
@@ -477,7 +479,8 @@ class Repository(object):
         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,
-                                   low_load_delay=pool_low_load_delay)
+                                   low_load_delay=pool_low_load_delay,
+                                   close_delay=pool_close_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
@@ -168,6 +168,14 @@ class ServerConfiguration(CubicWebConfig
                   'close open database connections if there are more than the minimum numbers',
           'group': 'main', 'level': 3,
           }),
+        ('connections-pool-close-delay',
+         {'type': 'int',
+          'default': 5,
+          'help': 'the delay, in secondes, between each connection close when the load is low and '
+                  'there are more open unused connections than the minimum number of open '
+                  'connections (min-connections-pool-size)',
+          'group': 'main', 'level': 3,
+          }),
         ('rql-cache-size',
          {'type': 'int',
           'default': 3000,



More information about the cubicweb-devel mailing list