yigit / android-priority-jobqueue

A Job Queue specifically written for Android to easily schedule jobs (tasks) that run in the background, improving UX and application stability.
3.4k stars 395 forks source link

SQLiteException when initialising JobManager #403

Open MFlisar opened 7 years ago

MFlisar commented 7 years ago

Crash in playstore

java.lang.RuntimeException: 
  at android.app.ActivityThread.handleBindApplication (ActivityThread.java:6320)
  at de.robv.android.xposed.XposedBridge.invokeOriginalMethodNative (Native Method)
  at de.robv.android.xposed.XposedBridge.handleHookedMethod (XposedBridge.java:755)
  at android.app.ActivityThread.handleBindApplication (<Xposed>)
  at android.app.ActivityThread.access$1800 (ActivityThread.java:221)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1860)
  at android.os.Handler.dispatchMessage (Handler.java:102)
  at android.os.Looper.loop (Looper.java:158)
  at android.app.ActivityThread.main (ActivityThread.java:7225)
  at java.lang.reflect.Method.invoke (Native Method)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:1230)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:1120)
  at de.robv.android.xposed.XposedBridge.main (XposedBridge.java:133)
Caused by: android.database.sqlite.SQLiteException: 
  at android.database.sqlite.SQLiteConnection.setLocaleFromConfiguration (SQLiteConnection.java:516)
  at android.database.sqlite.SQLiteConnection.open (SQLiteConnection.java:320)
  at android.database.sqlite.SQLiteConnection.open (SQLiteConnection.java:210)
  at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked (SQLiteConnectionPool.java:512)
  at android.database.sqlite.SQLiteConnectionPool.open (SQLiteConnectionPool.java:206)
  at android.database.sqlite.SQLiteConnectionPool.open (SQLiteConnectionPool.java:178)
  at android.database.sqlite.SQLiteDatabase.openInner (SQLiteDatabase.java:908)
  at android.database.sqlite.SQLiteDatabase.open (SQLiteDatabase.java:878)
  at android.database.sqlite.SQLiteDatabase.openDatabase (SQLiteDatabase.java:699)
  at android.app.ContextImpl.openOrCreateDatabase (ContextImpl.java:633)
  at android.content.ContextWrapper.openOrCreateDatabase (ContextWrapper.java:283)
  at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked (SQLiteOpenHelper.java:223)
  at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase (SQLiteOpenHelper.java:163)
  at com.birbit.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.<init> (SourceFile:49)
  at com.birbit.android.jobqueue.DefaultQueueFactory.a (SourceFile:27)
  at com.birbit.android.jobqueue.JobManagerThread.<init> (SourceFile:87)
  at com.birbit.android.jobqueue.JobManager.<init> (SourceFile:62)
  at com.my.app.a (SourceFile:31) // => new JobManager(builder.build()); line in my app, the last line of my setup below 

Setup

Configuration.Builder builder = new Configuration.Builder(this)
            .customLogger(new CustomLogger() {
                @Override
                public boolean isDebugEnabled() {
                    return isJobDebuggingEnabled() && BuildConfig.DEBUG;
                }
                @Override
                public void d(String text, Object... args) {
                    if (isJobDebuggingEnabled()) {
                        L.d(text, args);
                    }
                }
                @Override
                public void e(Throwable t, String text, Object... args) {
                    L.e(t, text, args);
                }
                @Override
                public void e(String text, Object... args) {
                    L.e(text, args);
                }
                @Override
                public void v(String text, Object... args) {
                    if (isJobDebuggingEnabled()) {
                        L.v(text, args);
                    }
                }
            })
            .minConsumerCount(0)//always keep at least one consumer alive
            .maxConsumerCount(3)//up to 3 consumers at a time
            .loadFactor(3)//3 jobs per consumer
            .consumerKeepAlive(120)//wait 2 minute
            ;
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        builder.scheduler(FrameworkJobSchedulerService.createSchedulerFor(this, MyJobService.class), true);
    }
    mManager = new JobManager(builder.build());

Any idea why this happens sometimes? It's an issue that only happens rarely, but regularly...

maxime-kouemo commented 7 years ago

If you are on production, please try commenting the customLogger.

quiro91 commented 6 years ago

I'm having a really similar issue:

Caused by: android.database.sqlite.SQLiteException: 
  at android.database.sqlite.SQLiteConnection.nativeOpen (SQLiteConnection.java)
  at android.database.sqlite.SQLiteConnection.open (SQLiteConnection.java:212)
  at android.database.sqlite.SQLiteConnection.open (SQLiteConnection.java:196)
  at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked (SQLiteConnectionPool.java:463)
  at android.database.sqlite.SQLiteConnectionPool.open (SQLiteConnectionPool.java:185)
  at android.database.sqlite.SQLiteConnectionPool.open (SQLiteConnectionPool.java:177)
  at android.database.sqlite.SQLiteDatabase.openInner (SQLiteDatabase.java:836)
  at android.database.sqlite.SQLiteDatabase.open (SQLiteDatabase.java:821)
  at android.database.sqlite.SQLiteDatabase.openDatabase (SQLiteDatabase.java:714)
  at android.app.ContextImpl.openOrCreateDatabase (ContextImpl.java:578)
  at android.content.ContextWrapper.openOrCreateDatabase (ContextWrapper.java:269)
  at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked (SQLiteOpenHelper.java:223)
  at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase (SQLiteOpenHelper.java:163)
  at com.birbit.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.<init> (SqliteJobQueue.java:49)
  at com.birbit.android.jobqueue.DefaultQueueFactory.createPersistentQueue (DefaultQueueFactory.java:27)
  at com.birbit.android.jobqueue.JobManagerThread.<init> (JobManagerThread.java:87)
  at com.birbit.android.jobqueue.JobManager.<init> (JobManager.java:62)
  at com.busuu.android.module.DomainModule.provideJobManager (DomainModule.java:56)
  at com.busuu.android.module.DomainModule_ProvideJobManagerFactory.get (DomainModule_ProvideJobManagerFactory.java:30)
  at com.busuu.android.module.DomainModule_ProvideJobManagerFactory.get (DomainModule_ProvideJobManagerFactory.java:10)
  at dagger.internal.DoubleCheck.get (DoubleCheck.java:47)
  at com.busuu.android.module.DomainModule_ProvideUseCaseExecutorFactory.get (DomainModule_ProvideUseCaseExecutorFactory.java:37)

