Unwanted sync causing data corruption

We are running an android app using couchbase lite and couchbase server. We have 2 DIFFERENT android apps with different package names - one live version and one demo version. Both apps connect to two DIFFERENT couchbase clusters through two SEPARATE sync gateways. Suddenly a while back, SOME data from our demo cluster started pooling into our live cluster. This has corrupted our live data.

  • Neither of the sync gateways either connect to or shadow the other cluster’s buckets.
  • The two clusters are not connected on the same network.

These facts eliminate the probability that the interconnection happened from the server or sync gateway side. Only possibility is replication from a client.

  1. Both clusters contain the same data. Basically we created the demo database by taking a copy of the live database. We then proceeded to add the SAME users to the demo cluster sync gateway with SAME usernames and passwords.
    Both apps also create a couchbase lite database with the SAME name (“ABCD”) on the phone to store the data. Could it be possible that a certain client had both apps installed at the same time and due to the database name on the phone being same, data from one app got synced to the other cluster since the replication happens on the database with name “ABCD”?
  2. We haven’t backed up our data using cbbackup. Is it possible to restore our data to an older time?
  3. If not, is it possible to revert ALL documents from the sync gateway bucket to an older revision?

Any help regarding this would be appreciated. Thank you!

Yes. If the database was synced with one server and downloaded the data from it, and then later synced with the other server, it will see that it has docs that aren’t on that server and will upload them. This is correct behavior.

If you have a client that has synced only the production database, you could recreate by syncing from that client back to an empty Sync Gateway database.

Thanks for your suggestion. Sadly we didn’t have that :frowning:

But shouldn’t two different apps have separate data sectors in memory? Even if both apps are creating a couchbase lite database with the same name on the phone, shouldn’t both the databases be saved in different file paths?
Or is there a common memory where couchbase lite databases are stored, and the same memory can be accessed by all apps?

Yes, if these are two separate apps on the device they’ll have separate storage for local databases. I thought you were saying there was a single app that sometimes synced with one server and sometimes with the other.

There is no way to recover old revision data. Sync Gateway is not a version-control system; it does store the revision history, but only stores old revision data for a short while.

Ok. Got it. Thanks a lot! :slight_smile: