Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CouchDB _design document conflict detection

Tags:

couchdb

I am aware that CouchDB identifies documents that are in conflict after replication. Does CouchDB handle conflict detection differently for _design documents than it does for regular documents? For example, I modify a _design document in DB1. I then modify the same _design document in DB2. I then replicate DB1 to DB2. I would expect that CouchDB identify a conflict, however after replication, Couch returns no conflicts.

like image 949
JimZ Avatar asked Oct 12 '22 11:10

JimZ


1 Answers

Design documents are exactly like normal documents, hence the name "design documents" instead of "couch programs" or such.

If you make identical modifications to identical documents in different databases, you will have no conflicts. Running couchapp push could create this situation, if you push the same app to two different databases (and they had the same _rev to begin with).

Otherwise, you will get a conflict, whether design document or no. Of course, couch will "promote" one revision as the canonical version, but if you check for _conflicts in a view, you will see them. (To see design documents in a view, you must also enable the include_design option.)

{ "_id": "_design/example"
, "views":
  { "conflicts":
    { "options": {"include_design": true}
    , "map": "function(doc) { if(doc._conflicts) emit(doc._id, doc._conflicts); }"
    }
  }
}

Find conflicting ddocs using a key range scan:

?startkey="_design/"&endkey="_design0"
like image 144
JasonSmith Avatar answered Oct 17 '22 23:10

JasonSmith