on 2014 Nov 10 1:49 PM
Hello everyone,
I have an Android method that runs in background performing some DML executions. However, if the device "Moto G" is put in sleep (I could not reproduce this error in any other device), after some minutes the Ultralite starts to thrown the following error for every single SQL execution in the opened connection:
Error[-305]: I/O error 200020 [Interrupted system call,0,312]
Any ideias what is going on?
I've been trying to get a solution for this, but I actually have no idea what to do next.
Finally I found the solution. To avoid the device is put in sleep we must implement an Android WakeLock:
PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
WakeLock wakeLock = powerManager.newWakeLock(
PowerManager.PARTIAL_WAKE_LOCK, "MyWakelockTag");
wakeLock.acquire();
// Do some heavy DML executions in background
wakeLock.release();
That is enough to get rid of the I/O UltraliteJ errors.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you for posting the solution, Alex!
A WakeLock is a good approach for keeping the device awake for a short time while a critical task is happening.
In general, we recommend that when your Activity is Paused or Stopped, you commit or rollback UltraLite connections and disconnect them. Then, when the Activity is Resumed, you renew the connections. This coincides with Google's recommendations on managing the Activity lifecycle (see http://developer.android.com/guide/components/activities.html#Lifecycle).
Apparently the write system call is returning an error because the device went to sleep. UltraLite is interpreting this as a file system failure and locking the database. (To recover, you must disconnect and reconnect to the database. When the database restarts, it will automatically recover to the last commit.)
One solution could be to keep the device awake while the DML is running. Another could be to make your background code robust to the sleep/error by continuing from the last commit. Whether UltraLite could safely retry this call internally (i.e., a bug fix) will require some research.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
71 | |
11 | |
11 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.