-
Notifications
You must be signed in to change notification settings - Fork 126
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CB Lite on Android Xamarin fails to replicate when local DB is large #742
Comments
here's a more verbose log for this problem. Note the state machine error at 17:19:12.728: CB Lite fails to push when local DB is large ADM log verbose.txt |
That error is not related to the size of the database. What version of Xamarin are you using? |
using Xamarin 23.3.0 |
I cannot upgrade to 23.4.0.1 for the Xamarin support packages, due to a constraint from Xamarin.Forms. I am using the newest Xamarin.Forms (2.3.2.127) which has dependencies on the Xamarin.Android.Support.* packages. It required exactly version 23.3.0 of the support packages. |
I am using the current stable Xamarin VS2015 extension (4.2.0.680) on VS 2015 Pro. |
No luck with the current Beta Xamarin (4.2.0.694). I am targeting a Nexus 5X on Android Nougat. Is N supported by couchbase-lite-net? My app shows popup warnings about libsqlite.so not being accessible. |
Interestingly, the push sync of the 200K doc database does work now, but very slowly. It could be that my Xamarin version upgrades improved the situation, or maybe I am giving it more time to do the sync. In any case, the push replication remains at ChangesCount 0 for several hours, and then the sync of a few hundred new docs happens relatively quickly. |
With regards to sqlite, Android N made the decision to disallow native library access to system libs installed on Android (one of which is sqlite). On CI, there is a now a "custom sqlite" storage engine which uses a bundled version of sqlite and going forward on Android it will need to be used. That doesn't likely have anything to do with this issue though. Several hours is not acceptable and something else is going on. Do you think you could run this in a debugger and pause while it is blocked and see how many threads are there and what they are doing? Also keep an eye out for how much garbage collection activity there is. |
I'm running the same application on a virtual Android M device. That instance has a much larger database (>800K docs). It does not have the slowness issue. So, you are correct, it is not a size issue. I will report thread counts and GC activity from Android Device Monitor tomorrow. |
@borrrden, I hope this helps: 09-27 08:32:22.592: I/mono-stdout(12082): INFO) DATABASE (Database): [6] 2016-9-27 08:32:22.591-07:00 Database[/data/user/0/com.biotronik.BTLEPerfTestXaPortable/files/.local/share/btlelog1.cblite2] posting change notifications: seq [616595] |
@borrrden, some heap and thread stats: |
That error message is something I am seeing from other reports as well and I fear its meaning. It seems to indicate that what I am doing to get socket timeout settings on Xamarin mobile platforms is not valid. It looks like either I'll have to abandon the socket timeout setting or convince Xamarin to ship the WebRequestHandler dll with the mobile profiles. |
Ok, I pushed up some changes to |
@borrrden, thank you for looking into this issue. I managed to build issue/#742 and run it on the problematic database where push repl is very slow. I debugged through Batcher.QueueObjects. It tries to add 117000 objects to _inbox which gets progressively slower. The first few thousand objects get added within a few seconds, but after adding 25000 objects it takes more than 20sec to add the next 1000. I hope this helps to track down the issue. Let me know how I can help further. |
What about the logs? Do you see any errors in them? |
P.S. This replication is not going to be quick. A database of this size is potentially 500MB+ in size. With your phone's network conditions, how long do you think it will take to upload a 500MB file? That's something to keep in mind. Replicating from scratch will need to send quite a lot of data. I'm currently in the process of generating a database with 1,000,000 entries to test and even generating it takes a few minutes. |
I'll look at logs in more detail. For some reason my debug build wasn't On Sep 28, 2016 6:02 PM, "Jim Borden" [email protected] wrote:
|
Actually, I've found the source of the problem, I'm pretty sure. I am working on a fix now but Android is always a gigantic pain because the debugger is a pain in the ass that crashes quite a bit and for some reason Xamarin Studio is being even more unreliable than usual...so it might not get done today. |
Great news. |
I take your point about limited mobile bandwidth. In my estimation a 2G cell connection with 100kBits/sec should be enough on average to push my application data to sync gateway. I use VisualStudio Android emulator to verify this. It can simulate slow connections with packet drops. |
Great, if nothing else comes up I am going to have another look at this today. Xamarin Android 7.x seems to be giving me issues so I've rolled back, and hopefully Xamarin will remain stable while I try to do some more testing. The ultimate issue is deduplication. The string comparison operation gets much slower as the size of the inbox grows since it checks the entries to ensure that it is not already added which causes a linear search of the inbox. I'm trying to coax it to run prematurely to start draining the inbox but that causes the problem of it thinking it is finished too soon. There is one other way I need to try as well. |
Ok at the expense of a slight increase in memory I've made the deduplication O(1) instead of O(n) and the results are immediately evident. I was able to add 1,000,000 items to the inbox in a matter of seconds. The replication itself is still a long process though (it's been going for about 10 minutes and finished ~200k). It's going to be much slower than that on a 100 kilobit / sec connection (kiloBIT? As in maximum 12.5 kiloBYTES per second? At that rate sending a 600 MB file would take no less than 13 1/2 hours) EDIT I pushed the changes to the issue branch |
@borrrden Hello. I have same problem. Can you send fix in http://latestbuilds.hq.couchbase.com/couchbase-lite-net/1.3.1/? |
@borrrden, Hi Jim, However, I still have problems, which I'll post in the forum. Then you can decide if they are related to this issue, or not. See https://forums.couchbase.com/t/lastsequence-remains-constant-across-many-push-replications/10218 Thanks. |
@rotorgames I won't be making a patch onto 1.3.1. This fix is currently targeted for 1.5 but I'd like to get it into 1.4 instead since it is a severe performance regression. |
@borrrden What version I need use that I will not get this error now? |
@rotorgames You will need to build it yourself from the issue/742 branch. If I get this moved to 1.4 then I will let you know because it will go into a CI build. |
@borrrden Hi. I compiled and tested issue/742 branch and I have new error: Galaxy s4
P.S. Error is in Replication.cs:1886. I catch value of LastSequence. It was "477:422". |
@rotorgames Filed this as #757 |
Alright, issue/742 will be merged into master soon and will be in 1.4 |
@borrrden Good news. Please tell me when you do it. |
@borrrden Hello. Any news? |
This will be done by the end of this week (and likely tomorrow) |
@borrrden Ok. Thx |
@rotorgames @rainerg2000 FYI this fix introduced a regression in one of our functional tests. It's a really hard case to hit as it requires a lot of updates from multiple clients to a sync gateway instance on the same set of documents but I have fixed it up while maintaining the performance changes. See the above commit. |
In regard to this Forum thread:
I am using CB Lite 1.3.1 on Android in a Xamarin-based application. The application logs about 1 small data item per second into Couchbase. It also updates a few documents about once per second.
I am using SQLite as a storage engine for CBLite. I am using Sync Gateway to replicate the database to Couchbase Server.
When the local database reaches a size of 100K-200K docs (100-200 MBytes) the push replication fails to start. I am using a non-continuous push replication. Its Status property is 'Active', IsRunning is true, ChangesCount is 0, CompletedChangesCount is 0.
For this replication the Sync Gateway log shows some activity. But I think it's from a pull replication and not from this push, that seems to get stuck.
Attached is the Android Device Monitor log filtered to tag:mono. Around 15:10:10 the push replication begins. Attached is also the log from sync gateway.
CB Lite fails to push when local DB is large ADM log.txt
CB Lite fails to push when local DB is large SG log.txt
The text was updated successfully, but these errors were encountered: