[Zope] ConflictError (ID-Counter for all Documents)

seb bacon seb@jamkit.com
25 Jan 2002 10:05:21 +0000


I haven't followed this thread, so feel free to shoot me down - but
what's wrong with making an autoincrement product which spits out
[number++] each time it is called?

seb

On Fri, 2002-01-25 at 03:38, Troy Farrell wrote:
> Ahhh.  Threading issues.  Can you try something?
> Look a lib/python/ts_regex.py
> I think that this is the locking you are looking for.  If this works, it 
> could be the answer to our unique_id problems.
> I see a Zope3 utility coming: unique id number generator.
> 
> Troy
> 
> -- 
> Troy Farrell
> Developer
> Entheos Software
> mailto:troy@entheossoft.com
> http://www.entheossoft.com
> 
> Thomas Guettler wrote:
> 
> >     Toby Dickenson wrote:
> > 
> >> On Thu, 24 Jan 2002 11:59:18 +0100, Thomas Guettler
> >> <zopestoller@thomas-guettler.de> wrote:
> >>
> >>> Catch the Exception, and retry it.
> >>>
> >>
> >> Dont catch it yourself. Zope is already doing this, and only shows the
> >> client an error message if it still fails after 3 attempts.
> >>
> >>> Use PCounter from ZODB/test/ConflictResolution.py
> >>>
> >>
> >> No, for two reasons:
> >>
> >> That class makes a good counter, but it is no use if you want to use
> >> the counter to generate unique ids. It works by allowing two
> >> transactions to proceed simultaneously with the same count value, then
> >> incrementing the count by two instead of one.
> >>
> >> Secondly, it wouldnt help even if it did generate unique ids. You
> >> would still get a conflict from the folder object.
> >>
> >> The easiest solution is to use only one publisher thread. That means
> >> no concurrency, no conflicts, but limited scalability.
> >>
> > Would this mean that if someone is downloading a 100MB file all other 
> > request have to wait?
> > 
> > I already asked this in an other thread: How can I get somethink like a 
> > syncronized block in Java?
> > 
> > syncronize{
> > last_id=last_id+1
> > }
> > 
> >>
> >> You best solution is:
> >>
> >> 1. Use a BTreeFolder (download it from www.zope.org), which allows for
> >> concurrent writes. It wont eliminate the need for retries, but it
> >> should decrease the probability of a failure after the three retries
> >> to an acceptable level.
> >>
> > I downloaded it. But it doesn't allow me to _setObject() of an int or a 
> > string.
> > 
> > 
> >>
> >> 2. Use a different method of generating ids, to avoid the problem
> >> where two concurrent writes always generate the same id. The easiest
> >> solution is random ids.
> >>
> > 
> > I now use BTreeFolder to store all documents. The ID of  the documents 
> > is created with DateTime().millis()
> > This works much better than before, but still gives me some conflicts 
> > when I add the new document to the folder:
> > 
> > Sometimes I get a strange error:
> > 2002-01-24T17:14:44 ERROR(200) ZODB Couldn't load state for 
> > '\x00\x00\x00\x00\x0
> > 0\x00!\x0b'
> > Traceback (innermost last):
> >  File F:\ZOPE-2~1\lib\python\ZODB\Connection.py, line 446, in setstate
> > AttributeError: 'None' object has no attribute 'load'
> > 
> > 
> > 
> > 
> > _______________________________________________
> > Zope maillist  -  Zope@zope.org
> > http://lists.zope.org/mailman/listinfo/zope
> > **   No cross posts or HTML encoding!  **
> > (Related lists - http://lists.zope.org/mailman/listinfo/zope-announce
> > http://lists.zope.org/mailman/listinfo/zope-dev )
> > 
> > 
> 
> 
> 
> 
> _______________________________________________
> Zope maillist  -  Zope@zope.org
> http://lists.zope.org/mailman/listinfo/zope
> **   No cross posts or HTML encoding!  **
> (Related lists - 
>  http://lists.zope.org/mailman/listinfo/zope-announce
>  http://lists.zope.org/mailman/listinfo/zope-dev )