I just remembered a likely cause of this, that I think has happened before. You 
may have a conflict in the document that can't be deleted. That is, a client of 
the Sync Gateway may have changed the document at about the same time that the 
document in the original bucket was changed.

When a document's in a conflicted state, the gateway determines a 'default' or 
'winning' revision, and that's the one that will get written back to the 
shadowed bucket. Live revisions take precedence over deletions, so the document 
will still exist in the bucket.

An example:
Doc is created in the Couchbase bucket
Gateway imports it, assigns it revision 1-abcd
Client app syncs with the gateway, downloads that revision
Offline, client app modifies the document creating revision 2-bcde
Your Couchbase app deletes the document in the bucket
Gateway notices the deletion, adds a deletion/tombstone revision 2-dbef to the 
database
Client app syncs back to the gateway, adding revision 2-bcde to the gateway's 
database
The document in the database is now in conflict. The default revision is 2-bcde 
which is not a deletion
Revision 2-bcde gets written back to the original bucket

The moral is to check for conflicts. You have to do so in the Gateway's 
database since Couchbase Server itself has no notion of conflicts so there's no 
way to tell whether a document in a 'normal' bucket has one. Then you can use 
the Gateway REST API to resolve the conflict and add a merged revision if 
necessary.

--Jens

-- 
You received this message because you are subscribed to the Google Groups 
"Couchbase Mobile" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mobile-couchbase/E2349468-20D1-4F8C-818E-0CF6E4096FD2%40couchbase.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to