[Zope-dev] Session Errors (read conflicts)

John Eikenberry jae-zdev@kavi.com
Tue, 18 Mar 2003 16:19:31 -0800


Chris McDonough wrote:

> On Mon, 2003-03-17 at 20:34, John Eikenberry wrote:
> > The KeyErrors happen under similar circumstances to the ReadConflictErrors.
> > The significant difference being that the KeyErrors happen after the
> > transience timeout has occured. When I am running with the
> > LowConflictConnection disabled the KeyErrors occur in the
> > Connection.setstate method at line 509, before the ReadConflictError check.
> 
> Is this the same KeyError you reported as coming out of
> TemporaryStorage.load?

Yes. I'm referring to the traceback I reported in a previous mail:

http://mail.zope.org/pipermail/zope-dev/2003-March/019118.html

The error occurs on the same line in TemporaryStorage.load(), whether it gets
called from ZODB/Connection.py or TemporaryFolder/LowConflictConnection.py.
 
> > So say you have 2 threads; A and B.  If A starts first, hits the session
> > code and triggers a _housekeep() call during which time B has started but
> > has not reached the Sessions code until after _housekeep() has finished.
> > When it does reach the sessions code, you get the KeyErrors. 
> 
> Would you mind restating that?  I think this is important, and I'm not
> sure I understand the second sentence above.

I'm working off the idea that the load() KeyErrors went away when the
ReadConflictErrors did. So it seemed like they were probably triggered by
similar scenarios. The difference being that for the former, the timeout had
been reached and the _housekeep() code had been run (and possibly some
additional code in _getCurrentBucket).

Now given Toby's description of how ReadConflicts occur [1], it seems that
instead of a change being committed to the object it is instead deleted (in
_housekeep). Thus instead of getting the object and seeing it is marked as
invalid, it cannot get the object at all when it expects to be able to...
resulting in the KeyError in load().



[1] "Read conflicts occur if a change is committed in between the start of a
transaction, and the transaction needing to load the object. A workaround to
reduce the number of read conflicts is to touch the objects that are likely
to change early in the transaction."

-- 

John Eikenberry [jae@kavi.com]
______________________________________________________________
"A society that will trade a little liberty for a little order
 will deserve neither and lose both."
                                          --B. Franklin