[ 
https://issues.apache.org/jira/browse/COUCHDB-1184?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13045205#comment-13045205
 ] 

Paul Joseph Davis commented on COUCHDB-1184:
--------------------------------------------

Tracked it down. Bug is here:

https://github.com/apache/couchdb/blob/trunk/src/couchdb/couch_db.erl#L517

Introduced in:

https://github.com/apache/couchdb/commit/91bf33fdc69c2087707795b8822b0fa7617f8709

Which is the "Deterministic revids, MD5 checking of documents, added tracking 
of rev when an attachment is edited to allow attachment level replication." 
patch from two years ago.

The switching of behaviour when a _design doc is involved comes from the orelse 
clause here:

https://github.com/apache/couchdb/blob/trunk/src/couchdb/couch_db.erl#L718

Notice that a validate_doc_update function would also probably trigger this 
behaviour.


So, this is a weird issue. Apparently there's an assertion that interactive 
edits should not be allowed to provide a rev to start from, but we allow it for 
single (non-design doc) PUTS (in so much as we replace the revision) or in 
_bulk_docs (where the new rev is a derivative).

I guess my vote would be to reject all creations that come with a rev specified 
to keep behaviour consistent. Although, rescuing a doc from deletion *can* have 
a previous revision (and not just a deleted revision) so that's also kinda 
contradictory sorta kinda.

Anyone else have thoughts?



> Bulk insert of design documents fails with conflict if the documents contain 
> "_rev" when they do not exist in the database
> --------------------------------------------------------------------------------------------------------------------------
>
>                 Key: COUCHDB-1184
>                 URL: https://issues.apache.org/jira/browse/COUCHDB-1184
>             Project: CouchDB
>          Issue Type: Bug
>    Affects Versions: 0.11
>            Reporter: Nuutti Kotivuori
>
> First a simple example to reproduce:
> $ curl -X PUT http://localhost:5984/repltest
> {"ok":true}
> $ curl -H "Content-type: application/json" -X POST --data 
> '{"docs":[{"_id":"_design/a","_rev":"1-2f4a8d26d103e914167052aea70a5031"}]}' 
> http://localhost:5984/repltest/_bulk_docs
> [{"id":"_design/a","error":"conflict","reason":"Document update conflict."}]
> So, inserting a previously non-existing design document in to a database via 
> bulk docs post fails the inserted design document has a "_rev" member.

--
This message is automatically generated by JIRA.
For more information on JIRA, see: http://www.atlassian.com/software/jira

Reply via email to