Android-Debug-Database icon indicating copy to clipboard operation
Android-Debug-Database copied to clipboard

[PRAGMA journal_mode=TRUNCATE] database is locked With Room

Open mianaliasjad opened this issue 5 years ago • 5 comments

This is a cool library to check datasbe. But when using with Room i was seeing this log in my logcat.

2019-05-27 04:46:06.569 3634-3691/com.test E/SQLiteLog: (5) statement aborts at 1: [PRAGMA journal_mode=TRUNCATE] database is locked
2019-05-27 04:46:06.579 3634-3691/com.test W/SQLiteConnection: Could not change the database journal mode of '/data/user/0/com.test/databases/MyDb' from 'wal' to 'TRUNCATE' because the database is locked.  This usually means that there are other open connections to the database which prevents the database from enabling or disabling write-ahead logging mode.  Proceeding without changing the journal mode.

It took me 1 day to figure out that this library was causing this issue.

mianaliasjad avatar May 26 '19 23:05 mianaliasjad

Can you confirm this?

abhinav-adtechs avatar Sep 17 '19 15:09 abhinav-adtechs

android.database.sqlite.SQLiteDatabaseLockedException: database is locked (code 5): , while compiling: PRAGMA journal_mode
        at android.database.sqlite.SQLiteConnection.nativePrepareStatement(Native Method)
        at android.database.sqlite.SQLiteConnection.acquirePreparedStatement(SQLiteConnection.java:890)
        at android.database.sqlite.SQLiteConnection.executeForString(SQLiteConnection.java:635)
        at android.database.sqlite.SQLiteConnection.setJournalMode(SQLiteConnection.java:321)
        at android.database.sqlite.SQLiteConnection.setWalModeFromConfiguration(SQLiteConnection.java:295)
        at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:216)
        at android.database.sqlite.SQLiteConnection.open(SQLiteConnection.java:194)
        at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked(SQLiteConnectionPool.java:493)
        at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:200)
        at android.database.sqlite.SQLiteConnectionPool.open(SQLiteConnectionPool.java:192)
        at android.database.sqlite.SQLiteDatabase.openInner(SQLiteDatabase.java:864)
        at android.database.sqlite.SQLiteDatabase.open(SQLiteDatabase.java:849)
        at android.database.sqlite.SQLiteDatabase.openDatabase(SQLiteDatabase.java:750)
        at android.database.sqlite.SQLiteDatabase.openOrCreateDatabase(SQLiteDatabase.java:767)
        at com.amitshekhar.debug.sqlite.DebugDBFactory.create(DebugDBFactory.java:13)
        at com.amitshekhar.server.RequestHandler.openDatabase(RequestHandler.java:187)
        at com.amitshekhar.server.RequestHandler.getTableListResponse(RequestHandler.java:306)
        at com.amitshekhar.server.RequestHandler.handle(RequestHandler.java:113)
        at com.amitshekhar.server.ClientServer.run(ClientServer.java:77)
        at java.lang.Thread.run(Thread.java:764)

This is my issue! When i use ROOM database and androidx.

pvthiendeveloper avatar Jan 06 '20 06:01 pvthiendeveloper

Also experiencing this issue here!

Screenshot 2020-04-02 at 00 39 26

ErickMaeda avatar Apr 01 '20 23:04 ErickMaeda

can any one help on solving the issue for instance? even after removing the library implementation, it is giving the same error.

aaghan avatar May 21 '20 15:05 aaghan

My issue occurs when I use the Firebase Database. And I remove this code to resolve issue:

FirebaseDatabase.getInstance().setPersistenceEnabled(true);

pvthiendeveloper avatar May 22 '20 02:05 pvthiendeveloper