sofs1
sofs1

Reputation: 4176

How to resolve MongoDB client error "Timeout waiting for a pooled item after 120000 MILLISECONDS"

I have a Java class (not Java Spring or server) which

  1. inserts documents to one table,
  2. reads documents from other table,
  3. insert documents to another table and
  4. delete documents from another table.

All above 4 operations happens with 3 tables.

I get the following error.

Exception in thread "pool-1-thread-240" com.mongodb.MongoTimeoutException: Timeout waiting for a pooled item after 120000 MILLISECONDS
    at com.mongodb.ConcurrentPool.get(ConcurrentPool.java:113)
    at com.mongodb.PooledConnectionProvider.get(PooledConnectionProvider.java:75)
    at com.mongodb.DefaultServer.getConnection(DefaultServer.java:73)
    at com.mongodb.BaseCluster$WrappedServer.getConnection(BaseCluster.java:221)
    at com.mongodb.DBTCPConnector$MyPort.getConnection(DBTCPConnector.java:508)
    at com.mongodb.DBTCPConnector$MyPort.get(DBTCPConnector.java:456)
    at com.mongodb.DBTCPConnector.getPrimaryPort(DBTCPConnector.java:414)
    at com.mongodb.DBCollectionImpl.insert(DBCollectionImpl.java:176)
    at com.mongodb.DBCollectionImpl.insert(DBCollectionImpl.java:159)
    at com.mongodb.DBCollection.insert(DBCollection.java:93)
    at com.mongodb.DBCollection.insert(DBCollection.java:78)
    at com.mongodb.DBCollection.insert(DBCollection.java:120)
    at MyProgram$MyClass.run(MyProgram.java:149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:895)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:918)
    at java.lang.Thread.run(Thread.java:695)
  1. How can I fix it? I am using mongod 2.6.3 in Mac OS System.
  2. Should I increase the mongodb pool in my client side.
  3. If yes, how should I do it?
  4. What is the maximum number to which I can set it?

I get this problem for the line in my java code where I do insert operation.

Upvotes: 4

Views: 9255

Answers (1)

Lombric
Lombric

Reputation: 838

The default pool connection number is 100 and the maximum pool size is 20 for a single MongoDB instance.

For resolve your problem take this article in consideration

Upvotes: -1

Related Questions