Question

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?

Was it helpful?

Solution 2

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).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top