[Zope3-dev] Potential bug of intid
Tadashi Matsumoto
ma2 at city.plala.jp
Sun Dec 11 11:00:30 EST 2005
On Sun, 11 Dec 2005 08:30:06 -0500
gary at zope.com wrote.
> 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),
No it wouldn't, because intid will increase.
> 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
Generating same intids does not always mean a conflict error.
----
Tadashi Matsumoto
ma2 at city.plala.jp
More information about the Zope3-dev
mailing list