[ZCM] [ZC] 2334/ 2 Comment "_ConnectionPool._reduce_size provides no hook"

"Collector: Zope Bugs, Features, and Patches ..." <[email protected]> Tue, 12 Jun 2007 22:37:37 -0400
Newsgroups gmane.comp.web.zope.devel.collector-monitor
Message-ID <[email protected]>
Issue #2334 Update (Comment) "_ConnectionPool._reduce_size provides no hook"
 Status Pending, Database/feature medium
To followup, visit:
  http://www.zope.org/Collectors/Zope/2334

==============================================================
= Comment - Entry #2 by eikenberry on Jun 12, 2007 10:37 pm

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. 
________________________________________
= Request - Entry #1 by eikenberry on Jun 12, 2007 6:25 pm

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.

==============================================================