I am using room with rxjava and I have one database with 2 tables. The former table has fields id and status, where status can be 0 or 1. The latter has a foreign key which is the id from table 1.
In DAO part, the insert into the latter and the update in the former on a single entry are Completables. These operations happen in an android service, both subscribeOn and observeOn are done on Schedulers.io().
Now in a separate thread, I am subscribing to a Flowable that is a select query on the latter table which retrieves the latest entry that has the associated entry in the former tabel with a status value of 1. The flowable also is subscribedOn and observedOn on Schedulers.io().
Now, I have a certain condition on which I have to insert an entry into the second table and immediately, in doOnComplete of this action, I update the status of the associated element in the first table to value 0. Most of the times I receive updates in flowable, but once in 10-15-20 times, the flowable does not emit anything, as if the update is done before the emission and there is nothing to emit because the condition that status has to be 1 is not met.
I included the insert and the update in the same transaction but it didn't help. I also tried to annotate the query used by flowable to @Transaction, the same result. Once every 10-15-20 times, I don't get an emission. I am also using the latest versions of room, sqlite and rxjava3. I expect to see the update on the table in flowable as soon as the insert is finished. It doesn't matter if the flowable emits after the update is finished, I just wish to receive an emission. If I put a small delay of 5ms between the insert and the update, then there is time for the hook to emit using flowable, but I do not wish to use delays.