Hi,
We're in the middle of the development of a tool using Couchbase Server/Sync/Lite (Android/Phonegap), for the classic example of multiple devices replicating through the Sync Gateway. At the moment we're attempting to manage some online/offline revisions of documents and conflicts, but I've hit a wall.
Here's the use case (both Devices on Continuous replication through the Sync to the Server)
- Device A/B online
- Device A creates document 1
- Device A looses network connection
- Documents are replicated to Device B from Sync
- Device B makes new revision of document 1
- Device A, while offline, makes a new revision to document 1
- Device A regains network connection
What I am seeing is the following:
- Server shows three revisions to document 1 - the initial document created by Device A, and the revision created by Device B, and the revision created by A after regaining network (with revision by B "winning")
- Device A and B now have two documents (i.e. document 1) with the same ID. A GET on the document while on the devices returns the same as when on the Server.
- From the devices...
sqlite> select * from docs where docid like '74%';
select * from docs where docid like '74%';
doc_id docid
109 74fc4797-6f93-4fd3-b9af-3701784f3596
sqlite> select * from revs where doc_id = 109;
select * from revs where doc_id = 109;
sequence doc_id revid parent current deleted json
224 109 1-17adec98-d34e-458a-b975-59526bd6c986 0 0 {"test":"123"}
225 109 2-74af32aa-769c-4a6d-b8c2-06a425aafb55 224 1 0 {"test":"999"}
226 109 2-a11653df-6049-4eb0-a00f-9b5abc2111c8 224 1 0 {"test":"707070"}
sqlite> select * from maps;
select * from maps;
view_id sequence key value
1 225 74fc4797-6f93-4fd3-b9af-3701784f3596 {"test":"999"}
1 226 74fc4797-6f93-4fd3-b9af-3701784f3596 {"test":"707070"}
Map function
function(doc) {
emit(doc._id, {
test: doc.test
});
)
Changes feed:
{"seq":"public:365","id":"74fc4797-6f93-4fd3-b9af-3701784f3596","changes":[{"rev":"2-74af32aa-769c-4a6d-b8c2-06a425aafb55"}]} ,{"seq":"public:366","id":"74fc4797-6f93-4fd3-b9af-3701784f3596","changes":[{"rev":"2-a11653df-6049-4eb0-a00f-9b5abc2111c8"}]}
If I run that view on the CB Server through the UI - I am just returned the single document, but on the devices, it returns both.
Can anyone explain to me what is happening here? I have the feeling I may be missing or confusing something fundamental with either the Sync Gateway, the Changes feed sequences perhaps, or even the View map function.
Would I be correct in saying that this is might be expected functionality? And that I need a Map function on the devices to get these conflicts and let the device user determine how to resolve?
(Lastly, I'd like to thank the Couchbase guys involved with the development of the product and support provided through here, both are really excellent.

)
Thanks.