- Notifications
You must be signed in to change notification settings - Fork 7.6k
Closed
Description
I've tested this with the latest versions of 3.x and 2.x (v3.0.9 and v2.2.20 at the time)
If my understanding is correct, Schedulers.io() should create a new thread if all the other threads are busy. This is not happening here, and it leads to a deadlock.
Flowable.just("item") .observeOn(Schedulers.io()) .firstOrError() .subscribe(__ -> { for (int i = 0; i < 200; i++) { Completable.complete() .observeOn(Schedulers.io()) .blockingAwait(); } System.out.println("Will never reach this"); }); I managed to simplify our code to this minimal reproducible example. I'm aware that .blockingAwait() doesn't make sense here but it does in the original code
The issue is easier to reproduce if the IO thread pool contains just a few threads, but it can still happen with bigger pools.
I think it can be related to some operator releasing the worker too soon. It will work fine if I replace the firstOrError operator like this
Single.just("item") .observeOn(Schedulers.io()) .subscribe(__ -> { for (int i = 0; i < 200; i++) { Completable.complete() .observeOn(Schedulers.io()) .blockingAwait(); } System.out.println("NO problem here"); }); Any help with this is much appreciated.
Cheers
RobertoArtiles