You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@couchdb.apache.org by Martin Hilbig <bl...@gmx.net> on 2011/01/24 22:16:50 UTC

Document update conflict. and attachments

hi,

is this a known bug or even my fault?

create db:

curl -X PUT http://localhost:5984/fail
{"ok":true}

create doc:

curl -vX PUT http://localhost:5984/fail/doc -d '{}'
{"ok":true,"id":"doc","rev":"1-967a00dff5e02add41819138abb3284d"}

put attachment with nearly correct format ?rev=x-y

curl -vX PUT http://localhost:5984/fail/doc/att?rev=12-12345 -d '{}'
 > PUT /fail/doc/att?rev=12-12345 HTTP/1.1
 > User-Agent: curl/7.21.3 (x86_64-unknown-linux-gnu) libcurl/7.21.3 
OpenSSL/1.0.0c zlib/1.2.5
 > Host: localhost:5984
 > Accept: */*
 > Content-Length: 2
 > Content-Type: application/x-www-form-urlencoded
 >
< HTTP/1.1 500 Internal Server Error
< Server: CouchDB/1.0.1 (Erlang OTP/R14B)
< Date: Mon, 24 Jan 2011 21:08:53 GMT
< Content-Type: text/plain;charset=utf-8
< Content-Length: 62
< Cache-Control: must-revalidate
<
{"error":"{not_found,missing}","reason":"{12,<<\"12345\">>}"}

shouldn't look this like:

curl -X PUT 
http://localhost:5984/fail/doc/att?rev=1-967a00dff5e02add41819138abb3284d -d 
'{}'
{"ok":true,"id":"doc","rev":"2-25fb7eb27842ed11617f4e8656600c54"}

curl -vX PUT 
http://localhost:5984/fail/doc/att?rev=1-967a00dff5e02add41819138abb3284d -d 
'{}'
 > PUT /fail/doc/att?rev=1-967a00dff5e02add41819138abb3284d HTTP/1.1
 > User-Agent: curl/7.21.3 (x86_64-unknown-linux-gnu) libcurl/7.21.3 
OpenSSL/1.0.0c zlib/1.2.5
 > Host: localhost:5984
 > Accept: */*
 > Content-Length: 2
 > Content-Type: application/x-www-form-urlencoded
 >
< HTTP/1.1 409 Conflict
< Server: CouchDB/1.0.1 (Erlang OTP/R14B)
< Date: Mon, 24 Jan 2011 21:12:04 GMT
< Content-Type: text/plain;charset=utf-8
< Content-Length: 58
< Cache-Control: must-revalidate
<
{"error":"conflict","reason":"Document update conflict."}

to sum it up: couchdb only sends a correct 'document update conflict' on 
attachments, when you give a rev already in the documents history.

have fun
martin

Re: Document update conflict. and attachments

Posted by Klaus Trainer <kl...@web.de>.
I'd rather say this is a known issue:
https://issues.apache.org/jira/browse/COUCHDB-1018

If nobody comes up with a patch for that, I'll do it as soon as I find
some time for that.


