[PATCH 07 of 12 cubicweb] [database/pool] add new min/max-connections-pool-timeout configuration options

Laurent Peuch cortex at worlddomination.be
Tue Jan 7 13:30:42 CET 2020


# HG changeset patch
# User Laurent Peuch <cortex at worlddomination.be>
# Date 1578394948 -3600
#      Tue Jan 07 12:02:28 2020 +0100
# Node ID d130990ad5232ac291835920dd1c9542a61231ae
# Parent  aa0c36b821c105b0e2c9620342cb2a79c6dd010c
# Available At https://hg.logilab.org/users/lpeuch/cubicweb
#              hg pull https://hg.logilab.org/users/lpeuch/cubicweb -r d130990ad523
[database/pool] add new min/max-connections-pool-timeout configuration options

diff --git a/cubicweb/server/repository.py b/cubicweb/server/repository.py
--- a/cubicweb/server/repository.py
+++ b/cubicweb/server/repository.py
@@ -374,9 +374,12 @@ class Repository(object):
         if config['connections-pooler-enabled']:
             max_pool_size, cw_init_phase_max_pool_size = config['connections-pool-size'], 1
             min_pool_size = config['min-connections-pool-size']
+            max_pool_timeout = config['max-connections-pool-timeout']
+            min_pool_timeout = config['min-connections-pool-timeout']
         else:
             max_pool_size = cw_init_phase_max_pool_size = None
             min_pool_size = None
+            max_pool_timeout, min_pool_timeout = 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)
@@ -429,7 +432,8 @@ class Repository(object):
         #    proper initialization
         self.cnxsets.close()
         self.cnxsets = _CnxSetPool(self.system_source,
-                                   max_size=max_pool_size, min_size=min_pool_size)
+                                   max_size=max_pool_size, min_size=min_pool_size,
+                                   max_timeout=max_pool_timeout, min_timeout=min_pool_timeout)
         # 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
@@ -147,6 +147,20 @@ class ServerConfiguration(CubicWebConfig
                   'connections will have this minimum number of opened connections.',
           'group': 'main', 'level': 3,
           }),
+        ('max-connections-pool-timeout',
+         {'type': 'float',
+          'default': 5.0,
+          'help': 'the delay, in secondes, before failing to get a database connection fails.',
+          'group': 'main', 'level': 3,
+          }),
+        ('min-connections-pool-timeout',
+         {'type': 'float',
+          'default': 0.1,
+          'help': 'the delay, in secondes, before failing to get a database connection result in '
+                  'opening a new connection if the max number of connections '
+                  '(connections-pool-size) hasn\'t been reached yet.',
+          'group': 'main', 'level': 3,
+          }),
         ('rql-cache-size',
          {'type': 'int',
           'default': 3000,



More information about the cubicweb-devel mailing list