Temporary connections not released
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
ZODB |
Won't Fix
|
Medium
|
Unassigned |
Bug Description
Temporary ZODB connections are never released.
The bug stems from 2 points:
* the "cc.close()" in "DB.DB.invalidate" closes the
connection but cycles involving the cache prevent
the connection from being garbage collected
* "DB.DB.close" forgets about temporary connections
Both bugs might disappear with Zope 2.8, if then the
cache participates in cyclic garbage collection.
*However* I am not sure! The cyclic garbage collector
cannot collect cycles involving objects with "__del__" methods
and the complex cycle formed between the connection and its cache
might contain such objects (altough persistent objects should
not have "__del__" methods).
Thus, it is probably better to not rely on the cyclic collector.
If "temporary connection" means one obtained by passing temporary=True to DB.open(), that argument was deprecated (and ignored) starting in ZODB 3.4 (3.4 has no inherent limit on the # of open connections, so the concept of a "temporary" connection stopped making much sense). I've opened hundreds of thousands of connections in stress programs there and never bothered to close them -- they do go away when they're no longer strongly referenced ("strongly" means that DB and transaction managers in 3.4 hold only weak references to connections).
The connection management code in 3.2 is more complicated and delicate. If you have a patch that works for you, I'll try to get into the next ZODB 3.2 bugfix release (assuming there is another one -- my best guess is yes, there will be).