You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by Michael Hendricks <mi...@ndrix.org> on 2008/12/03 17:39:44 UTC

bulk update: deleting and updating

What should be the proper behavior for a bulk update request which
asks to delete a document and to update it at the same time?  For
example:

    POST http://127.0.0.1:5984/net-couchdb-11942-61931/_bulk_docs
    Accept: application/json
    Content-Length: 104

    {"docs":[{"_deleted":true,"_id":"drei","_rev":"683265243"},{"_id":"drei","third":3,"_rev":"683265243"}]}

Until recently (r713132), CouchDB returned a 412 response to indicate
that there was a conflict.  That seems like the right thing to do.
The new response seems broken:

    HTTP/1.1 201 Created
    Cache-Control: must-revalidate
    Date: Wed, 03 Dec 2008 16:24:15 GMT
    Server: CouchDB/0.9.0a-incubating (Erlang OTP/R12B)
    Content-Length: 89
    Content-Type: application/json
    Client-Date: Wed, 03 Dec 2008 16:24:15 GMT
    Client-Peer: 127.0.0.1:5984
    Client-Response-Num: 15

    {"ok":true,"new_revs":[{"id":"drei","rev":"2472902046"},{"id":"drei","rev":"965136091"}]}

In other words, it created two new revisions for the same document.
Is that intended behavior?

-- 
Michael

Re: bulk update: deleting and updating

Posted by Michael Hendricks <mi...@ndrix.org>.
On Wed, Dec 03, 2008 at 04:56:26PM -0800, Chris Anderson wrote:
> I like Damien's solution. Michael, have you got the bandwidth to put
> together a couch_tests.js patch that shows the error?

This bug, with an associated patch adding the failing test, is now
known as COUCHDB-172.  I tried my hand at fixing the problem also, but
ran out of cycles before I solved it.

-- 
Michael

Re: bulk update: deleting and updating

Posted by Chris Anderson <jc...@apache.org>.
I like Damien's solution. Michael, have you got the bandwidth to put
together a couch_tests.js patch that shows the error?

On Wed, Dec 3, 2008 at 8:48 AM, Damien Katz <da...@apache.org> wrote:
> It's not intended behavior, but I'd say just don't do that. Editing the same
> document twice in a bulk update is not supported. Maybe we should add an
> explicit check and return an error.
>
> -Damien
>
> On Dec 3, 2008, at 11:39 AM, Michael Hendricks wrote:
>
>> What should be the proper behavior for a bulk update request which
>> asks to delete a document and to update it at the same time?  For
>> example:
>>
>>   POST http://127.0.0.1:5984/net-couchdb-11942-61931/_bulk_docs
>>   Accept: application/json
>>   Content-Length: 104
>>
>>
>> {"docs":[{"_deleted":true,"_id":"drei","_rev":"683265243"},{"_id":"drei","third":3,"_rev":"683265243"}]}
>>
>> Until recently (r713132), CouchDB returned a 412 response to indicate
>> that there was a conflict.  That seems like the right thing to do.
>> The new response seems broken:
>>
>>   HTTP/1.1 201 Created
>>   Cache-Control: must-revalidate
>>   Date: Wed, 03 Dec 2008 16:24:15 GMT
>>   Server: CouchDB/0.9.0a-incubating (Erlang OTP/R12B)
>>   Content-Length: 89
>>   Content-Type: application/json
>>   Client-Date: Wed, 03 Dec 2008 16:24:15 GMT
>>   Client-Peer: 127.0.0.1:5984
>>   Client-Response-Num: 15
>>
>>
>> {"ok":true,"new_revs":[{"id":"drei","rev":"2472902046"},{"id":"drei","rev":"965136091"}]}
>>
>> In other words, it created two new revisions for the same document.
>> Is that intended behavior?
>>
>> --
>> Michael
>
>



-- 
Chris Anderson
http://jchris.mfdz.com

Re: bulk update: deleting and updating

Posted by Damien Katz <da...@apache.org>.
It's not intended behavior, but I'd say just don't do that. Editing  
the same document twice in a bulk update is not supported. Maybe we  
should add an explicit check and return an error.

-Damien

On Dec 3, 2008, at 11:39 AM, Michael Hendricks wrote:

> What should be the proper behavior for a bulk update request which
> asks to delete a document and to update it at the same time?  For
> example:
>
>    POST http://127.0.0.1:5984/net-couchdb-11942-61931/_bulk_docs
>    Accept: application/json
>    Content-Length: 104
>
>    {"docs":[{"_deleted":true,"_id":"drei","_rev":"683265243"}, 
> {"_id":"drei","third":3,"_rev":"683265243"}]}
>
> Until recently (r713132), CouchDB returned a 412 response to indicate
> that there was a conflict.  That seems like the right thing to do.
> The new response seems broken:
>
>    HTTP/1.1 201 Created
>    Cache-Control: must-revalidate
>    Date: Wed, 03 Dec 2008 16:24:15 GMT
>    Server: CouchDB/0.9.0a-incubating (Erlang OTP/R12B)
>    Content-Length: 89
>    Content-Type: application/json
>    Client-Date: Wed, 03 Dec 2008 16:24:15 GMT
>    Client-Peer: 127.0.0.1:5984
>    Client-Response-Num: 15
>
>    {"ok":true,"new_revs":[{"id":"drei","rev":"2472902046"}, 
> {"id":"drei","rev":"965136091"}]}
>
> In other words, it created two new revisions for the same document.
> Is that intended behavior?
>
> -- 
> Michael