Document Sync Status


I’m initiating sync for the user after a successful login through our server API and the sync is continuous.

I need to update a document that holds user data once specific actions have been performed on the app.

I am facing a problem where sometimes the doc’s properties get replaced by the new updated properties and all the old properties are lost.

e.g. If my doc has say properties a, b, c, d…z and I update properties c and d, the document seems to have properties c and d only and nothing else.

While I do a null check for the document before trying the update, I think the problem exists because the document hasn’t fully synced yet and an update to that document is causing it to lose all data except for the updated ones.

Is there a way you can determine if the document has been fully synced (pulled) from SG? Does the Replication.IsDocumentPending(Doc) reflect sync status from SG?

On Couchbase Lite 1.4.0 .NET

Looking forward to a response and thanks in advance!

It sounds like the client set properties c and d before the pull replication brought in the initial revision of the doc. Now you have a conflict between the two revisions. Check out our docs on detecting and resolving conflicts.

BTW: A document can’t be partially synced. Revisions are atomic.

hmm thanks. will try this ASAP.

@jens Should the client handle conflicts of this type or should it be done with Sync Gateway?

If the client side doesn’t have the initial revision before updating, I’m guessing it should be done over on the Sync Gateway? If not, how do I go around resolving this on the client side?

I did read the docs but I haven’t quite figured out a way to accomplish it yet.

While Couchbase Mobile will deterministically select a “winning revision”, it is ultimately the responsibility of the app to resolve conflicts because the resolution will very likely be dependent on the app logic . You may be interested in this blog post that discusses the same -

@priya.rajagopal Hi. Thanks for the clarification and the blog post. I did read it and try to implement something for conflict resolution but I don’t think I’m doing it right.

What I did was modify the methods in here and replaced all relevant properties with the properties that my document has.

While I haven’t had many such cases, 1 or 2 so far in numerous instances of running the app, the document that I’m having issues with is quite critical and so I want to resolve it ASAP. I would hugely appreciate any form of help that could lead me to a resolution. Thanks!

Did you follow the steps under ResolveConflicts in From your description of the problem, it looks like you want a n-way merge (also specified in the same .cs file) . If you can share the conflict detection and resolver code that you are using in your application, that will help us understand what you are doing.

@priya.rajagopal Yup, I modified the code in there to match my needs. Should I include every property that the document holds?
Please take a look here and advise me as to if I’m missing something or doing anything wrong.

Yes, you will have to include every property in the PUT including the ones you are not changing.