Fixed
Status Update
Comments
ra...@google.com <ra...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-main
commit 11a3cb30e7c9067a27eb10bf96e89afdc283ba2e
Author: pingxuanli <pingxuanli@google.com>
Date: Mon Aug 22 13:03:03 2022
Adding error message check in EntityUpsertionAdapter.
Bug: 243039555
Test: Tests are in EntityUpsertionAdapterTest file. By using toy, can check for foreign key constraint. (FK violation is commented out to prevent crash but the errors were thrown correctly)
Relnote: restrict the minimum version that supports Upsert to at least 16
Change-Id: I5f67f2ab5d41a313c48dac42f485f8345f74c1b1
M room/room-common/api/current.txt
M room/room-runtime/api/restricted_current.txt
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/DaoConflictStrategyTest.java
M room/room-common/src/main/java/androidx/room/Upsert.kt
M room/room-common/api/public_plus_experimental_current.txt
M room/room-runtime/api/current.txt
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/LiveDataQueryTest.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/EntityUpsertionAdapterTest.java
M room/room-runtime/api/public_plus_experimental_current.txt
M room/room-runtime/src/main/java/androidx/room/EntityUpsertionAdapter.kt
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/vo/Toy.java
M room/room-common/api/restricted_current.txt
https://android-review.googlesource.com/2191947
Branch: androidx-main
commit 11a3cb30e7c9067a27eb10bf96e89afdc283ba2e
Author: pingxuanli <pingxuanli@google.com>
Date: Mon Aug 22 13:03:03 2022
Adding error message check in EntityUpsertionAdapter.
Bug: 243039555
Test: Tests are in EntityUpsertionAdapterTest file. By using toy, can check for foreign key constraint. (FK violation is commented out to prevent crash but the errors were thrown correctly)
Relnote: restrict the minimum version that supports Upsert to at least 16
Change-Id: I5f67f2ab5d41a313c48dac42f485f8345f74c1b1
M room/room-common/api/current.txt
M room/room-runtime/api/restricted_current.txt
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/DaoConflictStrategyTest.java
M room/room-common/src/main/java/androidx/room/Upsert.kt
M room/room-common/api/public_plus_experimental_current.txt
M room/room-runtime/api/current.txt
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/LiveDataQueryTest.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/EntityUpsertionAdapterTest.java
M room/room-runtime/api/public_plus_experimental_current.txt
M room/room-runtime/src/main/java/androidx/room/EntityUpsertionAdapter.kt
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/vo/Toy.java
M room/room-common/api/restricted_current.txt
ap...@google.com <ap...@google.com> #3
This bug was linked in a change in the following release(s):
androidx.room:room-common:2.5.0-beta01
androidx.room:room-runtime:2.5.0-beta01
ra...@google.com <ra...@google.com> #4
This fix is also preventing the update when there is a uniqueness conflict on an index (code 2067 SQLITE_CONTRAINT_UNIQUE). In this case `checkUniquenessException(ex)` rethrows the exception. Is it expected ?
ap...@google.com <ap...@google.com> #5
Thanks for the comment, indeed checkUniquenessException
should not throw for SQLITE_CONSTRAINT_UNIQUE
as per the SQLite docs:
The special UPSERT processing happens only for uniqueness constraint on the table that is receiving the INSERT. A "uniqueness constraint" is an explicit UNIQUE or PRIMARY KEY constraint within the CREATE TABLE statement, or a unique index. UPSERT does not intervene for failed NOT NULL or foreign key constraints or for constraints that are implemented using triggers.
In
We'll make a fix to includes SQLITE_CONSTRAINT_UNIQUE
as part of the 'uniqueness constraint' that will lead to an UPDATE
.
ro...@gmail.com <ro...@gmail.com> #6
Thanks for the update, really appreciate it !
an...@google.com <an...@google.com> #7
Hello,
I've just hit this issue and I would like to know what's the status on handling 2067 SQLITE_CONSTRAINT_UNIQUE the same way and proceed to an update. I was very surprised upsert wasn't working.
Thanks
I've just hit this issue and I would like to know what's the status on handling 2067 SQLITE_CONSTRAINT_UNIQUE the same way and proceed to an update. I was very surprised upsert wasn't working.
Thanks
ro...@gmail.com <ro...@gmail.com> #8
Thanks for the bump, we'll resolve this issue asap.
su...@google.com <su...@google.com> #9
Project: platform/frameworks/support
Branch: androidx-main
commit 01002bedc549e0264a5f920dc554ed7dd7785cfe
Author: elifbilgin <elifbilgin@google.com>
Date: Tue Aug 01 05:53:50 2023
Handle special case SQLite exception during upsert.
When 2067 SQLITE_CONSTRAINT_UNIQUE is thrown during an upsert, upsert should perform an update.
Bug: 243039555
Test: EntityUpsertionAdapterTest.java
Change-Id: If28499c59443f590ac456924eff03b18f1a87e4f
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/EntityUpsertionAdapterTest.java
M room/room-runtime/src/main/java/androidx/room/EntityUpsertionAdapter.kt
https://android-review.googlesource.com/2686153
Branch: androidx-main
commit 01002bedc549e0264a5f920dc554ed7dd7785cfe
Author: elifbilgin <elifbilgin@google.com>
Date: Tue Aug 01 05:53:50 2023
Handle special case SQLite exception during upsert.
When 2067 SQLITE_CONSTRAINT_UNIQUE is thrown during an upsert, upsert should perform an update.
Bug: 243039555
Test: EntityUpsertionAdapterTest.java
Change-Id: If28499c59443f590ac456924eff03b18f1a87e4f
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/EntityUpsertionAdapterTest.java
M room/room-runtime/src/main/java/androidx/room/EntityUpsertionAdapter.kt
ra...@google.com <ra...@google.com> #10
Also, are you sure the app in question was using the recent version of WM ?
Description
Version used:2.1.0
Devices/Android versions reproduced on:MINIX/Android 5.1.1
If this is a bug in the library, we would appreciate if you could attach:
07-23 15:02:22.508 1042-1127/E/WM-SystemAlarmDispatche: Unexpected error in onHandleIntent
java.util.concurrent.RejectedExecutionException: Task java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask@2713e108 rejected from java.util.concurrent.ScheduledThreadPoolExecutor@63770a1[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 0]
at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2011)
at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:793)
at java.util.concurrent.ScheduledThreadPoolExecutor.delayedExecute(ScheduledThreadPoolExecutor.java:298)
at java.util.concurrent.ScheduledThreadPoolExecutor.schedule(ScheduledThreadPoolExecutor.java:503)
at java.util.concurrent.Executors$DelegatedScheduledExecutorService.schedule(Executors.java:644)
at androidx.work.impl.background.systemalarm.WorkTimer.startTimer(WorkTimer.java:82)
at androidx.work.impl.background.systemalarm.DelayMetCommandHandler.onAllConstraintsMet(DelayMetCommandHandler.java:135)
at androidx.work.impl.background.systemalarm.DelayMetCommandHandler.handleProcessWork(DelayMetCommandHandler.java:211)
at androidx.work.impl.background.systemalarm.CommandHandler.handleDelayMet(CommandHandler.java:272)
at androidx.work.impl.background.systemalarm.CommandHandler.onHandleIntent(CommandHandler.java:171)
at androidx.work.impl.background.systemalarm.SystemAlarmDispatcher$1.run(SystemAlarmDispatcher.java:272)
at androidx.work.impl.utils.SerialExecutor$Task.run(SerialExecutor.java:75)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:818)
07-23 15:02:22.963 1042-1055/com.yantranet.signware.agent.staging A/PowerManager: WakeLock finalized while still held: WorkManager: 72a8dc67-9b97-430d-9fc9-876f7e7c836c (2)
I need to run work request on-demand for a list of workers. The on-demand request can come in multiple times. So I basically loop the requests and create OneTimeWorkRequest for each Worker. I end up with the Exectuor RejectionException as above.