[PATCH 12 of 23 cubicweb V2] [database/pool] add new min-connections-pool-size configuration option

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


# HG changeset patch
# User Laurent Peuch <cortex at worlddomination.be>
# Date 1578393398 -3600
#      Tue Jan 07 11:36:38 2020 +0100
# Node ID faafdb1362b331ae794094e0582d534fe81bd576
# Parent  01724c9a1b9443365572051667245cd77f32ccf0
# Available At https://hg.logilab.org/users/lpeuch/cubicweb
#              hg pull https://hg.logilab.org/users/lpeuch/cubicweb -r faafdb1362b3
[database/pool] add new min-connections-pool-size configuration option

diff --git a/cubicweb/server/repository.py b/cubicweb/server/repository.py
--- a/cubicweb/server/repository.py
+++ b/cubicweb/server/repository.py
@@ -414,8 +414,10 @@ class Repository(object):
         # size.
         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']
         else:
             max_pool_size = cw_init_phase_max_pool_size = None
+            min_pool_size = 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)
@@ -467,7 +469,8 @@ class Repository(object):
         # 4. close initialization connection set and reopen fresh ones for
         #    proper initialization
         self.cnxsets.close()
-        self.cnxsets = _CnxSetPool(self.system_source, max_pool_size)
+        self.cnxsets = _CnxSetPool(self.system_source,
+                                   max_size=max_pool_size, min_size=min_pool_size)
         # 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
@@ -139,6 +139,13 @@ the repository rather than the user runn
 connections will have this maximum number of opened connections.',
           'group': 'main', 'level': 3,
           }),
+        ('min-connections-pool-size',
+         {'type': 'int',
+          'default': 3,
+          'help': 'min size of the connections pool. Each source supporting multiple \
+connections will have this minimum number of opened connections.',
+          'group': 'main', 'level': 3,
+          }),
         ('rql-cache-size',
          {'type' : 'int',
           'default': 3000,



More information about the cubicweb-devel mailing list