I'm glad you solved this for your application, Dieter... I'm still struggling to try to pin it down for mine... I thought we had it licked after Shane showed me how to properly close a ZODB connection in CST, but unfortunately, the problem was unrelated. :-( Dieter Maurer wrote:
Recently, I reported a strange effect where Zope suddenly and without apparent reason reports lots of "Could not load state: None object has no attribute 'load'.
I think, I now understand why this happens and can work around it:
We use GUF (Generic User Folder) to maintain users in an Oracle database. Although Oracle is quite fast with the kind of queries involved in authentication (with others it is extremely slow), the complete authentication process was slow: 0.2 to 0.5 seconds I wanted to improve on this and implemented a user cache.
For simplicity and speed I cached the completely wrapped user object. Not a good idea, if one thinks carefully about it!
Apparently, everything worked well, but suddenly, non-deterministically after many hours, Zope reports "Could not load..." in the log file and raises really erratic exceptions in Web requests....
What have I learned....
*NEVER* cache persistent objects (or objects referencing a persistent one!).
They contain a hidden reference to the ZODB connection that created them (and that is used to load subobjects that have not yet been loaded). This reference is valid only in the thread (and probably also only the request) that made it.
Invalid uses can show very interesting effects, like the above "Could not load...", "TypeError, 'Results' instances do not support subscription", "AttributeError, '__len__'", .....
What will I do:
I will cache the bare non-persistent user object (after I scrapped all acquisition wrappers). I will rewrap it into the UserFolder context, when the cached object is looked up.
Special thanks to Chris for his help with the original problem report.
Dieter
_______________________________________________ Zope-Dev maillist - Zope-Dev@zope.org http://lists.zope.org/mailman/listinfo/zope-dev ** No cross posts or HTML encoding! ** (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce http://lists.zope.org/mailman/listinfo/zope )
-- Chris McDonough Zope Corporation http://www.zope.org http://www.zope.com "Killing hundreds of birds with thousands of stones"