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'