Re-installing app doesn't create database from scratch

Hi,

We are using couchbase lite & sync gateway in version of 2.6. Due to some problems, we needed to create a new bucket in a new vm. By the way, we haven’t change the sync gw configuration file, briefly everything remained same except the ip address of the sync gateway. Of course, we released a new mobile app by including this minor change.

However, when we checked the server, we noticed that some old data replicated to our new bucket. Our mobile developer stated that actual lite database might not be cleaned up at all (AppData folder couldn’t be deleted). In brief, our database corrupted with undesired data which is belong to past.

Note: We are developing for both UWP & Android and we saw that this issue happens only in Android.

Hi @glenn.
We are going to need some some more specific information, in order to analyze this issue.

If:

  • the new application has the same (package) name as the old app
  • the old app wasn’t specifically uninstalled from the device
  • the new app opens a db with the same name as the db opened by the old app

… then the new app is opening the old database and, if it is running a replicator, syncing it to the server.

If that is not what is happening in your case by all means respond. It would be very useful if you could provide a step-by-step scenario that would let us reproduce the problem

Probably a side effect of the way the replicator works. On the first sync with the new bucket, the client replicator will treat this as a new replication (because the URL is different), so all docs on both sides will be examined. In particular, docs on the client side that don’t exist on the server will be pushed to the server.

To prevent this, you’d need to either ensure that the client-side database is erased during the transition, or configure your SG sync function to reject the invalid old documents.

Edit: I wrote “because the URL is different”, but you actually said “the IP address is different”. If the URL is unchanged, that won’t trigger a re-sync. However, if your new bucket starts out empty, that definitely would, since the replicator would detect that its previously saved checkpoint on the server is missing.