Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

minconn and maxconn in pool code allow for non integer values resulting in unbounded pool

#220

Submitted by: bhazuka@usgs.gov

While working with connection pools the AbstractConnectionPool(minconn, maxconn, args, **kwargs), SimpleConnectionPool(minconn, maxconn, *args, **kwargs) and ThreadedConnectionPool(minconn, maxconn, *args, *kwargs) classes were ignoring the maxconn value that was being set.

A typical object initialization looked like the following.
pool = SimpleConnectionPool(5,
cfg['database.max_connections'], host=cfg['database.host'], port=cfg['database.port'], database=cfg['database.db'], user=user, password=passwd )

Where cfg[] was a dictionary object resulting from the ConfigParser making all the values configurable. This resulted in all of the cfg values being of a string type.

Based on the current comparison in the AbstractConnectionPool code where length of the array must be less than the max connection an integer gets compared with in the case detailed above a string. This results in the maxpool size code always resulting in generating another connection and not limiting the pool size. A simple fix of int(cfg['database.max_connections']) was able to resolve the issue once I understood what was going on. I propose adding a type check in the AbstractConnectionPool class for the maxconn and minconn variables and raising an error if they are not type integer.

Reported by Psycopg website · June 13th, 2014 @ 03:47 PM

State: resolved
Milestone: none
Assigned to: nobody

Activity

  1. Daniele Varrazzo
    Daniele Varrazzo
    • State changed from new to resolved

    Fixed in psycopg 2.5.4. The class init now attempts a conversion to int.

    August 13th, 2014 @ 01:35 AM