On Mon, 2011-01-24 at 16:30 -0500, Paul Davis wrote:
> On Mon, Jan 24, 2011 at 4:16 PM, Martin Hilbig <bl...@gmx.net> wrote:
> > hi,
> >
> > is this a known bug or even my fault?
> >
> > create db:
> >
> > curl -X PUT http://localhost:5984/fail
> > {"ok":true}
> >
> > create doc:
> >
> > curl -vX PUT http://localhost:5984/fail/doc -d '{}'
> > {"ok":true,"id":"doc","rev":"1-967a00dff5e02add41819138abb3284d"}
> >
> > put attachment with nearly correct format ?rev=x-y
> >
> > curl -vX PUT http://localhost:5984/fail/doc/att?rev=12-12345 -d '{}'
> >> PUT /fail/doc/att?rev=12-12345 HTTP/1.1
> >> User-Agent: curl/7.21.3 (x86_64-unknown-linux-gnu) libcurl/7.21.3
> >> OpenSSL/1.0.0c zlib/1.2.5
> >> Host: localhost:5984
> >> Accept: */*
> >> Content-Length: 2
> >> Content-Type: application/x-www-form-urlencoded
> >>
> > < HTTP/1.1 500 Internal Server Error
> > < Server: CouchDB/1.0.1 (Erlang OTP/R14B)
> > < Date: Mon, 24 Jan 2011 21:08:53 GMT
> > < Content-Type: text/plain;charset=utf-8
> > < Content-Length: 62
> > < Cache-Control: must-revalidate
> > <
> > {"error":"{not_found,missing}","reason":"{12,<<\"12345\">>}"}
> >
> > shouldn't look this like:
> >
> > curl -X PUT
> > http://localhost:5984/fail/doc/att?rev=1-967a00dff5e02add41819138abb3284d -d
> > '{}'
> > {"ok":true,"id":"doc","rev":"2-25fb7eb27842ed11617f4e8656600c54"}
> >
> > curl -vX PUT
> > http://localhost:5984/fail/doc/att?rev=1-967a00dff5e02add41819138abb3284d -d
> > '{}'
> >> PUT /fail/doc/att?rev=1-967a00dff5e02add41819138abb3284d HTTP/1.1
> >> User-Agent: curl/7.21.3 (x86_64-unknown-linux-gnu) libcurl/7.21.3
> >> OpenSSL/1.0.0c zlib/1.2.5
> >> Host: localhost:5984
> >> Accept: */*
> >> Content-Length: 2
> >> Content-Type: application/x-www-form-urlencoded
> >>
> > < HTTP/1.1 409 Conflict
> > < Server: CouchDB/1.0.1 (Erlang OTP/R14B)
> > < Date: Mon, 24 Jan 2011 21:12:04 GMT
> > < Content-Type: text/plain;charset=utf-8
> > < Content-Length: 58
> > < Cache-Control: must-revalidate
> > <
> > {"error":"conflict","reason":"Document update conflict."}
> >
> > to sum it up: couchdb only sends a correct 'document update conflict' on
> > attachments, when you give a rev already in the documents history.
> >
> > have fun
> > martin
> >
> 
> I think more likely its that 12-12345 fails to parse as a correct
> revision and the error gets confused as it bubbles up the stack.
> 
> To verify, try replacing 12-12345 with a modified version of the
> previous revision, ie, so it matches the (\d+)-([a-z0-9]{32}) regular
> expression.



Re: Document update conflict. and attachments

Posted by Klaus Trainer <kl...@web.de>.
As I'm currently unable to beat you to anything due to the large
geographical distance and other people might have the same problem, I
tried to fix the issue and found this patch:
https://issues.apache.org/jira/secure/attachment/12469996/0001-Fix-COUCHDB-1018.patch

- Klaus

On Tue, 2011-01-25 at 11:03 -0500, Paul Davis wrote:
> Yep. Looks like a bug. I'll get to it eventually if no one beats me to
> it. Hint hint.
> 
> On Tue, Jan 25, 2011 at 2:43 AM, Martin Hilbig <bl...@gmx.net> wrote:
> > On 24.01.2011 22:30, Paul Davis wrote:
> >>
> >> I think more likely its that 12-12345 fails to parse as a correct
> >> revision and the error gets confused as it bubbles up the stack.
> >>
> >> To verify, try replacing 12-12345 with a modified version of the
> >> previous revision, ie, so it matches the (\d+)-([a-z0-9]{32}) regular
> >> expression.
> >>
> >
> > i changed the last bit of the revision and still get:
> >
> > {"error":"{not_found,missing}","reason":"{2,<<37,251,126,178,120,66,237,17,97,127,78,134,86,96,12,85>>}"}
> >
> > also klaus is right, i just stumbled upon COUCHDB-1018.
> >
> > have fun
> > martin
> >



Re: Document update conflict. and attachments

Posted by Paul Davis <pa...@gmail.com>.
Yep. Looks like a bug. I'll get to it eventually if no one beats me to
it. Hint hint.

On Tue, Jan 25, 2011 at 2:43 AM, Martin Hilbig <bl...@gmx.net> wrote:
> On 24.01.2011 22:30, Paul Davis wrote:
>>
>> I think more likely its that 12-12345 fails to parse as a correct
>> revision and the error gets confused as it bubbles up the stack.
>>
>> To verify, try replacing 12-12345 with a modified version of the
>> previous revision, ie, so it matches the (\d+)-([a-z0-9]{32}) regular
>> expression.
>>
>
> i changed the last bit of the revision and still get:
>
> {"error":"{not_found,missing}","reason":"{2,<<37,251,126,178,120,66,237,17,97,127,78,134,86,96,12,85>>}"}
>
> also klaus is right, i just stumbled upon COUCHDB-1018.
>
> have fun
> martin
>

