[Zope3-dev] Potential bug of intid
Gary Poster
gary at zope.com
Sun Dec 11 08:30:06 EST 2005
On Dec 11, 2005, at 4:23 AM, Tadashi Matsumoto wrote:
> Hello
>
> I was looking into the following code of intid's __init__.py.
...
>
> I think it is better to use, for example, 2**30 instead of 2**31.
Looks like a good catch to me.
Also looks like 2**31 -1 would be sufficient (typical sys.maxint),
rather than 2**30...or maybe just sys.maxint (though I wouldn't be
surprised if the author had consciously rejected maxint for database
portability).
> By the way, there is a probability (less than 1/2**31 percent) of
> generating same intids, if thread switching occurs between the line
> 114 and 115.
At which point you should get a conflict error, which in Zope would
cause one of the transactions to be retried without the user's
knowledge and everything would still be good.
Gary
More information about the Zope3-dev
mailing list