The post is long but believe me it is worth reading and help full.
We have around 48000 documents and around 5000 images (thumbnail only). We need to sync this data in the CBL and then we can let the app be usable. For the first time it takes a lot of time. So to over come this I have made a java app which keep synced with he sync gateway. This App does lot of things like conflict resolution, populate data with views and put the CBL files at a location.
After every 3 minutes the replication is stoped and a zip file is created and put on a location. After creation of the Zip file the replication starts again.
Then I have created a web service which provides the zip file to the app when a call is made. The zip is a mere around 20 Mb which downloads in seconds and data is there which previously used to take 10-20 minutes.
All is good here and once its all sorted out I would like to share it with the community.
Now I have following issue : -
When the server side java app syncs data, it inserts PrivateUUID, PublicUUID and check points in the info table of SQL lite which is used by CBL.
Whenever the app starts it makes hundreds of call of _rev_diff which can be seen in fiddler, these calls eventually slows down the app launching time because the one shot is running, even all the latest data is synced and no new sequence number is generated on the server.
This happens every time on the clients but not on the server. May be due to PrivateUUID, PublicUUID and check points.
If this happens only once in, continuously killing and launching the app I can live with it.
Further R&D points I can make is to delete the data from info table of above mentioned point. then the call of local document to the sync gateway for each app will have different ID. And _rev_diff call will happen only once. But is there a built in system to do so? May be a method or something else. Else I would have to do it directly in the SQL Lite.
Or is there something else I can do. Or is there a better solution then this available or I can create?
I deleted data from info table other then pruned key. And when the app runs for the first time it creates privateUUID, publicUUID , last_optimized and checkpoint data. After the first successful run _revs_diff call doesn’t happen.
Are you using the API call to install a database file? This call updates the database’s UUIDs to unique values, which is important to avoid checkpoint conflicts on the server.
Whenever the app starts it makes hundreds of call of _rev_diff
This happens because the client- and server-side checkpoints conflict or don’t exist. (The problem I mentioned above.) To ensure consistency, the client has to compare all of its doc/rev IDs with the server to see if they match and to pull any new ones; that’s the purpose of all those rev_diffs calls.
This happens every time on the clients but not on the server.
Yeah, your clients must not be updating their database UUIDs. This causes them all to store their checkpoints under the same docID on the server, so they’re constantly overwriting each other and creating conflicts. You need to use our API call to install the downloaded database file.
I was filling database using a Java app which works as a client. Not with Rest API. Its more like one App giving the complete database backup to other. And overwriting checkpoints of each other. Hence before I can distribute this to Apps now I delete the UUIDs, and check point values from info table this does give call of _revs_diff once per client and then not on any future launch. and solves my issue.
I don’t mean on the server side. I mean on the device when you download the zipped database and install it. You have to use the Database method to install a db file; you can’t just copy it over using filesystem calls.
now I delete the UUIDs, and check point values from info table this does give call of _revs_diff once per client and then not on any future launch. and solves my issue.
Please don’t edit internal stuff in the database. Use our API call.
I do use Database Method to install db file in the App after downloading Zip.
Is there an API call to change the UUID and checkpoint data through API call. Because its more like one app device has given CBL zip to other device to use it in the app. We are doing it because downloading a zip is faster then downloading all documents. Now both devices will be using same UUIDs so I am editing internal stuff, so they cant overwrite checkpoints of each other. If there is way to do it by API call I will be happier then ever.