Any update on this?

MFlisar commented 6 years ago

Here are some other stacktraces that I rarely get at the same place when trying to init the job manager...

android.database.sqlite.SQLiteDiskIOException: 
  at android.database.sqlite.SQLiteConnection.nativeExecute (Native Method)
  at android.database.sqlite.SQLiteConnection.execute (SQLiteConnection.java:576)
  at android.database.sqlite.SQLiteSession.beginTransactionUnchecked (SQLiteSession.java:336)
  at android.database.sqlite.SQLiteSession.beginTransaction (SQLiteSession.java:311)
  at android.database.sqlite.SQLiteDatabase.beginTransaction (SQLiteDatabase.java:532)
  at android.database.sqlite.SQLiteDatabase.beginTransaction (SQLiteDatabase.java:443)
  at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked (SQLiteOpenHelper.java:264)
  at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase (SQLiteOpenHelper.java:175)
  at com.birbit.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.<init> (SourceFile:49)
  at com.birbit.android.jobqueue.DefaultQueueFactory.a (SourceFile:27)
  at com.birbit.android.jobqueue.JobManagerThread.<init> (SourceFile:87)
  at com.birbit.android.jobqueue.JobManager.<init> (SourceFile:62)
  ...

android.database.sqlite.SQLiteException: 
  at android.database.sqlite.SQLiteConnection.setLocaleFromConfiguration (SQLiteConnection.java:417)
  at android.database.sqlite.SQLiteConnection.open (SQLiteConnection.java:238)
  at android.database.sqlite.SQLiteConnection.open (SQLiteConnection.java:205)
  at android.database.sqlite.SQLiteConnectionPool.openConnectionLocked (SQLiteConnectionPool.java:501)
  at android.database.sqlite.SQLiteConnectionPool.open (SQLiteConnectionPool.java:204)
  at android.database.sqlite.SQLiteConnectionPool.open (SQLiteConnectionPool.java:180)
  at android.database.sqlite.SQLiteDatabase.openInner (SQLiteDatabase.java:880)
  at android.database.sqlite.SQLiteDatabase.open (SQLiteDatabase.java:848)
  at android.database.sqlite.SQLiteDatabase.openDatabase (SQLiteDatabase.java:716)
  at android.app.ContextImpl.openOrCreateDatabase (ContextImpl.java:590)
  at android.content.ContextWrapper.openOrCreateDatabase (ContextWrapper.java:269)
  at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked (SQLiteOpenHelper.java:277)
  at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase (SQLiteOpenHelper.java:174)
  at com.birbit.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.<init> (SourceFile:49)
  at com.birbit.android.jobqueue.DefaultQueueFactory.a (SourceFile:27)
  at com.birbit.android.jobqueue.JobManagerThread.<init> (SourceFile:87)
  at com.birbit.android.jobqueue.JobManager.<init> (SourceFile:62)
  ...

android.database.sqlite.SQLiteReadOnlyDatabaseException: 
  at android.database.sqlite.SQLiteConnection.nativeExecuteForChangedRowCount (Native Method)
  at android.database.sqlite.SQLiteConnection.executeForChangedRowCount (SQLiteConnection.java:743)
  at android.database.sqlite.SQLiteSession.executeForChangedRowCount (SQLiteSession.java:754)
  at android.database.sqlite.SQLiteStatement.executeUpdateDelete (SQLiteStatement.java:64)
  at android.database.sqlite.SQLiteDatabase.executeSql (SQLiteDatabase.java:1707)
  at android.database.sqlite.SQLiteDatabase.execSQL (SQLiteDatabase.java:1636)
  at com.birbit.android.jobqueue.persistentQueue.sqlite.DbOpenHelper.onCreate (SourceFile:58)
  at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked (SQLiteOpenHelper.java:251)
  at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase (SQLiteOpenHelper.java:163)
  at com.birbit.android.jobqueue.persistentQueue.sqlite.SqliteJobQueue.<init> (SourceFile:49)
  at com.birbit.android.jobqueue.DefaultQueueFactory.a (SourceFile:27)
  at com.birbit.android.jobqueue.JobManagerThread.<init> (SourceFile:87)
  at com.birbit.android.jobqueue.JobManager.<init> (SourceFile:62)
  ...

My solution for now is using a custom QueueFactory with a dummy persistant queue, because I'm not using persistant jobs anyways... Not the best solution, so I'm still looking forward for any help with this issue