Room & Store4 Deadlock Test

A test sample for deadlock issue with Room and Store4

Original problems

When calling store.get() in the RoomDatabase.withTransaction {} and the store trigger the writer to write data into the database, a deadlock will occur. Everything is fine if the writer does not trigger or calling the store.get() outside the withTransaction {}.

To Reproduce

  • clear the Room’s table that the Store used
  • call store.get() inside the RoomDatabase.withTransaction {}

Reason

withTransaction() could only use the same coroutineScope that receive by the suspending block to perform blocking database operation. So this is the limitation of Room which let the usage of Store inside withTransaction() impossible Screen Shot 2022-09-27 at 9 52 25 PM

Related issue

MobileNativeFoundation/Store#453

GitHub

View Github