I am converting Room’s test suite over to test my CWAC-SafeRoom bridge between Room and SQLCipher for Android. On the whole, things are going well. However, I’m having trouble getting one test working and was wondering if there’s a known scenario that might explain what’s going on.
As part of Room’s
WriteAheadLoggingTest, they have a
readInBackground() test method that includes the following:
- Begin a transaction
- In that transaction, delete an existing row from a table
- With that transaction still open, start a background thread
- In that background thread, against the same
SQLiteDatabaseobject, perform a query to retrieve the to-be-deleted row without an explicit transaction
- Block the first thread waiting for the second thread to complete its query
- Commit the transaction
The test works fine when tested against the framework SQLite implementation. With SafeRoom and SQLCipher for Android, the read thread blocks indefinitely. My guess is that the reader thread is blocked by SQLCipher waiting for the transaction to be committed.
However, WAL mode is enabled, insofar as
PRAGMA journal_mode; returns
WAL (I’m using
equalsIgnoreCase()). WAL mode would have been enabled before the bulleted list shown above begins, and I am testing if WAL mode is enabled during that transaction. If my understanding is correct, WAL mode should allow readers to not be blocked by writers, and so I’m not sure why I’m seeing the reader thread be blocked.
Is there some known issue here that I can address?