Thanks (again!) Jens, > Do you have any more ideas about how you think this should work? (I will > freely admit that I'm not an expert on CAS.)
Not really I'm afraid! CB-Mobile is actually our first experience with optimistic concurrency. Is the communication between bucket and shadowed bucket push or polled? I.e. How great a window of opportunity is there for an SG revision to overwrite a revision from non-SG code? I had the impression from the CB SDKs that the caller is in-charge of setting up the CAS value with each call (i.e. changing it to some new value each time though I was looking at CB Java SDK 2 which isn't fully documented yet). If the two sides (SG/CB-SDKs) could agree to source the CAS value on the current revision metadata from SG (e.g. most significant long in the UUID) then that could make this easier, though I gather from your comment about needing a 2nd call that I've misinterpreted it? I'll try to find some time to check tomorrow. Thanks, Dan. On 18 Aug 2014, at 16:39, Jens Alfke wrote: > >> On Aug 18, 2014, at 1:35 AM, Daniel McGreal <[email protected]> wrote: >> >> Is it possible to use Couchbase Server's (Java SDK) Check and Set >> functionality with Sync Gateway's bucket shadowing in order to have >> optimistic concurrency on both sides of the application? Essentially this >> boils down to whether SG will respect CAS values when it updates a document >> in CB. I'm particularly interested in CB3 CAS support with Java SDK 2.0. > > No -- the gateway uses a simple Set call without CAS to update the app bucket. > > What you're suggesting, I think, is for the gateway to record the CAS value > whenever it saves a document to the app bucket, and then use a Set-with-CAS > the next time it updates the document; that way if the CAS value has changed > the Set will fail, and the gateway can read the current value from the app > bucket. > > It's been a while since I worked on this code, but IIRC there are two > problems: > > 1. Couchbase Server's Set call doesn't return the new CAS value. So to get > this value we'd have to issue an immediate Get after the Set, which could be > bad for performance (and is subject to possible race conditions.) > > 2. It's unclear what to do if there is a conflict. CAS codes carry less > information than the revision histories that the Gateway and Couchbase Lite > use. The result would be a conflict, but I'm not sure if it would be possible > to add the new version from the app bucket to the revision tree in a > meaningful way. (Hm, it might be. This needs more thought...) > > Do you have any more ideas about how you think this should work? (I will > freely admit that I'm not an expert on CAS.) > > --Jens > > > -- > You received this message because you are subscribed to a topic in the Google > Groups "Couchbase Mobile" group. > To unsubscribe from this topic, visit > https://groups.google.com/d/topic/mobile-couchbase/t5mHKrBR8Jk/unsubscribe. > To unsubscribe from this group and all its topics, send an email to > [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/mobile-couchbase/1A413910-8CAF-4655-B06A-3EDC71809C4A%40couchbase.com. > For more options, visit https://groups.google.com/d/optout. -- 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/318F17E3-3893-4A86-AD48-E1BCEDC4B57E%40gmail.com. For more options, visit https://groups.google.com/d/optout.
