android-priority-jobqueue icon indicating copy to clipboard operation
android-priority-jobqueue copied to clipboard

SQLiteDatabaseLockedException

Open slott opened this issue 9 years ago • 11 comments

With the latest version 2 we are getting the following crash which we never had with the previous version.

Fatal Exception: android.database.sqlite.SQLiteDatabaseLockedException: database is locked (code 5) at android.database.sqlite.SQLiteConnection.nativeExecute(SQLiteConnection.java) at android.database.sqlite.SQLiteConnection.execute(SQLiteConnection.java:725) at android.database.sqlite.SQLiteSession.beginTransactionUnchecked(SQLiteSession.java:323) at android.database.sqlite.SQLiteSession.beginTransaction(SQLiteSession.java:298) at android.database.sqlite.SQLiteDatabase.beginTransaction(SQLiteDatabase.java:510) at android.database.sqlite.SQLiteDatabase.beginTransaction(SQLiteDatabase.java:421) at com.birbit.android.jobqueue.h.a.d.b(SqliteJobQueue.java:205) at com.birbit.android.jobqueue.h.a.d.c(SqliteJobQueue.java:201) at com.birbit.android.jobqueue.a.a.c(CachedJobQueue.java:51) at com.birbit.android.jobqueue.l.a(JobManagerThread.java:561) at com.birbit.android.jobqueue.l.a(JobManagerThread.java:36472) at com.birbit.android.jobqueue.l$1.a(JobManagerThread.java:237) at com.birbit.android.jobqueue.l.run(JobManagerThread.java:7039) at java.lang.Thread.run(Thread.java:818)

slott avatar Nov 23 '16 08:11 slott

Do you have de-obfuscated stack trace? Also, there is no reason for a db to be locked unless you are creating more than 1 instance of JobManager with the same ID.

yigit avatar Nov 24 '16 07:11 yigit

Sorry this is all I have. Its a crash picked up from Fabric and we have a few issues getting it to correctly de-obfuscated the stack trace from time to time. Before the version upgrade from 1.x -> 2.x we never had this problem

slott avatar Nov 28 '16 06:11 slott

Crash without proguard - hope that will help as this is by far the issue causing most crashes to our Vivino app. It seems to happen when I'm offline and the jobs are queued up.

FATAL EXCEPTION: job-manager Process: vivino.web.app.common, PID: 12332 android.database.sqlite.SQLiteDatabaseLockedException: database is locked (code 5) at android.database.sqlite.SQLiteConnection.nativeExecute(Native Method) at android.database.sqlite.SQLiteConnection.execute(SQLiteConnection.java:561) at android.database.sqlite.SQLiteSession.execute(SQLiteSession.java:619) at android.database.sqlite.SQLiteStatement.execute(SQLiteStatement.java:44) at com.birbit.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.setSessionIdOnJob(SqliteJobQueue.java:360) at com.birbit.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.nextJobAndIncRunCount(SqliteJobQueue.java:301) at com.birbit.android.jobqueue.cachedQueue.CachedJobQueue.nextJobAndIncRunCount(CachedJobQueue.java:79) at com.birbit.android.jobqueue.JobManagerThread.getNextJob(JobManagerThread.java:665) at com.birbit.android.jobqueue.JobManagerThread.getNextJob(JobManagerThread.java:642) at com.birbit.android.jobqueue.ConsumerManager.handleIdle(ConsumerManager.java:199) at com.birbit.android.jobqueue.JobManagerThread$1.handleMessage(JobManagerThread.java:231) at com.birbit.android.jobqueue.messaging.PriorityMessageQueue.consume(PriorityMessageQueue.java:39) at com.birbit.android.jobqueue.JobManagerThread.run(JobManagerThread.java:222) at java.lang.Thread.run(Thread.java:818)

slott avatar Dec 16 '16 09:12 slott

I got same error from Fabric, in different place:

Fatal Exception: android.database.sqlite.SQLiteDatabaseLockedException: database is locked (code 5) at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(SQLiteConnection.java) at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:782) at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:788) at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:86) at com.birbit.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.insertOrReplace(SqliteJobQueue.java:191) at com.birbit.android.jobqueue.cachedQueue.CachedJobQueue.insertOrReplace(CachedJobQueue.java:39) at com.birbit.android.jobqueue.JobManagerThread.reAddJob(JobManagerThread.java:550) at com.birbit.android.jobqueue.JobManagerThread.insertOrReplace(JobManagerThread.java:544) at com.birbit.android.jobqueue.JobManagerThread.handleRunJobResult(JobManagerThread.java:492) at com.birbit.android.jobqueue.JobManagerThread.access$300(JobManagerThread.java:35) at com.birbit.android.jobqueue.JobManagerThread$1.handleMessage(JobManagerThread.java:237) at com.birbit.android.jobqueue.messaging.PriorityMessageQueue.consume(PriorityMessageQueue.java:39) at com.birbit.android.jobqueue.JobManagerThread.run(JobManagerThread.java:222) at java.lang.Thread.run(Thread.java:841)

on NU-3S, Android 4.4.2

sideprojecteu avatar Dec 17 '16 12:12 sideprojecteu

This is really weird, we don't open database multiple times and all access happens on the JobManagerThread (as shown in logs JobManagerThread$1). Are you sure you are not creating multiple instances of the JobManager ? Also, can you share the full report from crashlytics so that we can check other threads?

yigit avatar Dec 17 '16 18:12 yigit

http://crashes.to/s/ad77072ff73 - This is all I have right now.

I'll check the code if we are having two instances of the job manager...

slott avatar Dec 17 '16 23:12 slott

Your crash report shows 2 job-manager threads. (threads 19 and 13 in the log). Btw, you can have multiple job manager instances but they need to have different ids (and they work exclusive of each other).

yigit avatar Dec 18 '16 01:12 yigit

Just checked and indeed someone added

jobManager = new JobManager(builder.build()); in another place.

Thanks for chipping in - much appreciated.

Merry x-mas !

slott avatar Dec 19 '16 06:12 slott

@sideprojecteu , can you share the crash report as well?

yigit avatar Dec 19 '16 08:12 yigit

@yigit i got same error too http://crashes.to/s/ec22eee52bf

biliboss avatar Jan 31 '17 12:01 biliboss

I got the same error as well.

nishantt12 avatar Aug 01 '18 07:08 nishantt12