Server-side sync conflict resolution

Hi,
If I understand correctly, the philosophy of Couchbase sync conflicts resolution is to always resolve it on device. I would like to know if it’s possible to have the conflicts resolution on the server side? So an example scenario would be:

  1. Device initiates the sync and sends all his changes to the server
  2. Server deals with the conflicts and creates updated revision
  3. Device receives and accepts all incoming changes (the newest revision, with all conflicts resolved)

Is this scenario possible? If so, what would be the best way to implement it?

Best Regards,
Krzysztof Zabkowski

Hello @krzysztofZabkowski,

You could add a listener to the changes feed with the querystring ?include_docs=true&conflicts=true.
Then use the _bulk_docs endpoint to save the resolution to SG (by deleting the conflicting revisions).

“Once you have retrieved all the conflicting revisions, your application can then choose to display them all to the user. Or it could attempt to merge them, write back the merged version, and delete the conflicting versions - that is, to resolve the conflict permanently.
As described above, you need to update one revision and delete all the conflicting revisions explicitly. This can be done using a single POST to _bulk_docs by setting "_deleted" : true on those revisions you wish to delete.” from http://wiki.apache.org/couchdb/Replication_and_conflicts#Single_document_API

James

Hi,

I tried the Solution you suggested with the _bulk_docs on Server-Side, and the old Revisions get the _deleted=true
When i delete the current revision afterwards, no old revision becomes active, so this is working as expected.

BUT: After the bulk_docs, the old Revision becomes updated too and still exists. If I run my tool again on the same ID, it will find both the revisions again and act as if it was a conflict. Is the right approach to just ignore conflicts when all other Revisions are deleted? I don’t like this, because it might be possible that the document SHOULD be deleted.

Is it just a matter of time until the old revisions get purged? Does this have to be initiated by the client? I can’t initiate the purge on a document from serverside, there I get a FileNotFoundException.

Thanks in advance