Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Interrupted acquiring a permit to retrieve an item from the pool in MongDB

We am seeing a strange error pasted below all of sudden in the Prod environment:

com.mongodb.MongoInterruptedException: Interrupted acquiring a permit to retrieve an item from the pool 
    at com.mongodb.internal.connection.ConcurrentPool.acquirePermit(ConcurrentPool.java:186) 

We have a plain java mongo driver version of 3.0.2.The application code is also in java and deployed in tomcat server.

Sequence of flow which is leading to the cause is :

1.Future task runs across 6 collections and tries to pull data based on certain date 2.Only one of the collection is sharded and it is splitted across three sets.Sets having a primary ,secondary and arbiter.

Is there any special consideration to be done on the connection pool or infra applied on the mongo server environment .Data which resides on the mongo is close to 150GB

Appreciate any response.

like image 227
Amar Avatar asked Dec 04 '16 18:12

Amar


2 Answers

For all those coming across this question:

It happens to me that this problem is arising only when debugging with IntelliJ Idea. If the exception is thrown in the code or in the normal processing flow, the problem doesn't occur.

like image 160
Mauro Avatar answered Oct 19 '22 23:10

Mauro


I had the same issue when called Thread.currentThread().interrupt()

There is even a closed ticket in Jira https://jira.mongodb.org/browse/JAVA-2091 which says

the thread has already been interrupted when the mongo call is made

and

it Works as Designed.

The other question is whether this is correct design, since calling interrupt() on a Thread considered to be the right practice.

I'm not sure that's your case, though.

like image 40
Alex Boyarintsev Avatar answered Oct 19 '22 22:10

Alex Boyarintsev