Re: Document update conflict. and attachments

Posted by Martin Hilbig <bl...@gmx.net>.
On 24.01.2011 22:30, Paul Davis wrote:
> I think more likely its that 12-12345 fails to parse as a correct
> revision and the error gets confused as it bubbles up the stack.
>
> To verify, try replacing 12-12345 with a modified version of the
> previous revision, ie, so it matches the (\d+)-([a-z0-9]{32}) regular
> expression.
>

i changed the last bit of the revision and still get:

{"error":"{not_found,missing}","reason":"{2,<<37,251,126,178,120,66,237,17,97,127,78,134,86,96,12,85>>}"}

also klaus is right, i just stumbled upon COUCHDB-1018.

have fun
martin

Re: Document update conflict. and attachments

Posted by Paul Davis <pa...@gmail.com>.
On Mon, Jan 24, 2011 at 4:16 PM, Martin Hilbig <bl...@gmx.net> wrote:
> hi,
>
> is this a known bug or even my fault?
>
> create db:
>
> curl -X PUT http://localhost:5984/fail
> {"ok":true}
>
> create doc:
>
> curl -vX PUT http://localhost:5984/fail/doc -d '{}'
> {"ok":true,"id":"doc","rev":"1-967a00dff5e02add41819138abb3284d"}
>
> put attachment with nearly correct format ?rev=x-y
>
> curl -vX PUT http://localhost:5984/fail/doc/att?rev=12-12345 -d '{}'
>> PUT /fail/doc/att?rev=12-12345 HTTP/1.1
>> User-Agent: curl/7.21.3 (x86_64-unknown-linux-gnu) libcurl/7.21.3
>> OpenSSL/1.0.0c zlib/1.2.5
>> Host: localhost:5984
>> Accept: */*
>> Content-Length: 2
>> Content-Type: application/x-www-form-urlencoded
>>
> < HTTP/1.1 500 Internal Server Error
> < Server: CouchDB/1.0.1 (Erlang OTP/R14B)
> < Date: Mon, 24 Jan 2011 21:08:53 GMT
> < Content-Type: text/plain;charset=utf-8
> < Content-Length: 62
> < Cache-Control: must-revalidate
> <
> {"error":"{not_found,missing}","reason":"{12,<<\"12345\">>}"}
>
> shouldn't look this like:
>
> curl -X PUT
> http://localhost:5984/fail/doc/att?rev=1-967a00dff5e02add41819138abb3284d -d
> '{}'
> {"ok":true,"id":"doc","rev":"2-25fb7eb27842ed11617f4e8656600c54"}
>
> curl -vX PUT
> http://localhost:5984/fail/doc/att?rev=1-967a00dff5e02add41819138abb3284d -d
> '{}'
>> PUT /fail/doc/att?rev=1-967a00dff5e02add41819138abb3284d HTTP/1.1
>> User-Agent: curl/7.21.3 (x86_64-unknown-linux-gnu) libcurl/7.21.3
>> OpenSSL/1.0.0c zlib/1.2.5
>> Host: localhost:5984
>> Accept: */*
>> Content-Length: 2
>> Content-Type: application/x-www-form-urlencoded
>>
> < HTTP/1.1 409 Conflict
> < Server: CouchDB/1.0.1 (Erlang OTP/R14B)
> < Date: Mon, 24 Jan 2011 21:12:04 GMT
> < Content-Type: text/plain;charset=utf-8
> < Content-Length: 58
> < Cache-Control: must-revalidate
> <
> {"error":"conflict","reason":"Document update conflict."}
>
> to sum it up: couchdb only sends a correct 'document update conflict' on
> attachments, when you give a rev already in the documents history.
>
> have fun
> martin
>

I think more likely its that 12-12345 fails to parse as a correct
revision and the error gets confused as it bubbles up the stack.

To verify, try replacing 12-12345 with a modified version of the
previous revision, ie, so it matches the (\d+)-([a-z0-9]{32}) regular
expression.