Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 75885

Sqlite transaction timeout failure in Xamarin.Forms app running on iOS device

$
0
0

I have a Xamarin.Forms app being built for iOS and Android that uses sqlite for data storage. In the iOS version, we call directly into the sqlite APIs instead of using something like system.data.sqlite. We set all our read/write database connections to WAL journaling using PRAGMA journal_mode='WAL' and set a busy timeout of 10 seconds using sqlite3_busy_timeout(db, 10000);. But when running on the device, when two transactions overlap, we get instant failure (i.e. the statement fails with SQLITE_BUSY) with no timeout.

I've tried setting the busy timeout with the equivalent pragma statement, and I've tried retrieving both the journal mode and timeout values after setting them to confirm they're sticking. They are.

I've tried two main ways of debugging this.

The first is to build an updated sqlite version from source myself and link against it as described here. But the build process insists on linking against the sqlite version built into iOS. I tried changing the name of the sqlite3_libversion method to sqlite3_libversion_ot in my sqlite source in case it's finding duplicate names in my framework and the system's and preferring the system's, but when I call it I get a runtime exception of System.EntryPointNotFoundException: sqlite3_libversion_ot.

The second is to use the sqlite error log in the hope that it'll spit out either an explicit reason why it's not using its timeout or some other message about something funky with the database connection. But because sqlite3_config uses va_args, it's very difficult to call into it from C#. If anyone can show me how to set up the sqlite error log from C#, it would be much appreciated.

So the question: has anyone had similar issues with transaction timeouts with SQLite and Xamarin / Mono before? If not, can anyone help with either of the two debugging approaches mentioned, or suggest other ideas?


Viewing all articles
Browse latest Browse all 75885

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>