You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The TransactionalUndo object never closes the new storage.
RelStorage could potentially work around this (e.g., implement a 'undo_instance' method that returns a special storage wrapper that closes itself in tpc_finish and tpc_abort), but it seems like the more general solution would be for TransactionalUndo to close the storage it opened in its implementation of those methods.
This problem is made worse by the fact that there's a reference cycle involved, so the connections won't get cleaned up until the GC runs at some arbitrary point in the future.
The reference cycle was completely non-intuitive. The active transaction points to the TransactionalUndo instance as a resource manager (Transaction._resources), which points to the storage instance (TransactionalUndo._storage); the storage instance has methods that have __globals__ being the module dictionary of relstorage.storage; in turn (through a chain of module imports) the transaction module is referenced. The transaction module has an instance of ThreadTransactionManager, which has a thread-local dictionary containing the current transaction manager, which in turn points back to the active transaction.
_txn is the active transaction instance from step 1
EDIT: As pointed out in zopefoundation/transaction#82, the transaction does drop the IDataManager objects it has when a transaction is committed, so there must be another cycle somewhere.
Activity
jamadden commentedon May 14, 2019
This problem is made worse by the fact that there's a reference cycle involved, so the connections won't get cleaned up until the GC runs at some arbitrary point in the future.
The reference cycle was completely non-intuitive. The active transaction points to the
TransactionalUndoinstance as a resource manager (Transaction._resources), which points to the storage instance (TransactionalUndo._storage); the storage instance has methods that have__globals__being the module dictionary ofrelstorage.storage; in turn (through a chain of module imports) thetransactionmodule is referenced. Thetransactionmodule has an instance ofThreadTransactionManager, which has a thread-local dictionary containing the current transaction manager, which in turn points back to the active transaction.relstorage.storage->ZODB->ZODB.POSException->transaction) ->_txnis the active transaction instance from step 1EDIT: As pointed out in zopefoundation/transaction#82, the transaction does drop the IDataManager objects it has when a transaction is committed, so there must be another cycle somewhere.
TransactionalUndo closes storages it opens.
TransactionalUndo closes storages it opens.
d-maurer commentedon May 15, 2019
The
ZEOtests produce lots ofResourceWarnings of the formunclosed file,unclosed socket. Maybe, the cycles come not fromtransaction?jamadden commentedon May 15, 2019
I'll try to manually break this cycle and then go hunting again.
Failure to close the storage was easy to diagnose and correct, though.
TransactionalUndo releases storages it opens.