Zain
Zain

Reputation: 71

MongoDB reactive fails to send complete signals

I'm using spring webflux + mongodb. When a more complex method that merged multiple fluxes returned, I ran into the issue of the flux never completing (the http client being stuck waiting).

In trying to reproduce, the following seems to be the issue:

someRepository.findAll().subscribe([etc...]); Always emits exactly 3855 entities, despite there being 15228 entities in the database. The complete signal is not played. When using a coreSubscriber, the subscriber will be garbage collected when the gc runs, meaning there is basically no way anything was still queued up.

Does anyone know the reason and or a workaround for this issue?

(Tested to happen 100% of the time in versions spring-boot-starter-data-mongodb-reactive 2.0.0.RELEASE, 2.0.3.RELEASE and 2.0.4.RELEASE, assumed to happen in the versions inbetween too. Mongo version: 4.0.0)

Edit: Relevant code:

public interface LocationRepository extends ReactiveMongoRepository<Location, String> {}

and

locationRepository.findAll().subscribe(result -> log.info("RESULT "+result), error -> log.info("ERROR"+error),() -> log.info("DONE"));

Upvotes: 0

Views: 396

Answers (1)

Zain
Zain

Reputation: 71

This later turned out to be a deadlock in the driver. This can be resolved by using the AsynchronousSocketChannelStreamFactoryFactory when configuring mongo

Upvotes: 1

Related Questions