Crashes caused by TimeoutException


#1

Hello,
We just released an application and users report crashes caused by following Exception.

Fatal Exception: java.util.concurrent.TimeoutException
net.sqlcipher.database.SQLiteCompiledSql.finalize() timed out after 10 seconds

java.lang.Object.wait (Object.java)
java.lang.Thread.parkFor$ (Thread.java:1220)
sun.misc.Unsafe.park (Unsafe.java:299)
java.util.concurrent.locks.LockSupport.park (LockSupport.java:158)
java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt (AbstractQueuedSynchronizer.java:810)
java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued (AbstractQueuedSynchronizer.java:843)
java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire (AbstractQueuedSynchronizer.java:1172)
java.util.concurrent.locks.ReentrantLock$FairSync.lock (ReentrantLock.java:196)
java.util.concurrent.locks.ReentrantLock.lock (ReentrantLock.java:257)
net.sqlcipher.database.SQLiteDatabase.lock (SQLiteDatabase.java:553)
net.sqlcipher.database.SQLiteCompiledSql.releaseSqlStatement (SQLiteCompiledSql.java:106)
net.sqlcipher.database.SQLiteCompiledSql.finalize (SQLiteCompiledSql.java:152)
java.lang.Daemons$FinalizerDaemon.doFinalize (Daemons.java:217)
java.lang.Daemons$FinalizerDaemon.run (Daemons.java:200)
java.lang.Thread.run (Thread.java:818)

We use SQLCipher 3.5.9 and Android from 4.4.2 to 7.0.
Is there a way we can avoid those crashes?


#2

Hello @korwinek

Are you using multiple threads to read/write to the database? If so, you might consider using the WAL journaling mode if you aren’t already. More information about WAL can be found here. Also, you could set a busy timeout period which may allow additional time for locks to clear. You can find more info on setting a timeout here.