4

I have quite a lot of customers getting the exception mentioned in the title, but i can't reproduce it on any of my devices.

Bug Reports seem to suggest that the error happens only on Sony devices, but i can't seem to find any reports of Sony doing anything funny with their databases on Android.

The code that triggers this exception is ending a transaction

db.beginTransaction();
for(some iterator)
    db.execSQL("UPDATE table SET column = " + value + " WHERE other_column = " + something);
db.setTransactionSuccessful();
db.endTransaction();

The stacktrace from here is:

android.database.sqlite.SQLiteDiskIOException: disk I/O error (code 1290)
at android.database.sqlite.SQLiteConnection.nativeExecute(Native Method)
at android.database.sqlite.SQLiteConnection.execute(SQLiteConnection.java:559)
at android.database.sqlite.SQLiteSession.endTransactionUnchecked(SQLiteSession.java:437)
at android.database.sqlite.SQLiteSession.endTransaction(SQLiteSession.java:401)
at android.database.sqlite.SQLiteDatabase.endTransaction(SQLiteDatabase.java:530)

The database resides on external storage (but according to customer reports it happens when the external storage is mounted):

SQLiteDatabase db = SQLiteDatabase.openDatabase("/path/to/sqlite", null, SQLiteDatabase.NO_LOCALIZED_COLLATORS);

Please don't be too harsh about the code, I know that (for instance) there should be a try/catch around the sql statements with endTransaction being in finally, but it would make no difference in this case (and I don't get the resources to clean this legacy mess up at the moment).

I found some old reports about SQLITE_IOERR_DIR_FSYNC on AIX, where fsync() on directories was not supported, but that didn't really help me since i obviously cannot recomplie SQLite with the correct compiler flags on Android...

Any Ideas?

Pontomedon
  • 937
  • 9
  • 18
  • Did you tried to reproduce the bug on the same sony device at your end on which the customer reported the bug? – user_CC Mar 18 '13 at 09:20
  • No, unfortunately I don't have access to any Sony device, and i can't reproduce it on any of the devices I can test on (Samsung Galaxy 1&2, Nexus S, Nexus 4, several Samsung Tablets and a 7" Kindle Fire HD); in fact the bug did not happen a single time for me... – Pontomedon Mar 18 '13 at 09:53
  • Ok I can get my hands on a SE device if you forward me your APK I can try it...? – user_CC Mar 18 '13 at 09:58
  • Thanks a lot, i built an apk with extra-verbose logging, how can i send it to you? SO doesn't have private messaging, right? if nothing else you can contact me at at gmail. Thanks again! – Pontomedon Mar 18 '13 at 15:47
  • mystackoverflowPontomedon is this right? – user_CC Mar 18 '13 at 16:37
  • ah sorry for the delay&confusion, just saw it - it's just pontomedon before the @ :) – Pontomedon Mar 19 '13 at 06:20
  • Can you tell which app and which exact model this is happening? – auselen Mar 19 '13 at 07:43
  • I have reports from xperia t (4.0.4, 4.1.2), xperia z (4.1.2) and xperia v (4.1.2), and one report that it works on an xperia s with 4.0. If you contact me (email see previous comments), i can send you an APK to test. – Pontomedon Mar 19 '13 at 08:06
  • May be you can stop by at chat room http://chat.stackoverflow.com/rooms/26442/sqllite-android-issue-http-stackoverflow-com-questions-15471851 – auselen Mar 19 '13 at 08:49
  • @Pontomedon Tried on Xperia P and it works...didn't get any crash – user_CC Mar 20 '13 at 13:54
  • user_CC: what android version are you running on the P? – Pontomedon Mar 21 '13 at 13:52
  • @Pontomedon The only reason I can think of is, Android is ported on many different hardware, and sometimes not completely. For example on samsung devices locationlisteners dont return. So its possible that the implementation of android on sony is not complete. You should log a bug with Sony and track it with them. Dont assume that its your issue (may be, but not necessary). I suggest handle the exception (if its not on ALL sony devices). But please do get a hold of a sony device. If its happening on all devices you have a huge problem. – Siddharth Apr 19 '13 at 16:26

2 Answers2

0

Try this patch, it looked something related with

https://android.googlesource.com/platform/external/sqlite.git/+/6ab557bdc070f11db30ede0696888efd19800475%5E!/#F0

biAji
  • 44
  • 2
0

This was a bug in Sony's sqlite build, i reported it to them and got notification that they fixed it. unfortunately the bug is still out in the wild - but i can safely be ignored, the transaction is in fact completed successfully (one of the last calls sqlite does - an fsync on the directory containing the database - fails, but it doesn't seem to be necessary anyway).

Pontomedon
  • 937
  • 9
  • 18