top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Non-blocking asynchronous mongo java/scala driver can block thread - how to deal with that?

+1 vote
387 views

With the non-blocking asynchronous mongo java/scala driver, it is possible to define a wait time and a wait queue size for operations that cannot be executed directly with a free connection. When settings these values, the mongo driver will make the threads waiting for an available connection.

This behavior is very dangerous for an application written with non-blocking asynchronous IO in mind. These applications use a very limited number of threads (= numbers of cores). Blocking one of these thread can block the whole application.

What would be the recommended way to for this kind of applications? Should we set all these waiting settings to 0 and handle MongoWaitQueueFullException with retries in the application? Should the driver call an application callback when a connection is free?

posted Dec 4, 2015 by Sridharan

Looking for an answer?  Promote on:
Facebook Share Button Twitter Share Button LinkedIn Share Button

Similar Questions
0 votes

I am trying to figuring out how to use $sample through the driver.
I know that there is the functionality, I just failed to comprehend how to use it...

+2 votes

Considering working with a shard replica-set cluster, some emergency such as re-pick primary node will happen and maybe we can retry the command several times for waiting for recover of mongo.

Is there anyone know when use c driver api such as mongoc_collection_update, mongoc_collection_commond, mongoc_collection_insert, which error codes tell me that I can retry command for making the application more robust.

0 votes

We recently starting using MongoDB and the new Scala driver library (v 1.1.1). We have not made any custom configurations but we are consistently running out of connections and getting connection timeouts. I worry that we are using the driver incorrectly.

Please see my questions below -

  1. We are using dependency injection to manage the MongoClient. Should be injecting MongoClient or MongoDatabase into all of our CRUD classes?
  2. Should we treat the MongoClient and/or the MongoDatabase as a singleton?
  3. Are there any other common mistakes people have seen with the Scala driver?

Thanks in advance...

+2 votes

I use the mongo c driver to operate the mongodb, I just wonder if the driver has the function of auto re-connection? And if I use a mongodb cluster with three shards, how can I connect all of the Mongos? And how can I do to switch to another mongos when i am using one of the mongos to operate the DB?

Any help is welcome.

0 votes

I am trying to use the truncate feature within YCSB to cause the db to truncate the data set to allow multiple runs against the DB to see the same DB state in spite of previous runs inserts.
I am using -p truncate=true. Is this the correct way to cause a truncate in Mongo.

...