_ConnectionPool._reduce_size provides no hook

Bug #143927 reported by John Eikenberry
2
Affects Status Importance Assigned to Milestone
ZODB
Triaged
Wishlist
Unassigned

Bug Description

Tracked down a local memory leak to Zope leaking database connections when the _ConnectionPool is temporarily expanded beyond the target size. When the pool is resized the mysql connections are leaked. This is a known limitation with mysqldb, that you must explicitally close() a connection or it will leak. But there is no hook provided to do this.

Unless I'm missing some way of doing this (always possible) I think providing a hook here would really help when dealing with not quite well behaved C modules.

Revision history for this message
John Eikenberry (jae) wrote :

After thinking about this some more I don't think a callback/hook would work here as there are no guarantees that the connection is not still in use at this point.

Maybe I could check for this in a synchronizer. Detect that the connection has been removed from the pool and close the database connection. Detecting that the connection has been removed from the pool is the trick though.

Revision history for this message
John Eikenberry (jae) wrote :

> = Comment - Entry #3 by tseaver on Jun 13, 2007 9:16 am
>
> One possibility would be to set the "target" size of connections
> which are removed from the pool to 0, and just allow ZODB's
> garbage collection to do its thing for you.

This is what we have done for the moment. Made sure all our sites have the pool-size set to be >= to the zserver-threads value. This fixes our sites but I am helping maintain the ZMySQLDA and would like to include a fix there other than requiring a certain configuration setup.

> We might also add an event to be published at removal (maybe
> at add, as well); you could then register a subscriber which
> used the about-to-be removed ZODB connection to find the DA and
> issued the 'close'.

This sounds like just what I need.
+1

Revision history for this message
Tres Seaver (tseaver) wrote :

One possibility would be to set the "target" size of connections
which are removed from the pool to 0, and just allow ZODB's
garbage collection to do its thing for you.

We might also add an event to be published at removal (maybe
at add, as well); you could then register a subscriber which
used the about-to-be removed ZODB connection to find the DA and
issued the 'close'.

Tres Seaver (tseaver)
affects: zope2 → zodb
Changed in zodb:
importance: Medium → Wishlist
status: New → Triaged
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.