I have a problem where a document reverts back to its original when it gets deleted from another device
This is the scenario.
Say I have 3 devices: A, B and C
All 3 devices contains a document which is in sync.
I change the document in Device A and let it sync to Device B
I then delete the Document from Device A.
Result:
Device B will delete the document
But Device C will still contain the document
We are testing a case where a user could have 3 devices.
We purposely did not open the app on Device 3 when Device A made a change to the document. This could happen in real life scenario.
So here’s the steps again in more detail.
Device A, B and C are connected and linked to Sync gateway. All data is in Sync
Device A creates a new document called Doc-Rev1. Device B and C is opened and connected, both device see Doc-Rev1
We now close Device B and C. Leaving A on and online.
Using Device A, we change the document to Doc-Rev2.
Now we open Device B and let it talk to sync gateway. Device B gets Doc-Rev2. Device C is closed and is offline still.
Device A and Device B is both opened and talking to sync gateway still
Device A deletes the Doc. Device B is synced up and deletes the Doc too.
Now we open Device C. Doc-Rev1 remains on Device C
What we noticed is that during any revisions/changes to a document, if not all devices are synced up to every revision, the document will remain on some devices when the document gets deleted.
Yes, all devices are using the same authenticated user with SG.
Here’s more scenarios that we tried.
Device A creates Doc, Device B and C syncs and gets this Doc
Device A updates the Doc, Device B and C is offline and does not grab this revision
Device A deletes the Doc, Device B and C comes online, both Device deletes Doc
Device A creates Doc (Rev1), Device B and C syncs and gets this Doc (Rev1)
Device A updates the Doc (Rev2), Device B comes online and Syncs this Doc (Rev2). Device C is still offline
Device A updates the Doc (Rev3) again, Device B is online, syncs and Doc (Rev3) is up to date. Device C comes online too and the Doc (Rev3) on Device C gets up to date.
Device A deletes the Doc. Doc is deleted on Device B but on Device C, Doc gets reverted back to (Rev1)
From what we observe, if the devices are up to date with every revision, the document will sync correctly even when it is deleted in the end. But if a device misses one revision and the document is deleted, the document reverts back to the last revision that was available on that particular device.
What platform/version of CBL is this?
You should file an issue against the appropriate repo on Github, including those steps, and ideally a snippet of code showing how you create/update the doc on device A.