Not sure if this is just an concurrency issue of the users' db got corruped.
There following crash was observed by fabric on an Samsung 5.0 and 6.0 when executing:
new JobRequest.Builder(JOB_WIDGET_UPDATER)
.setExecutionWindow(SECONDS.toMillis(3), SECONDS.toMillis(15))
.build()
.schedule();
android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: jobs._id (code 1555)
#
Error Code : 1555 (SQLITE_CONSTRAINT_PRIMARYKEY)
Caused By : Abort due to constraint violation.
(UNIQUE constraint failed: jobs._id (code 1555))#
at android.app.ActivityThread.handleReceiver(ActivityThread.java:3641) at android.app.ActivityThread.access$2000(ActivityThread.java:221) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1876) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:158) at android.app.ActivityThread.main(ActivityThread.java:7224) at java.lang.reflect.Method.invoke(Method.java) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)Caused by android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: jobs._id (code 1555)
#
Error Code : 1555 (SQLITE_CONSTRAINT_PRIMARYKEY)
Caused By : Abort due to constraint violation.
(UNIQUE constraint failed: jobs._id (code 1555))#
at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(SQLiteConnection.java) at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:915) at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:788) at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:86) at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1609) at android.database.sqlite.SQLiteDatabase.insertOrThrow(SQLiteDatabase.java:1505) at com.evernote.android.job.JobStorage.store(JobStorage.java:245) at com.evernote.android.job.JobStorage.put(JobStorage.java:127) at com.evernote.android.job.JobManager.schedule(JobManager.java:231) at com.evernote.android.job.JobRequest.schedule(JobRequest.java:354)
Thanks for sharing. Can you tell me which version you were using? Is this happening right after you call .schedule() or some time later?
Version 1.1.9, according to the logs, it happens right after calling .schedule ().
Sorry, another question. Is it possible, that you are using multiple app processes? I'm asking because I don't get into the state where the library is crashing.
I see this crash too. I don't use multi processes.
However the builder class has a flaw which could cause this. It generates an id upon builder creation, not upon build.
So something like this:
public class App extends Application {
@Override public void onCreate() {
super.onCreate();
JobManager.create(this)
.addJobCreator(new JobCreator() {
@Override public Job create(String tag) {
return new Job() {
@NonNull @Override protected Result onRunJob(Params params) {
return Result.SUCCESS;
}
};
}
});
final JobRequest.Builder builder = new JobRequest.Builder("tag")
.setExecutionWindow(1000, 2000);
builder.build().schedule();
builder.build().schedule();
}
}
Will immediately throw the SQLiteConstraintException
I don't reuse my builder instances but when touching the JobManager from different threads it will cancel each job id multiple times:
04-15 09:28:28.066 7604-7632/de.paul_woitaschek.evernotecrash I/JobManager: Found pending job request{id=10403, tag=tag}, canceling
04-15 09:28:28.069 7604-7708/de.paul_woitaschek.evernotecrash I/JobManager: Found pending job request{id=10395, tag=tag}, canceling
04-15 09:28:28.073 7604-7715/de.paul_woitaschek.evernotecrash I/JobManager: Found pending job request{id=10403, tag=tag}, canceling
04-15 09:28:28.077 7604-7706/de.paul_woitaschek.evernotecrash I/JobManager: Found pending job request{id=10460, tag=tag}, canceling
04-15 09:28:28.081 7604-7702/de.paul_woitaschek.evernotecrash I/JobManager: Found pending job request{id=10460, tag=tag}, canceling
04-15 09:28:28.086 7604-7709/de.paul_woitaschek.evernotecrash I/JobManager: Found pending job request{id=10467, tag=tag}, canceling
04-15 09:28:28.091 7604-7707/de.paul_woitaschek.evernotecrash I/JobManager: Found pending job request{id=10459, tag=tag}, canceling
04-15 09:28:28.095 7604-7638/de.paul_woitaschek.evernotecrash I/JobManager: Found pending job request{id=10395, tag=tag}, canceling
04-15 09:28:28.100 7604-7713/de.paul_woitaschek.evernotecrash I/JobManager: Found pending job request{id=10388, tag=tag}, canceling
04-15 09:28:28.106 7604-7712/de.paul_woitaschek.evernotecrash I/JobManager: Found pending job request{id=10395, tag=tag}, canceling
04-15 09:28:28.110 7604-7717/de.paul_woitaschek.evernotecrash I/JobManager: Found pending job request{id=10395, tag=tag}, canceling
04-15 09:28:28.115 7604-7710/de.paul_woitaschek.evernotecrash I/JobManager: Found pending job request{id=10395, tag=tag}, canceling
Awesome, thanks for the sample. I'll take a look at it next week. I can reproduce both issues.
Okay, I had some time left. Could give the snapshot build a try and see if that fixes the issue for you? I'd appreciate the help.
repositories {
jcenter()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
}
dependencies {
compile 'com.evernote:android-job:1.1.10-SNAPSHOT'
}
It's still happening with 1.1.10;
Error Code : 1555 (SQLITE_CONSTRAINT_PRIMARYKEY)
Caused By : Abort due to constraint violation.
(UNIQUE constraint failed: jobs._id (code 1555))
com.evernote.android.job.JobStorage.store (SourceFile:243)
com.evernote.android.job.JobStorage.put (SourceFile:125)
com.evernote.android.job.JobManager.schedule (SourceFile:231)
Can you reproduce it?
I have noticed a similar crash report in our Play store Crashes and ANR's page. I will try to find it and post the log here. I don't recall which version but I suspect it was with 1.1.9.
Reported on May 3rd, android-job 1.10, Android 6.0, Galaxy S5
android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: jobs._id (code 1555)
in #################################################################.nativeExecuteForLastInsertedRowId
Caused By : Abort due to constraint violation.
(UNIQUE constraint failed: jobs._id (code 1555))
at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(SQLiteConnection.java)
at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:915)
at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:788)
at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:86)
at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1609)
at android.database.sqlite.SQLiteDatabase.insertOrThrow(SQLiteDatabase.java:1505)
at com.evernote.android.job.JobStorage.store(JobStorage.java:243)
at com.evernote.android.job.JobStorage.put(JobStorage.java:125)
at com.evernote.android.job.JobManager.schedule(JobManager.java:231)
at com.evernote.android.job.JobRequest.schedule(JobRequest.java:366)
at com.evernote.android.job.JobRescheduleService.onHandleIntent(JobRescheduleService.java:60)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:66)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.os.HandlerThread.run(HandlerThread.java:61)
@PaulWoitaschek Can you post a full stack trace as well?
Another crash log from May 2nd, v1.10, Android 6.0 LGG3
android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: jobs._id (code 1555)
in at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(SQLiteConnection.java).nativeExecuteForLastInsertedRowId
at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:926)
at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:86)
at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1581)
at android.database.sqlite.SQLiteDatabase.insertOrThrow(SQLiteDatabase.java:1477)
at com.evernote.android.job.JobStorage.store(JobStorage.java:243)
at com.evernote.android.job.JobStorage.put(JobStorage.java:125)
at com.evernote.android.job.JobManager.schedule(JobManager.java:231)
at com.evernote.android.job.JobRequest.schedule(JobRequest.java:366)
at com.evernote.android.job.JobRescheduleService.onHandleIntent(JobRescheduleService.java:60)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:66)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.os.HandlerThread.run(HandlerThread.java:61)
Can you reopen this?
Fatal Exception: android.database.sqlite.SQLiteConstraintException: PRIMARY KEY must be unique (code 19)
at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(SQLiteConnection.java)
at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:972)
at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:788)
at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:86)
at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1590)
at android.database.sqlite.SQLiteDatabase.insertOrThrow(SQLiteDatabase.java:1486)
at com.evernote.android.job.JobStorage.store(SourceFile:243)
at com.evernote.android.job.JobStorage.put(SourceFile:125)
at com.evernote.android.job.JobManager.schedule(SourceFile:231)
at com.evernote.android.job.JobRequest.schedule(SourceFile:366)
at com.evernote.android.job.JobRescheduleService.onHandleIntent(SourceFile:60)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:146)
at android.os.HandlerThread.run(HandlerThread.java:61)
Yes, sure.
I think I found the reason, see the test in #33d64c8
It would be great, if you could give it a try:
repositories {
jcenter()
maven {
url 'https://oss.sonatype.org/content/repositories/snapshots/'
}
}
dependencies {
compile 'com.evernote:android-job:1.1.11-SNAPSHOT'
}
same issue +1
@eggcaker Could you give the snapshot build a try?
I will continue to monitor this. It's is a rare occurrence in my apps user base so it may be a while before I know for certain if it's fixed or not.
Thanks, I appreciate it!
@vRallev looks the snapshot build fixed this issue
Great. I'll probably publish a stable release at the end of this week. But I don't expect any changes compared to the last snapshot build anymore.
New week has begun. Any news on this?
We're testing the latest snapshot build in our latest release at the moment (staged rollout). Once we're confident that the bug is fixed, I'll push a new stable release. But there's nothing preventing you to use the snapshot build as well.
I have it out to about 130000 users at this time. I will scrub through my crash reports in a bit to see if it's gone.
I just checked and I have 4 crashes with this error on 1.11-SNAPSHOT vs previous versions total of 755.
Android 5.1:
android.database.sqlite.SQLiteConstraintException:
at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(SQLiteConnection.java:0)
at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:788)
at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:788)
at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:86)
at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1471)
at android.database.sqlite.SQLiteDatabase.insertOrThrow(SQLiteDatabase.java:1367)
at com.evernote.android.job.JobStorage.store(JobStorage.java:243)
at com.evernote.android.job.JobStorage.put(JobStorage.java:125)
at com.evernote.android.job.JobManager.schedule(JobManager.java:231)
at com.evernote.android.job.JobRequest.schedule(JobRequest.java:366)
at com.evernote.android.job.JobRescheduleService.onHandleIntent(JobRescheduleService.java:60)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:211)
at android.os.HandlerThread.run(HandlerThread.java:61)
Android 5.0:
android.database.sqlite.SQLiteConstraintException:
at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(SQLiteConnection.java:0)
at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:791)
at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:788)
at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:86)
at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1501)
at android.database.sqlite.SQLiteDatabase.insertOrThrow(SQLiteDatabase.java:1397)
at com.evernote.android.job.JobStorage.store(JobStorage.java:243)
at com.evernote.android.job.JobStorage.put(JobStorage.java:125)
at com.evernote.android.job.JobManager.schedule(JobManager.java:231)
at com.evernote.android.job.JobRequest.schedule(JobRequest.java:366)
at com.evernote.android.job.JobRescheduleService.onHandleIntent(JobRescheduleService.java:60)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:65)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:194)
at android.os.HandlerThread.run(HandlerThread.java:61)
and 2 on Android 6.0:
android.database.sqlite.SQLiteConstraintException:
at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(SQLiteConnection.java:0)
at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:789)
at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:788)
at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:86)
at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1501)
at android.database.sqlite.SQLiteDatabase.insertOrThrow(SQLiteDatabase.java:1397)
at com.evernote.android.job.JobStorage.store(JobStorage.java:243)
at com.evernote.android.job.JobStorage.put(JobStorage.java:125)
at com.evernote.android.job.JobManager.schedule(JobManager.java:231)
at com.evernote.android.job.JobRequest.schedule(JobRequest.java:366)
at com.evernote.android.job.JobRescheduleService.onHandleIntent(JobRescheduleService.java:60)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:66)
at android.os.Handler.dispatchMessage(Handler.java:111)
at android.os.Looper.loop(Looper.java:207)
at android.os.HandlerThread.run(HandlerThread.java:61)
android.database.sqlite.SQLiteConstraintException:
at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(SQLiteConnection.java:0)
at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:786)
at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:788)
at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:86)
at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1471)
at android.database.sqlite.SQLiteDatabase.insertOrThrow(SQLiteDatabase.java:1367)
at com.evernote.android.job.JobStorage.store(JobStorage.java:243)
at com.evernote.android.job.JobStorage.put(JobStorage.java:125)
at com.evernote.android.job.JobManager.schedule(JobManager.java:231)
at com.evernote.android.job.JobRequest.schedule(JobRequest.java:366)
at com.evernote.android.job.JobRescheduleService.onHandleIntent(JobRescheduleService.java:60)
at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:66)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:234)
at android.os.HandlerThread.run(HandlerThread.java:61)
Thanks, but unfortunately you're either shrinking your code or you were using and old build (that's the downside of snapshot builds, sorry). From the stacktrace
com.evernote.android.job.JobStorage.store(JobStorage.java:243)
But this line is a comment in the most recent version: https://github.com/evernote/android-job/blob/master/library/src/main/java/com/evernote/android/job/JobStorage.java#L243
Yes, it is likely a older snapshot build - this release has been out for several days already. Won't be releasing a new build for a week or more though so will have to wait and see.
We haven't seen this issue anymore. But I won't publish the stable version until we're sure that it's fixed. Before you publish a new version, please run >./gradlew --refresh-dependencies to make sure that you're using the latest snapshot build.
I appreciate your help!
Upgrade app in google play.
Updated android job from 1.1.9 to 1.1.10.
Only Samsung and Lenovo devices crashing:
Galaxy Note7 - 35%
Galaxy S4 Mini - 13%
Galaxy Note 8.0 - 13%
Galaxy Tab3V 7.0 - 13%
Galaxy S3 - 13%
Galaxy S5 - 13#
Lenovo VIBE X3 Lite
After upgrade few users get:
Fatal Exception: java.lang.RuntimeException: Unable to create application com.droid4you.application.wallet.Application: android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: jobs._id (code 1555)
#################################################################
Error Code : 1555 (SQLITE_CONSTRAINT_PRIMARYKEY)
Caused By : Abort due to constraint violation.
(UNIQUE constraint failed: jobs._id (code 1555))
#################################################################
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6319)
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:7224)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by android.database.sqlite.SQLiteConstraintException: UNIQUE constraint failed: jobs._id (code 1555)
#################################################################
Error Code : 1555 (SQLITE_CONSTRAINT_PRIMARYKEY)
Caused By : Abort due to constraint violation.
(UNIQUE constraint failed: jobs._id (code 1555))
#################################################################
at android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId(SQLiteConnection.java)
at android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId(SQLiteConnection.java:915)
at android.database.sqlite.SQLiteSession.executeForLastInsertedRowId(SQLiteSession.java:788)
at android.database.sqlite.SQLiteStatement.executeInsert(SQLiteStatement.java:86)
at android.database.sqlite.SQLiteDatabase.insertWithOnConflict(SQLiteDatabase.java:1609)
at android.database.sqlite.SQLiteDatabase.insertOrThrow(SQLiteDatabase.java:1505)
at com.evernote.android.job.JobStorage.store(SourceFile:243)
at com.evernote.android.job.JobStorage.put(SourceFile:125)
at com.evernote.android.job.JobManager.schedule(SourceFile:231)
at com.evernote.android.job.JobRequest.schedule(SourceFile:366)
at com.droid4you.application.wallet.jobs.internal.BaseJob.schedulePeriodicJob(SourceFile:69)
at com.droid4you.application.wallet.jobs.internal.BaseJob.schedule(SourceFile:27)
at com.droid4you.application.wallet.jobs.internal.JobsEnum.scheduleAll(SourceFile:70)
at com.droid4you.application.wallet.Application.initJobs(SourceFile:271)
at com.droid4you.application.wallet.Application.onCreate(SourceFile:189)
at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1036)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:6316)
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:7224)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
BaseJob.java
private int schedulePeriodicJob() {
long timeDiff = getTimeIntervalFromExactTimeOrTomorrow(getTimeToShow());
JobRequest.Builder builder = new JobRequest.Builder(getJobEnum().getTag())
.setExecutionWindow(timeDiff, timeDiff + DateHelper.ONE_MINUTE)
.setUpdateCurrent(true)
.setPersisted(true)
.setUpdateCurrent(true);
addSpecialParamsToJobRequest(builder);
JobRequest jobRequest = builder.build();
int jobId = jobRequest.schedule();
Ln.d("Job " + getJobEnum().getTag() + " scheduled at " + DateTime.now().plusMillis((int)jobRequest.getStartMs()).toString());
return jobId;
}
@mtrakal I'd appreciate if you could give the snapshot build a try!
@vRallev I will, thanks for hint. I'll notify after release new apk to play store. Thanks
@vRallev looks fixed with compile 'com.evernote:android-job:1.1.11-SNAPSHOT'.
No new crashes on it in Fabric. Thanks
No more crashes here either.
That's great to hear. I guess then next week will be a good time for a stable release.
Seems ok here as well.
I'm not seeing this exception in the Play store reports any more. Seems to be fixed :)
That's great to hear. I guess then next week will be a good time for a stable release.
What's the status of the release @vRallev ?
Most helpful comment
Done https://github.com/evernote/android-job/releases/tag/v1.1.11