couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Ryan Ramage <ryan.ram...@gmail.com>
Subject Re: Update conflicts?
Date Wed, 06 Apr 2011 00:45:57 GMT
Luis,

Having the rev is very important when you update a doc. It lets you
know that your piece of information is out of date. This is a good
thing....

I am wondering if the way you are modeling your data is not leading
you to do this update with less chance of conflict. See if you can
break your docs into even smaller docs. For example, I noticed from a
prior post you had a lot of Arrays in your docs. If multiple processes
are changing that array, you might be better served by making each
element in the array a separate doc.

Ryan

On Tue, Apr 5, 2011 at 4:41 PM, Luis Miguel Silva
<luismiguelferreirasilva@gmail.com> wrote:
> More or less!
>
> The most common scenario will be:
> - two or more processes writing to the same document, but only to a
> specific attribute (not overwriting the whole document)
>
> If, by any chance, two processes overwrite the same field, i'm ok with
> the last one always winning.
>
> Thanks,
> Luis
>
> On Tue, Apr 5, 2011 at 4:26 PM, Robert Newson <robert.newson@gmail.com> wrote:
>> "Ideally, we would be able to update without specifying the _rev, just
>> posting (or, in this case PUTting) to the document..."
>>
>> So you want to blindly overwrite some unknown data?
>>
>> B.
>>
>> On 5 April 2011 22:57, Zachary Zolton <zachary.zolton@gmail.com> wrote:
>>> Luis,
>>>
>>> Checkout _update handlers:
>>>
>>> http://wiki.apache.org/couchdb/Document_Update_Handlers
>>>
>>>
>>> Cheers,
>>>
>>> Zach
>>>
>>> On Tue, Apr 5, 2011 at 4:46 PM, Luis Miguel Silva
>>> <luismiguelferreirasilva@gmail.com> wrote:
>>>> Dear all,
>>>>
>>>> I'm trying to play around with updates and i'm bumping into some problems.
>>>>
>>>> Let's image we have to clients that poll a document from the server at
>>>> the same time and get the same _rev.
>>>> Then one of them updates the doc based on the _rev it got:
>>>> [root@xkitten ~]# curl -X PUT -d
>>>> '{"_rev":"3-0d519bcf08130bf784f3c35d79760740","hello2":"fred2"}'
>>>> http://localhost:5984/benchmark/test?conflicts=true
>>>> {"ok":true,"id":"test","rev":"4-03640ebafbb4fcaf127844671f8e2de7"}
>>>> Then another one tries to update the doc based on the same exact _rev:
>>>> [root@xkitten ~]# curl -X PUT -d
>>>> '{"_rev":"3-0d519bcf08130bf784f3c35d79760740","hello3":"fred3"}'
>>>> http://localhost:5984/benchmark/test?conflicts=true
>>>> {"error":"conflict","reason":"Document update conflict."}
>>>> [root@xkitten ~]#
>>>>
>>>> Is there a way to avoid this?! (like...make the update just create a
>>>> new _rev or something)??
>>>>
>>>> Ideally, we would be able to update without specifying the _rev, just
>>>> posting (or, in this case PUTting) to the document...
>>>>
>>>> Thoughts??
>>>>
>>>> Thank you,
>>>> Luis
>>>>
>>>
>>
>

Mime
View raw message