[ZODB-Dev] database conflict fail

Jim Fulton jim at zope.com
Thu Mar 22 19:23:53 UTC 2012


On Thu, Mar 22, 2012 at 1:23 PM, Claudiu Saftoiu <csaftoiu at gmail.com> wrote:
> On Thu, Mar 22, 2012 at 5:29 AM, Vincent Pelletier <vincent at nexedi.com>
> wrote:
>>
>> Le Wed, 21 Mar 2012 21:04:20 -0400,
>> Claudiu Saftoiu <csaftoiu at gmail.com> a écrit :
>> > I definitely want to keep the latest update.
>>
>> Then, if the change alters just one persistent object, you can write a
>> conflict resolution method on the class of that object
>> (_p_resolveConflict). Note, through, that this only means you will keep
>> the latest in commit order, not in transaction-begin order.
>
>
> Ahh, now that looks promising. Are there any particularly good places to
> get documentation on that sort of thing? All I see when I google are mailing
> list archives.
>
> Also: is there any easier way to see which objects had a conflict when a
> ConflictError is raised? Currently I am doing a binary-search via commenting
> code, but I figure there must be a better way...

Stop!  Before you go down that road, application-level conflict resolution
if an extremely advanced feature.  It's on the same level as meta classes
and custom import hooks in a Python.  It's a last resort (or maybe the one
after that).

The first thing you need to ask yourself is why your application wants to
update the same value from multiple threads.  This is a hot spot.
Hot spots: bad.  Most applications will need to update the same value from
multiple threads occasionally.  Occasionally retrying is fine.

If your application wants to update the same value from multiple
threads often, then that's a design problem you should solve.

Jim

-- 
Jim Fulton
http://www.linkedin.com/in/jimfulton


More information about the ZODB-Dev mailing list