> On Oct 23, 2014, at 2:12 PM, Christoph Berlin <[email protected]> wrote:
> 
> My question would be whether it is save to assume that I could technically 
> create two documents with the same ID on two different offline devices and 
> Sync Gateway will try to clean up the mess?

Yes. Actually it's not the Gateway doing anything special. It's just that, in 
any database, an attempt to get the current contents of a conflicted document 
follows the same algorithm where one revision is picked as the winner. Once 
both devices are in sync, they have the same revision history of that document 
so they'll pick the same revision as the current one.

> If so how do I protect my data logic from running into that problem? Meaning 
> there is a reason that I usually cannot create the same document ID twice but 
> in this scenario it bypasses that check.

The client API tries to prevent conflicts when it can, by returning a 409 error 
if your change would create a conflict with another revision in the local 
database.
But in the general case, conflicts can't be prevented because this is a 
distributed system. (In terms of the CAP theorem, we've sacrificed Consistency.)
So there are two different manifestations of conflict handling — one where you 
get an error before the conflict would happen, and another where the system 
tries to deal with a conflict that already exists.

—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/5BC4914C-555E-470D-80ED-0EF1F1EBBEAA%40couchbase.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to