[Zope] Trying to trap ConflictError

Jonathan dev101 at magma.ca
Wed Jul 5 16:02:44 EDT 2006


----- Original Message ----- 
From: <dieter at handshake.de>
To: "Jonathan" <dev101 at magma.ca>
Cc: "Dennis Allison" <allison at shasta.stanford.edu>; <zope at zope.org>
Sent: Wednesday, July 05, 2006 3:25 PM
Subject: Re: [Zope] Trying to trap ConflictError


> Jonathan wrote at 2006-7-5 14:40 -0400:
>> ...
>>The id for the image object is generated by the following code:
>>
>>def MakeId():
>>   time.sleep(.01)
>>   ts = string.replace(str(time.time()),'.', '')   # remove floating point
>>'.' char
>>   return ts[-10:]
>>
>>So there should not be any collision of ids.
>
> You should verify this. I doubt that you are right, as both the
> scheduling as well as the clock granularity are discrete (and rather
> coarse).
>
> I suggest you use either the mechanism of
>
>  *  the "BrowserIdManager"::it combines a time with a random number
>
>  *  the "ZCatalog": it chooses per thread a random number and
>     then assignes sequentially, until a conflict happens.
>     Then it restarts (choosing a random number...)
>
>>I am still investing, and have found errors like:
>>
>>2006-07-04T14:48:12 ERROR ZODB.Connection Couldn't load state for 0x1c
>>Traceback (most recent call last):
>>  File "/usr/local/Zope-2.9.2/lib/python/ZODB/Connection.py", line 732, in
>>setstate
>>    self._setstate(obj)
>>  File "/usr/local/Zope-2.9.2/lib/python/ZODB/Connection.py", line 768, in
>>_setstate
>>    p, serial = self._storage.load(obj._p_oid, self._version)
>>  File "/usr/local/Zope-2.9.2/lib/python/tempstorage/TemporaryStorage.py",
>>line 104, in load
>>    s=self._index[oid]
>>KeyError: '\x00\x00\x00\x00\x00\x00\x00\x1c'
>>
>>in the event.log.
>
> Apparently, you have more than a single type of error...
>
>
> Are you the person that used "try: ... except: ..."?
>
>   The non-deterministic inconsistencies caused by such constructs
>   can look like what you decribe above...

I was originally using the try/except to trap the conflict error, but as a 
result of being educated as to the futility of that approach I have since 
removed the try/except.

I have also included a random 3 digit suffix in the id generation routine to 
address the issue of muliple processes potentially generating the same id. 
However, the conflict errors remain, so I am back to investigating...

Thanks for the help,

Jonathan 



More information about the Zope mailing list