[JAVA-2438] com.mongodb.MongoInterruptedException: Interrupted acquiring a permit to retrieve an item from the pool Created: 29/Jan/17 Updated: 11/Sep/19 Resolved: 22/Jun/17 |
|
| Status: | Closed |
| Project: | Java Driver |
| Component/s: | None |
| Affects Version/s: | 3.0.2 |
| Fix Version/s: | None |
| Type: | Task | Priority: | Major - P3 |
| Reporter: | sulabh | Assignee: | Unassigned |
| Resolution: | Incomplete | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Redhat linux, Java, MongoDB java Driver 3.0.2 |
||
| Description |
|
Hi, We are running multiple threads, which are doing reads and writes operation at same point of time. One of the thread is reading from the database with time filter which is big enough to fetch 111000 records in one shot. The field in indexed in the collection. But, while this query is running it closes the connection pool and resulting the com.mongodb.MongoInterruptedException exception. Can you please tell me in what situation already open cursor will be closed abruptly where application has not initiated any close connection command. Below are the mongo-java-driver logs in trace mode. We are running single node of the mongo-database where mongodb version is 2.6.4 (Also tried with 3.2.8 wiredTiger but no luck) and mongo java driver 3.0.2 with java 8 and radhat linux environment. 2017/01/28 15:44:41.279 [MongoDbUtils] [SimpleAsyncTaskExecutor-4]: DEBUG: [588CBB1BE4B0F200BF2094F1] Getting Mongo Database name=[COLLECTIONNAME] ] to server HOST:27017 ] to server HOST:27017 2017/01/28 15:44:41.289 [connection] [pool-2-thread-2]: TRACE: [588CBB3DE4B0F200BF2094FC] Checked in connection [connectionId {localValue:10, serverValue:3246}] to server HOST:27017 ] to HOST:27017 because the pool has been closed. 2017/01/28 15:44:41.290 [connection] [pool-2-thread-2]: TRACE: [588CBB3DE4B0F200BF2094FC] Checked out connection [connectionId {localValue:2, serverValue:3238}] to server HOST:27017 ] to server HOST:27017 ] to server HOST:27017 Caused by: com.mongodb.MongoInterruptedException: Interrupted acquiring a permit to retrieve an item from the pool |
| Comments |
| Comment by Jeffrey Yemin [ 29/Jan/17 ] | ||||||
|
It has nothing to do with any options that your application is setting. As documented here and here the only way Semaphore.acquire throws an InterruptedException is if the application calls Thread.interrupt(). I've confirmed that the driver never calls Thread.interrupt() itself on any application threads. | ||||||
| Comment by sulabh [ 29/Jan/17 ] | ||||||
|
Thanks Jeff for the prompt response. Our application is an standalone application which is not calling Thread.interrupt() in the code, So, what could be the ideal max connection per host size and max time out for MongoOptions since we are getting this error, even we had increased minConnectionsPerHost=20000 and connectTimeout=1000*300 but still we saw the same issue? Or is there any option in the MongoDB java driver 3.0.2 to set, So that MongoDB Driver will recover automatically from this kind of situation? | ||||||
| Comment by Jeffrey Yemin [ 29/Jan/17 ] | ||||||
|
The cursor may be closed abruptly when the application (or more generally, the application server) calls Thread.interrupt() on the thread that is iterating the cursor. It looks something like this:
At any of those interruptible points a concurrent call to Thread.interrupt() on the iterating thread will result in an InterruptedException being thrown. | ||||||
| Comment by sulabh [ 29/Jan/17 ] | ||||||
|
Used MongoDBOption with default configuariont connectionPerHost=100 & maxConnectionTimeout=1000*10 |