[ZODB-Dev] ReadConflictError while re-indexing big fat index
sean.upton at uniontrib.com
sean.upton at uniontrib.com
Mon Aug 2 15:34:24 EDT 2004
Tim Peters wrote:
> you read object 1
> another transaction commits a change to object 2
> you get an invalidation for object 2 as a result
> you try to read object 2
>
> Now you get a read conflict: ZODB is protecting you from
> seeing object 2 in a state that may be inconsistent with the
> state you already have for object 1. If you had read object
> 2 before it was invalidated, no problem, then the states you
> see for objects 1 and 2 are consistent.
So is there any way to re-read the object based on it's new state after you
catch the RCE and want to retry (outside the publisher machinery)? I'm
thinking something less complicated than "re-loading" an entire index.
Let's say, just a simple content object gets invalidated. What's the "right
way" to reload in a scenario like this:
app = Zope.app()
retries = 0
while 1:
try:
foo = app['foo'].__of__(app)
#another thread/client changes app.foo here
print foo.bar #raises RCE
break
except ReadConflictError:
retries += 1
#do something here to make the air safe to breath again?
if retries > 4: break
Is there any way to get the new, consistent state for app.foo in the except
block above, so that I'm not retrying in vain? Will get_connection().sync()
do the trick or is there something more?
This stuff is painful - I think I will be jumping on the 2.8/MVCC testing
bandwagon soon with some test instances of our production apps.
Thanks,
Sean
+----------------------------------------------------------+
Sean Upton SignOnSanDiego.com
Site Technology Supervisor The San Diego Union-Tribune
619.718.5241 sean.upton at signonsandiego.com
2375 Northside Dr #300 San Diego, CA 92108
Plone Powered! plone.org ++ python.org ++ zope.org
+----------------------------------------------------------+
More information about the ZODB-Dev
mailing list