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

Laurent Peuch cortex at worlddomination.be
Tue Jan 7 13:30:39 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 b14b764ae605da5aa25f778deb5bf9019368390f
# Parent  41efc8a1933cb72b35ee0c66f017bf36aa848050
# Available At https://hg.logilab.org/users/lpeuch/cubicweb
#              hg pull https://hg.logilab.org/users/lpeuch/cubicweb -r b14b764ae605
[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
@@ -373,8 +373,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)
@@ -426,7 +428,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