Skip to content

SQLiteCompiledSql.finalize() timed out after 10 seconds #335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
g123k opened this issue May 2, 2017 · 7 comments
Closed

SQLiteCompiledSql.finalize() timed out after 10 seconds #335

g123k opened this issue May 2, 2017 · 7 comments

Comments

@g123k
Copy link

g123k commented May 2, 2017

On Android with the latest version of SQLCipher (3.5.7), I have a huge amount of crashs on Crashlytics. It is similar to #313, but happens instead with the SQLiteCompiledSql class.

This is the full stacktrace:

Exception: java.util.concurrent.TimeoutException: net.sqlcipher.database.SQLiteCompiledSql.finalize() timed out after 10 seconds
at java.lang.Object.wait(Object.java)
at java.lang.Thread.parkFor(Thread.java:1205)
at sun.misc.Unsafe.park(Unsafe.java:325)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:
at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:813)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:846)
at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1175)
at java.util.concurrent.locks.ReentrantLock$FairSync.lock(ReentrantLock.java:195)
at java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:256)
at net.sqlcipher.database.SQLiteDatabase.lock(SQLiteDatabase.java:553)
at net.sqlcipher.database.SQLiteCompiledSql.releaseSqlStatement(SQLiteCompiledSql.java:106)
at net.sqlcipher.database.SQLiteCompiledSql.finalize(SQLiteCompiledSql.java:152)
at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:187)
at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:170)
at java.lang.Thread.run(Thread.java:841)
@developernotes
Copy link
Member

Hi @g123k

You might consider setting the PRAGMA busy_timeout to allow more time for the lock to reset. Would you try that and let us know your results? Thanks!

@g123k
Copy link
Author

g123k commented May 5, 2017

I have tried with 30 seconds and I don't know if the settings actually works, because I still have the same issue : net.sqlcipher.database.SQLiteCompiledSql.finalize() timed out after 10 seconds

Requesting the pragma returns a correct value however.

db.rawQuery("PRAGMA busy_timeout = 30000;", null)

@developernotes
Copy link
Member

Hello @g123k

Are you still experiencing an issue? If so, are you able to reproduce it within the SQLCipher for Android test suite?

@developernotes
Copy link
Member

Hello @g123k,

Since we have not heard back, I am going to close this ticket. If you still experiencing an issue we would be happy to investigate this further. Please fee free to open a new ticket and provide supporting information regarding your issue, preferably with a reproducible test case within the SQLCipher for Android test suite. Thanks!

@oleksandr-semenov
Copy link

oleksandr-semenov commented Feb 15, 2021

Having the same issue, stacktrace:

    2021-02-15 13:31:15.099 E/AndroidRuntime: FATAL EXCEPTION: FinalizerWatchdogDaemon
    Process: com.xxx.yyy, PID: 4531
    java.util.concurrent.TimeoutException: net.sqlcipher.database.SQLiteCompiledSql.finalize() timed out after 10 seconds
        at java.lang.Object.wait(Native Method)
        at java.lang.Thread.parkFor$(Thread.java:2127)
        at sun.misc.Unsafe.park(Unsafe.java:325)
        at java.util.concurrent.locks.LockSupport.park(LockSupport.java:161)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer.parkAndCheckInterrupt(AbstractQueuedSynchronizer.java:840)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquireQueued(AbstractQueuedSynchronizer.java:873)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer.acquire(AbstractQueuedSynchronizer.java:1197)
        at java.util.concurrent.locks.ReentrantLock$FairSync.lock(ReentrantLock.java:200)
        at java.util.concurrent.locks.ReentrantLock.lock(ReentrantLock.java:262)
        at net.sqlcipher.database.SQLiteDatabase.lock(SQLiteDatabase.java:570)
        at net.sqlcipher.database.SQLiteCompiledSql.releaseSqlStatement(SQLiteCompiledSql.java:104)
        at net.sqlcipher.database.SQLiteCompiledSql.finalize(SQLiteCompiledSql.java:146)
        at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:222)
        at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:209)
        at java.lang.Thread.run(Thread.java:761)

I tried to reproduce that in unit tests, but I can't emulate all conditions
This happens 100% in our code on Android API 24-25 during concurrent work with DB. We don't have this issue without SQLCipher.
My guess would be that locking DB in finalize is error-prone, since finalize should be quick so that GC can collect data quickly.
Is it something that can be removed?

@developernotes
Copy link
Member

Hello @oleksandr-semenov,

Thank you for your report. We too have been unable to reproduce finalize time out errors within the unit test suite. We plan to revisit the locking mechanics present within the library to evaluate whether removal or augmentation is more appropriate in a future release.

@oleksandr-semenov
Copy link

Hello @developernotes didn't see your reply and opened a new issue for this #537
I've created a synthetic test that reproduces this, maybe it can help to find the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants