[ZODB-Dev] Debugging ConflictErrors
Casey Duncan
casey at zope.com
Thu Jan 15 09:19:05 EST 2004
On Thu, 15 Jan 2004 14:47:21 +0100
Thomas Güttler <tguettler at tbz-pariv.de> wrote:
> Hi!
>
> Has someone hints how to debug ConflictErrors?
>
> Up to now I log ConflictErrors like this:
>
> # First version taken from Dulcinea/lib/ui/publish.py
> retries=15
> for i in range(retries):
> try:
> return Publisher.try_publish(self, request, path)
> except ConflictError, exc:
> obj=self.root_namespace._p_jar[exc.oid]
> print "ConflictError %sv%s: retrying request. " \
> "path=%s user=%s obj=%s oid=%s" % (
> i, retries,
> path, os.environ.get("REMOTE_USER", ""),
> repr(exc.oid), obj)
> get_transaction().abort()
> request.response = HTTPResponse() # reset response
> object time.sleep(2 + (random.random() * (i+1)))
> else:
> raise RuntimeError("too many conflict errors")
>
> The conflicts always are in my root object. This is
> the object which holds all other objects. I use ZODB 3.2
Do you regularly mutate the root object (i.e., add and remove keys?). If
so I would recommend against it, AFAIK it will not allow concurrent
changes without conflicts. If you need to mutate a mapping concurrently
you should use a BTree hung off the root object.
In general ZODB apps keep a few static keys in the root and only mutate
lower objects regularly.
-Casey
More information about the ZODB-Dev
mailing list