Spring 5 Reactive - Why that code doesn't consume CPU?

536 Views Asked by At

I'm testing springboot 2.0.0.M3 with spring-webflux and mongodb-reactive driver and don't understand why my code doesn't consume CPU (less than 2%). Memory is ok (70% used in 32GB), I/O are low (hard drive is silently :) ) And Finally i have an error

Caused by: com.mongodb.MongoCursorNotFoundException: Query failed with error code -5 and error message 'Cursor 26041128255 not found on server localhost:27017' on server localhost:27017

I suspect that it tooks too long and after 10 minutes, it throws this exception.

Here the code :

usedKeyRepository.findAll()
   .buffer(4096).parallel()
   .concatMap(listUsedKey -> generatedKeyRepository.bulkFindGeneratedKeysByPub(listUsedKey.stream().map(u -> u.getPub()).collect(Collectors.toSet())))
   .subscribe(clefsTrouvees -> recordMatches(clefsTrouvees),
              ex -> LOG.error("my exception", ex)
);
private void recordMatches(GeneratedKey clefGeneree) {
   LOG.warn("clef : priv:{}\tpub:{}", clefGeneree.getPriv(), clefGeneree.getPub());
}

the usedKeyRepository.findAll() method is

@Autowired
private ReactiveMongoTemplate template;

public Flux<UsedKey> findAll() {
   return template.findAll(UsedKey.class);
}
public Flux<GeneratedKey> bulkFindGeneratedKeysByPub(final Collection<String> pub) {
   Query query = new Query(Criteria.where("pub").in(pub));
   return template.find(query, GeneratedKey.class);
}

My collection usedKey contains 8 millions doc and generatedkey contains 650 millions. Any ideas ? :-/

0

There are 0 best solutions below