Fixed
Status Update
Comments
su...@google.com <su...@google.com> #2
Hi, do you have a code sample that reproduces this problem?
[Deleted User] <[Deleted User]> #3
Hi, we didn't get the time to reproduce this but this is happening in large numbers on alpha08. I thought this was fixed in alpha07. Fabrics link is also attached.
ap...@google.com <ap...@google.com> #4
Project: platform/frameworks/support
Branch: androidx-master-dev
commit e6be41fdad08bb09c5f3ddb101bca0438773ca48
Author: Sumir Kataria <sumir@google.com>
Date: Mon Sep 17 12:21:59 2018
Prevent potential foreign key constraints.
Scheduling happens in a separate DB transaction from making things
as enqueued (for a variety of historical reasons that will soon be
changing). This allows for a race condition where a synchronous
cancel/enqueue/enqueueUniqueWork can change the database and lead
to a foreign key constraint violation because the original WorkSpec
no longer exists. This code handles that gracefully; we can
remove it down the road when additional infrastructure and changes
come online.
Bug: 114705286
Test: Added and ran tests.
Change-Id: Id1c6cf48b305a3526e2913a38ee0b5398c244ba4
M work/workmanager/src/androidTest/java/androidx/work/impl/background/systemjob/SystemJobSchedulerTest.java
M work/workmanager/src/main/java/androidx/work/impl/background/systemjob/SystemJobScheduler.java
https://android-review.googlesource.com/758783
https://goto.google.com/android-sha1/e6be41fdad08bb09c5f3ddb101bca0438773ca48
Branch: androidx-master-dev
commit e6be41fdad08bb09c5f3ddb101bca0438773ca48
Author: Sumir Kataria <sumir@google.com>
Date: Mon Sep 17 12:21:59 2018
Prevent potential foreign key constraints.
Scheduling happens in a separate DB transaction from making things
as enqueued (for a variety of historical reasons that will soon be
changing). This allows for a race condition where a synchronous
cancel/enqueue/enqueueUniqueWork can change the database and lead
to a foreign key constraint violation because the original WorkSpec
no longer exists. This code handles that gracefully; we can
remove it down the road when additional infrastructure and changes
come online.
Bug: 114705286
Test: Added and ran tests.
Change-Id: Id1c6cf48b305a3526e2913a38ee0b5398c244ba4
M work/workmanager/src/androidTest/java/androidx/work/impl/background/systemjob/SystemJobSchedulerTest.java
M work/workmanager/src/main/java/androidx/work/impl/background/systemjob/SystemJobScheduler.java
su...@google.com <su...@google.com> #5
A further fix should be available in alpha09.
ap...@google.com <ap...@google.com> #6
Project: platform/frameworks/support
Branch: androidx-master-dev
commit fd35a469cabd33509e1d90c57561e33be03a0dd8
Author: Sumir Kataria <sumir@google.com>
Date: Tue Sep 18 13:11:51 2018
Prevent potential foreign key constraints in AlarmMgr.
This change is an addition to the one for JobScheduler:
https://android-review.googlesource.com/c/platform/frameworks/support/+/758783
Also, this change fixes a potential issue where handleScheduleWorkIntent
was not being executed inside a transaction as it should.
Bug: 114705286
Test: Added and ran tests.
Change-Id: Ica1e54e3e9d43d52e11731f3a5727433aac0f622
M work/workmanager/src/androidTest/java/androidx/work/impl/background/systemalarm/SystemAlarmDispatcherTest.java
M work/workmanager/src/main/java/androidx/work/impl/background/systemalarm/CommandHandler.java
https://android-review.googlesource.com/760504
https://goto.google.com/android-sha1/fd35a469cabd33509e1d90c57561e33be03a0dd8
Branch: androidx-master-dev
commit fd35a469cabd33509e1d90c57561e33be03a0dd8
Author: Sumir Kataria <sumir@google.com>
Date: Tue Sep 18 13:11:51 2018
Prevent potential foreign key constraints in AlarmMgr.
This change is an addition to the one for JobScheduler:
Also, this change fixes a potential issue where handleScheduleWorkIntent
was not being executed inside a transaction as it should.
Bug: 114705286
Test: Added and ran tests.
Change-Id: Ica1e54e3e9d43d52e11731f3a5727433aac0f622
M work/workmanager/src/androidTest/java/androidx/work/impl/background/systemalarm/SystemAlarmDispatcherTest.java
M work/workmanager/src/main/java/androidx/work/impl/background/systemalarm/CommandHandler.java
su...@google.com <su...@google.com> #7
Fixed in alpha09.
ak...@gmail.com <ak...@gmail.com> #8
It is happening again on 2.7.1 version
`implementation 'androidx.work:work-runtime-ktx:2.7.1'
`implementation 'androidx.work:work-runtime-ktx:2.7.1'
mw...@gmail.com <mw...@gmail.com> #9
We have following gradle version, it is impacted heavily
Gradle: androidx.work:work-runtime:2.7.0@aar
Gradle: androidx.work:work-runtime-ktx:2.7.0@aar
Gradle: androidx.work:work-rxjava2:2.7.0@aar
Attachment: Impacted Users and session in a week
This issue has 16,025,903 crash events affecting 55,770 users
Stack Trace:
Fatal Exception: android.database.sqlite.SQLiteConstraintException: FOREIGN KEY constraint failed (code 787 SQLITE_CONSTRAINT_FOREIGNKEY)
at android.database.sqlite.SQLiteConnection.nativeExecuteForChangedRowCount(SQLiteConnection.java)
at android.database.sqlite.SQLiteConnection.executeForChangedRowCount(SQLiteConnection.java:890)
at android.database.sqlite.SQLiteSession.executeForChangedRowCount(SQLiteSession.java:756)
at android.database.sqlite.SQLiteStatement.executeUpdateDelete(SQLiteStatement.java:66)
at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1920)
at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1841)
at androidx.sqlite.db.framework.FrameworkSQLiteDatabase.execSQL(FrameworkSQLiteDatabase.java:265)
at androidx.work.impl.WorkDatabase$2.onOpen(WorkDatabase.java:167)
at androidx.work.impl.WorkDatabase_Impl$1.onOpen(WorkDatabase_Impl.java:113)
at androidx.room.RoomOpenHelper.onOpen(RoomOpenHelper.java:136)
at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.onOpen(FrameworkSQLiteOpenHelper.java:201)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:427)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:316)
at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getWritableSupportDatabase(FrameworkSQLiteOpenHelper.java:151)
at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper.getWritableDatabase(FrameworkSQLiteOpenHelper.java:112)
at androidx.room.RoomDatabase.inTransaction(RoomDatabase.java:706)
at androidx.room.RoomDatabase.assertNotSuspendingTransaction(RoomDatabase.java:483)
at androidx.work.impl.model.WorkTagDao_Impl.getTagsForWorkSpecId(WorkTagDao_Impl.java:93)
at androidx.work.impl.WorkerWrapper.run(WorkerWrapper.java:135)
at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:91)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
Gradle: androidx.work:work-runtime:2.7.0@aar
Gradle: androidx.work:work-runtime-ktx:2.7.0@aar
Gradle: androidx.work:work-rxjava2:2.7.0@aar
Attachment: Impacted Users and session in a week
This issue has 16,025,903 crash events affecting 55,770 users
Stack Trace:
Fatal Exception: android.database.sqlite.SQLiteConstraintException: FOREIGN KEY constraint failed (code 787 SQLITE_CONSTRAINT_FOREIGNKEY)
at android.database.sqlite.SQLiteConnection.nativeExecuteForChangedRowCount(SQLiteConnection.java)
at android.database.sqlite.SQLiteConnection.executeForChangedRowCount(SQLiteConnection.java:890)
at android.database.sqlite.SQLiteSession.executeForChangedRowCount(SQLiteSession.java:756)
at android.database.sqlite.SQLiteStatement.executeUpdateDelete(SQLiteStatement.java:66)
at android.database.sqlite.SQLiteDatabase.executeSql(SQLiteDatabase.java:1920)
at android.database.sqlite.SQLiteDatabase.execSQL(SQLiteDatabase.java:1841)
at androidx.sqlite.db.framework.FrameworkSQLiteDatabase.execSQL(FrameworkSQLiteDatabase.java:265)
at androidx.work.impl.WorkDatabase$2.onOpen(WorkDatabase.java:167)
at androidx.work.impl.WorkDatabase_Impl$1.onOpen(WorkDatabase_Impl.java:113)
at androidx.room.RoomOpenHelper.onOpen(RoomOpenHelper.java:136)
at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.onOpen(FrameworkSQLiteOpenHelper.java:201)
at android.database.sqlite.SQLiteOpenHelper.getDatabaseLocked(SQLiteOpenHelper.java:427)
at android.database.sqlite.SQLiteOpenHelper.getWritableDatabase(SQLiteOpenHelper.java:316)
at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper$OpenHelper.getWritableSupportDatabase(FrameworkSQLiteOpenHelper.java:151)
at androidx.sqlite.db.framework.FrameworkSQLiteOpenHelper.getWritableDatabase(FrameworkSQLiteOpenHelper.java:112)
at androidx.room.RoomDatabase.inTransaction(RoomDatabase.java:706)
at androidx.room.RoomDatabase.assertNotSuspendingTransaction(RoomDatabase.java:483)
at androidx.work.impl.model.WorkTagDao_Impl.getTagsForWorkSpecId(WorkTagDao_Impl.java:93)
at androidx.work.impl.WorkerWrapper.run(WorkerWrapper.java:135)
at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:91)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:923)
xu...@gmail.com <xu...@gmail.com> #10
i met issue too: FOREIGN KEY constraint failed (code 787 SQLITE_CONSTRAINT_FOREIGNKEY)
Description
Version used:1.0.0-alpha08
Devices reproduced on:Xiaomi, Motorola, Samsung, Oppo, etc
Android versions reproduced on:6,7,8,9
We are facing this crash with 2 stack traces :
android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId (SQLiteConnection.java)
android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId (SQLiteConnection.java:812)
android.database.sqlite.SQLiteSession.executeForLastInsertedRowId (SQLiteSession.java:788)
android.database.sqlite.SQLiteStatement.executeInsert (SQLiteStatement.java:86)
android.arch.persistence.db.framework.FrameworkSQLiteStatement.executeInsert (SourceFile:50)
android.arch.persistence.room.EntityInsertionAdapter.bind (SourceFile:64)
androidx.work.impl.model.SystemIdInfoDao_Impl.insertSystemIdInfo (SourceFile:52)
androidx.work.impl.background.systemjob.SystemJobScheduler.schedule (SourceFile:92)
androidx.work.impl.Schedulers.schedule (SourceFile:99)
androidx.work.impl.utils.EnqueueRunnable.scheduleWorkInBackground (SourceFile:114)
androidx.work.impl.utils.EnqueueRunnable.run (SourceFile:86)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1113)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:588)
java.lang.Thread.run (Thread.java:818)
android.database.sqlite.SQLiteConnection.nativeExecuteForLastInsertedRowId (SQLiteConnection.java)
android.database.sqlite.SQLiteConnection.executeForLastInsertedRowId (SQLiteConnection.java:812)
android.database.sqlite.SQLiteSession.executeForLastInsertedRowId (SQLiteSession.java:788)
android.database.sqlite.SQLiteStatement.executeInsert (SQLiteStatement.java:86)
android.arch.persistence.db.framework.FrameworkSQLiteStatement.executeInsert (SourceFile:50)
android.arch.persistence.room.EntityInsertionAdapter.bind (SourceFile:64)
androidx.work.impl.model.SystemIdInfoDao_Impl.insertSystemIdInfo (SourceFile:52)
androidx.work.impl.background.systemjob.SystemJobScheduler.schedule (SourceFile:92)
androidx.work.impl.Schedulers.schedule (SourceFile:99)
androidx.work.impl.WorkManagerImpl.rescheduleEligibleWork (SourceFile:555)
androidx.work.impl.utils.ForceStopRunnable.run (SourceFile:74)
java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1113)
java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:588)
java.lang.Thread.run (Thread.java:818)
Here is the fabrics link for this crash: