Document reverts to original when deleted


#1

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

Thanks


#2

Is this a peer-to-peer scenario, or are the documents getting synchronized through a server like Sync Gateway?


#3

Its thru sync gateway


#4

I change the document in Device A and let it sync to Device B

Doesn’t it sync to device C too, since they’re all talking to the server?

Can you give more detail about the exact steps? It sounds like there are some important details missing.


#5

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.


#6

Hm, that’s weird. Everything should sync to device C. Are all devices authenticated as the same user with SG?


#7

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.


#8

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.


#9

iOS, CBL 1.3.0

I’ll file it in github.

Thanks


#10

When I hear that it “reverts to original” this makes me think that there are conflicting revisions going on. Are you modifying it locally on device C?


#11

We didnt modify anything on Device C. We left Device C offline and didnt touch anything.