couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Couchdb Wiki] Update of "Replication_and_conflicts" by BrianCandler
Date Sun, 01 Nov 2009 11:09:39 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for change notification.

The "Replication_and_conflicts" page has been changed by BrianCandler.
The comment on this change is: Example view which finds conflicts.
http://wiki.apache.org/couchdb/Replication_and_conflicts?action=diff&rev1=4&rev2=5

--------------------------------------------------

  
  == View API ==
  
- Views also only get the winning revision of a document. However they do also
+ Views only get the winning revision of a document. However they do also
  get a _conflicts member if there are any conflicting revisions.  This means
  you can write a view whose job is specifically to locate documents with
- conflicts.
+ conflicts. Here is a simple map function which achieves this:
  
+ {{{
+ function(doc) {
+   if (doc._conflicts) {
+     emit(null, [doc._rev].concat(doc._conflicts));
+   }
+ }
+ }}}
+ 
+ which gives the following output:
+ 
+ {{{
+ {"total_rows":1,"offset":0,"rows":[
+ {"id":"test","key":null,"value":["2-b91bb807b4685080c6a651115ff558f5",
+ "2-65db2a11b5172bf928e3bcf59f728970","2-5bc3c6319edf62d4c624277fdd0ae191"]}
+ ]}
+ }}}
+ 
- If you do this, you can have a separate "sweep" proces which periodically
+ If you do this, you can have a separate "sweep" process which periodically
  scans your database, looks for documents which have conflicts, fetches
  the conflicting revisions, and resolves them.
  
@@ -283, +300 @@

  properly, and this will introduce odd behaviour which will be hard to track
  down.
  
+ Couchdb's "winning" revision algorithm may mean that information drops out
+ of a view until a conflict has been resolved. Consider Bob's business card
+ again; suppose Alice has a view which emits mobile numbers, so that her
+ telephony application can display the caller's name based on caller ID. If there
+ are conflicting documents with Bob's old and new mobile numbers, and they
+ happen to be resolved in favour of Bob's old number, then the view won't
+ be able to recognise his new one. In this particular case, the application
+ might have preferred to put information from ''both'' the conflicting
+ documents into the view, but this currently isn't possible.
+ 
- == Suggested code for fetch with conflict resolution ==
+ == Suggested code to fetch a document with conflict resolution ==
  
  Pseudocode:
  {{{

Mime
View raw message