[ZODB-Dev] Maximum pool size considered harmful

Jim Fulton jim at zope.com
Fri May 14 06:18:49 EDT 2004


Jeremy Hylton wrote:
> One thing I don't understand about the proposal is why the DB keeps weak
> references to the connections. 

So it can compute cache statistics or allow other connection monitoring tools
to get at existing connections,


 > A connection is explicitly opened and
> closed. 

The terms "open" and "close" are a bit missleading here.  Better words
would be "use" and "don't use".  "open" implies construction, but
usually, when you open a connection, you may actually get an existing
one.  Similarly, "closing" implies destruction, but closing a ZODB connection
may just put it in a pool.  This is further complicated by the fact that
the existing implementation partially destroys and reconstructs connections
when they are closed and opened.  This code was originally written to avoid
cycles in Python 1.x.  This code is very confusing and error prone.  A side
agenda in this proposal is to vastly simplify this code.  The tear-down that
currently happens in close will go away.


 > A weakref is usually used to avoid keeping resources alive
> unnecessarily, but the DB can simply drop its (strong) reference to excess
> connections when they are closed.  Is the proposal intending to make the
> close() call optional? 

Yes.

 > I can't tell why that would be.

Doing so simplifies application code avoids a whole class of bugs.  Connections
*should* be able to be garbage collected if application code stops using them.

Applications that don't care about reusing connections needn't bother closing them.
OTOH, applications that do care, like Zope, will continue to use close.

Jim

-- 
Jim Fulton           mailto:jim at zope.com       Python Powered!
CTO                  (540) 361-1714            http://www.python.org
Zope Corporation     http://www.zope.com       http://www.zope.org




More information about the ZODB-Dev mailing list