Fixed
Status Update
Comments
ia...@gmail.com <ia...@gmail.com> #2
Project: platform/frameworks/support
Branch: androidx-master-dev
commit b90079595f33f58fece04026a97faa0d243acdb1
Author: Yuichi Araki <yaraki@google.com>
Date: Wed Sep 18 16:55:49 2019
Change the way to detect mismatch between POJO and query
This fixes cursor mismatch warnings with expandProjection.
Bug: 140759491
Test: QueryMethodProcessorTest
Change-Id: I7659002e5e0d1ef60fc1af2a625c0c36da0664d8
M room/compiler/src/main/kotlin/androidx/room/processor/QueryMethodProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt
M room/compiler/src/main/kotlin/androidx/room/solver/query/result/PojoRowAdapter.kt
M room/compiler/src/test/kotlin/androidx/room/processor/QueryMethodProcessorTest.kt
M room/compiler/src/test/kotlin/androidx/room/testing/TestProcessor.kt
https://android-review.googlesource.com/1123258
https://goto.google.com/android-sha1/b90079595f33f58fece04026a97faa0d243acdb1
Branch: androidx-master-dev
commit b90079595f33f58fece04026a97faa0d243acdb1
Author: Yuichi Araki <yaraki@google.com>
Date: Wed Sep 18 16:55:49 2019
Change the way to detect mismatch between POJO and query
This fixes cursor mismatch warnings with expandProjection.
Bug: 140759491
Test: QueryMethodProcessorTest
Change-Id: I7659002e5e0d1ef60fc1af2a625c0c36da0664d8
M room/compiler/src/main/kotlin/androidx/room/processor/QueryMethodProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt
M room/compiler/src/main/kotlin/androidx/room/solver/query/result/PojoRowAdapter.kt
M room/compiler/src/test/kotlin/androidx/room/processor/QueryMethodProcessorTest.kt
M room/compiler/src/test/kotlin/androidx/room/testing/TestProcessor.kt
yb...@google.com <yb...@google.com>
yb...@google.com <yb...@google.com> #3
yb...@google.com <yb...@google.com> #4
Project: platform/frameworks/support
Branch: androidx-master-dev
commit bdde5a1a970ddc9007b28de4aa29d60ffa588f08
Author: Yigit Boyar <yboyar@google.com>
Date: Thu Apr 16 16:47:05 2020
Re-factor how errors are dismissed when query is re-written
This CL changes how we handle errors/warnings if query is
re-written.
There was a bug in expandProjection where we would report warnings
for things that Room already fixes automatically ( b/140759491 ).
The solution to that problem (I7659002e5e0d1ef60fc1af2a625c0c36da0664d8)
solved it by deferring validating of columns until after re-write
decision is made. Unfortunately, this required changing PojoRowAdapter
to have a dummy mapping until it is validating, make it hard to use
as it does have a non-null mapping which is not useful.
This CL partially reverts that change and instead rely on the log
deferring logic we have in Context. This way, we don't need to break
the stability of PojoRowAdapter while still having the ability to
drop warnings that room fixes. This will also play nicer when we
have different query re-writing options that can use more information
about the query results.
Bug: 153387066
Bug: 140759491
Test: existing tests pass
Change-Id: I2ec967c763d33d7a3ff02c1a13c6953b460d1e5f
M room/compiler/src/main/kotlin/androidx/room/log/RLog.kt
M room/compiler/src/main/kotlin/androidx/room/processor/QueryMethodProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt
M room/compiler/src/main/kotlin/androidx/room/solver/query/result/PojoRowAdapter.kt
https://android-review.googlesource.com/1288456
Branch: androidx-master-dev
commit bdde5a1a970ddc9007b28de4aa29d60ffa588f08
Author: Yigit Boyar <yboyar@google.com>
Date: Thu Apr 16 16:47:05 2020
Re-factor how errors are dismissed when query is re-written
This CL changes how we handle errors/warnings if query is
re-written.
There was a bug in expandProjection where we would report warnings
for things that Room already fixes automatically (
The solution to that problem (I7659002e5e0d1ef60fc1af2a625c0c36da0664d8)
solved it by deferring validating of columns until after re-write
decision is made. Unfortunately, this required changing PojoRowAdapter
to have a dummy mapping until it is validating, make it hard to use
as it does have a non-null mapping which is not useful.
This CL partially reverts that change and instead rely on the log
deferring logic we have in Context. This way, we don't need to break
the stability of PojoRowAdapter while still having the ability to
drop warnings that room fixes. This will also play nicer when we
have different query re-writing options that can use more information
about the query results.
Bug: 153387066
Bug: 140759491
Test: existing tests pass
Change-Id: I2ec967c763d33d7a3ff02c1a13c6953b460d1e5f
M room/compiler/src/main/kotlin/androidx/room/log/RLog.kt
M room/compiler/src/main/kotlin/androidx/room/processor/QueryMethodProcessor.kt
M room/compiler/src/main/kotlin/androidx/room/solver/TypeAdapterStore.kt
M room/compiler/src/main/kotlin/androidx/room/solver/query/result/PojoRowAdapter.kt
ia...@gmail.com <ia...@gmail.com> #5
As I understand it, any non-Room suspending method in the middle of a transaction will still break since you might resume the coroutine on a different thread?
I think I'd personally really like an extension method of:
fun RoomDatabase.transaction(body: suspend () -> Unit)
that replaces / obsoletes runInTransaction and would be safe to do both Room suspend methods and other, non-Room suspend methods, always returning to the correct thread for the transaction.
I think I'd personally really like an extension method of:
fun RoomDatabase.transaction(body: suspend () -> Unit)
that replaces / obsoletes runInTransaction and would be safe to do both Room suspend methods and other, non-Room suspend methods, always returning to the correct thread for the transaction.
yb...@google.com <yb...@google.com> #6
yea the issue w/ suspending room version is that we need to make sure we can carry over the transaction information so that it can go to the right thread and only it (not some other parallel task).
This is why we need a proper transaction abstraction to safely do these jumps (or at least thats what i thnk we'll need, maybe not)
This is why we need a proper transaction abstraction to safely do these jumps (or at least thats what i thnk we'll need, maybe not)
ap...@google.com <ap...@google.com> #7
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 69961b4ef143d82f50c3a7fd3969826d51a0ee25
Author: Daniel Santiago Rivera <danysantiago@google.com>
Date: Thu Jan 31 12:57:58 2019
Room Suspending Transaction
Create an API for performing database transaction with coroutines. When
starting a transaction coroutine a thread of the database query executor
is hold for performing all database operations within the coroutine. It
is recommended that all DAO functions invoked are also suspend
functions. In the case they are blocking DAO methods, then invoking
those on a different context other than the transaction context will
throw an exception, preventing possible deadlocks.
Bug: 120854786
Test: ./gradlew room:room-compiler:test
room:integration-tests:room-testapp-kotlin:cC
room:integration-tests:room-testapp:cC
Change-Id: I30f76db29a3882968f43e1dd1c1038b5afd7f299
M room/compiler/src/main/kotlin/androidx/room/solver/prepared/binder/InstantPreparedQueryResultBinder.kt
M room/compiler/src/main/kotlin/androidx/room/solver/query/result/InstantQueryResultBinder.kt
M room/compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/InstantDeleteOrUpdateMethodBinder.kt
M room/compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/InstantInsertMethodBinder.kt
M room/compiler/src/test/data/daoWriter/output/ComplexDao.java
M room/compiler/src/test/data/daoWriter/output/DeletionDao.java
M room/compiler/src/test/data/daoWriter/output/UpdateDao.java
M room/compiler/src/test/data/daoWriter/output/WriterDao.java
M room/coroutines/api/2.1.0-alpha05.txt
M room/coroutines/api/current.txt
M room/coroutines/build.gradle
M room/coroutines/src/main/java/androidx/room/CoroutinesRoom.kt
A room/coroutines/src/main/java/androidx/room/RoomDatabase.kt
M room/integration-tests/kotlintestapp/build.gradle
M room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/test/SuspendingQueryTest.kt
M room/runtime/api/restricted_2.1.0-alpha05.txt
M room/runtime/api/restricted_current.txt
M room/runtime/src/main/java/androidx/room/RoomDatabase.java
https://android-review.googlesource.com/891674
https://goto.google.com/android-sha1/69961b4ef143d82f50c3a7fd3969826d51a0ee25
Branch: androidx-master-dev
commit 69961b4ef143d82f50c3a7fd3969826d51a0ee25
Author: Daniel Santiago Rivera <danysantiago@google.com>
Date: Thu Jan 31 12:57:58 2019
Room Suspending Transaction
Create an API for performing database transaction with coroutines. When
starting a transaction coroutine a thread of the database query executor
is hold for performing all database operations within the coroutine. It
is recommended that all DAO functions invoked are also suspend
functions. In the case they are blocking DAO methods, then invoking
those on a different context other than the transaction context will
throw an exception, preventing possible deadlocks.
Bug: 120854786
Test: ./gradlew room:room-compiler:test
room:integration-tests:room-testapp-kotlin:cC
room:integration-tests:room-testapp:cC
Change-Id: I30f76db29a3882968f43e1dd1c1038b5afd7f299
M room/compiler/src/main/kotlin/androidx/room/solver/prepared/binder/InstantPreparedQueryResultBinder.kt
M room/compiler/src/main/kotlin/androidx/room/solver/query/result/InstantQueryResultBinder.kt
M room/compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/InstantDeleteOrUpdateMethodBinder.kt
M room/compiler/src/main/kotlin/androidx/room/solver/shortcut/binder/InstantInsertMethodBinder.kt
M room/compiler/src/test/data/daoWriter/output/ComplexDao.java
M room/compiler/src/test/data/daoWriter/output/DeletionDao.java
M room/compiler/src/test/data/daoWriter/output/UpdateDao.java
M room/compiler/src/test/data/daoWriter/output/WriterDao.java
M room/coroutines/api/2.1.0-alpha05.txt
M room/coroutines/api/current.txt
M room/coroutines/build.gradle
M room/coroutines/src/main/java/androidx/room/CoroutinesRoom.kt
A room/coroutines/src/main/java/androidx/room/RoomDatabase.kt
M room/integration-tests/kotlintestapp/build.gradle
M room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/test/SuspendingQueryTest.kt
M room/runtime/api/restricted_2.1.0-alpha05.txt
M room/runtime/api/restricted_current.txt
M room/runtime/src/main/java/androidx/room/RoomDatabase.java
ap...@google.com <ap...@google.com> #8
Project: platform/frameworks/support
Branch: androidx-master-dev
commit f0f9ed8db13fbeb028391af00b626e19a0f2746e
Author: Daniel Santiago Rivera <danysantiago@google.com>
Date: Mon Feb 11 14:35:55 2019
Deprecate RoomDatabase transaction methods.
Deprecate beginTransaction, setTransactionSuccessful and endTransaction,
in favor of runInTransaction. Deprecating these methods discourage
users from using them within coroutines.
Bug: 120854786
Test: ./gradlew room:room-compiler:test
room:integration-tests:room-testapp-kotlin:cC
room:integration-tests:room-testapp:cC
Change-Id: Idc1bb04555fdba78eb1142b3ba461b87e6b06a69
M room/compiler/src/main/kotlin/androidx/room/writer/ClassWriter.kt
M room/compiler/src/test/data/daoWriter/output/ComplexDao.java
M room/compiler/src/test/data/daoWriter/output/DeletionDao.java
M room/compiler/src/test/data/daoWriter/output/UpdateDao.java
M room/compiler/src/test/data/daoWriter/output/WriterDao.java
M room/compiler/src/test/data/databasewriter/output/ComplexDatabase.java
M room/compiler/src/test/kotlin/androidx/room/writer/EntityCursorConverterWriterTest.kt
M room/coroutines/src/main/java/androidx/room/RoomDatabase.kt
M room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/migration/MigrationKotlinTest.kt
M room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/test/SuspendingQueryTest.kt
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/migration/FtsMigrationTest.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/migration/MigrationTest.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/paging/DataSourceFactoryTest.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/ForeignKeyTest.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/MultiInstanceInvalidationTest.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/QueryTransactionTest.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/RxJava2Test.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/RxJava2WithInstantTaskExecutorTest.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/WriteAheadLoggingTest.java
M room/runtime/api/2.1.0-alpha05.txt
M room/runtime/api/current.txt
M room/runtime/src/main/java/androidx/room/RoomDatabase.java
M room/runtime/src/main/java/androidx/room/paging/LimitOffsetDataSource.java
https://android-review.googlesource.com/900916
https://goto.google.com/android-sha1/f0f9ed8db13fbeb028391af00b626e19a0f2746e
Branch: androidx-master-dev
commit f0f9ed8db13fbeb028391af00b626e19a0f2746e
Author: Daniel Santiago Rivera <danysantiago@google.com>
Date: Mon Feb 11 14:35:55 2019
Deprecate RoomDatabase transaction methods.
Deprecate beginTransaction, setTransactionSuccessful and endTransaction,
in favor of runInTransaction. Deprecating these methods discourage
users from using them within coroutines.
Bug: 120854786
Test: ./gradlew room:room-compiler:test
room:integration-tests:room-testapp-kotlin:cC
room:integration-tests:room-testapp:cC
Change-Id: Idc1bb04555fdba78eb1142b3ba461b87e6b06a69
M room/compiler/src/main/kotlin/androidx/room/writer/ClassWriter.kt
M room/compiler/src/test/data/daoWriter/output/ComplexDao.java
M room/compiler/src/test/data/daoWriter/output/DeletionDao.java
M room/compiler/src/test/data/daoWriter/output/UpdateDao.java
M room/compiler/src/test/data/daoWriter/output/WriterDao.java
M room/compiler/src/test/data/databasewriter/output/ComplexDatabase.java
M room/compiler/src/test/kotlin/androidx/room/writer/EntityCursorConverterWriterTest.kt
M room/coroutines/src/main/java/androidx/room/RoomDatabase.kt
M room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/migration/MigrationKotlinTest.kt
M room/integration-tests/kotlintestapp/src/androidTest/java/androidx/room/integration/kotlintestapp/test/SuspendingQueryTest.kt
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/migration/FtsMigrationTest.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/migration/MigrationTest.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/paging/DataSourceFactoryTest.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/ForeignKeyTest.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/MultiInstanceInvalidationTest.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/QueryTransactionTest.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/RxJava2Test.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/RxJava2WithInstantTaskExecutorTest.java
M room/integration-tests/testapp/src/androidTest/java/androidx/room/integration/testapp/test/WriteAheadLoggingTest.java
M room/runtime/api/2.1.0-alpha05.txt
M room/runtime/api/current.txt
M room/runtime/src/main/java/androidx/room/RoomDatabase.java
M room/runtime/src/main/java/androidx/room/paging/LimitOffsetDataSource.java
Description
withContext(Dispatchers.Default) {
db.beginTransaction()
db.insert(data) // DAO suspend function
db.update(anotherData) // DAO suspend function
db.setTransactionSuccessful()
db.endTransaction()
}
This can deadlock because transaction are exclusive and are ThreadLocal, meaning once a transaction is started in a thread form the default dispatcher, another coroutine dispatcher thread will get blocked even if we are within the same coroutine.