3

We are currently developing an iPhone app with Xamarin's monotouch and use SQLite to store data. We use the latest version of the SQLite-component (https://github.com/praeclarum/sqlite-net).

Unfortunately, we had some strange problems in the last few weeks. Everything works as designed, but after a while (between maybe 15-30min tracking, which generates GPS inserts into the database), the SQLite returns every database access with an I/O error:

SQLite.SQLiteException: IOError

Disk space was available, also R/W-rights for the file were not the problem, because the first 30min everything worked...

So after a long Google research, I think the reason might be the same as here:

CoreData: error: (14) I/O error for database

Maybe also this issue here is related: Sqlite disk I/O error on iphone 5

As a workaround, we now deactivate the WAL (http://www.sqlite.org/wal.html) with setting the journal_mode = OFF (http://www.stevemcarthur.co.uk/blog/post/some-kind-of-disk-io-error-occurred-sqlite/), but it's not the proper solution.

Which leads to my question: Is somebody out there who's got the same problem and found a real solution? And is my assumption correct that WAL with iOS 7.0 causes this problem? Or might there be another reason?

Community
  • 1
  • 1
Ursin Brunner
  • 2,310
  • 1
  • 24
  • 24
  • I have the same problem however I haven't had any luck setting the journal_mode to OFF. I tried var cmd = _connection.CreateCommand ("PRAGMA journal_mode = OFF"); cmd.ExecuteNonQuery (); w/o any luck, I get a SQLite exception. Any help would be much appreciated. – Raciel R. Feb 26 '14 at 20:56
  • 1
    string pragma = "PRAGMA journal_mode = OFF"; SQLiteCommand cmd = this.CreateCommand(pragma); string result = cmd.ExecuteScalar(); – Ursin Brunner Feb 27 '14 at 18:57
  • 1
    Thanks @u_b, I got this working early this morning by using ExecuteScalar. However, setting journal_mode to OFF didn't fix my problem. I tried querying the default journal_mode and it is "delete" instead of "wal" which is supposed to be the default in iOS 7.0 (https://developer.apple.com/library/ios/releasenotes/DataManagement/WhatsNew_CoreData_iOS/) After I set it back to wal, it works as expected. I'm confused and not sure what is going on here. I'm posting on xamarin forum and will submit a support ticket too. Thanks a ton! – Raciel R. Feb 27 '14 at 19:48
  • Just posted it here: http://forums.xamarin.com/discussion/14083/sqlite-net-i-o-errors-in-when-the-app-is-in-the-background – Raciel R. Feb 27 '14 at 20:53
  • @RacielR. lets discuss it in the xamarin forum and post a solution here if we find one :-) – Ursin Brunner Feb 27 '14 at 23:37

0 Answers0