com.mongodb.MongoInterruptedException: A driver operation has been interrupted

1,769 views
Skip to first unread message

Srividhya Shanmugam

unread,
Mar 14, 2014, 8:00:26 AM3/14/14
to mongod...@googlegroups.com
I m getting the following exception in my application

com.mongodb.MongoInterruptedException: A driver operation has been interrupted
at com.mongodb.DBPortPool.get(DBPortPool.java:216)
at com.mongodb.DBTCPConnector$MyPort.get(DBTCPConnector.java:440)
at com.mongodb.DBTCPConnector.say(DBTCPConnector.java:177)
at com.mongodb.DBTCPConnector.say(DBTCPConnector.java:155)
at com.mongodb.DBApiLayer$MyCollection.update(DBApiLayer.java:349)
at com.mongodb.DBCollection.update(DBCollection.java:177)
at com.mongodb.DBCollection.save(DBCollection.java:817)
at com.mongodb.DBCollection.save(DBCollection.java:785)
at cherrypick.ck.datalayer.mongo.MongoDataAccessLayer.saveObject(MongoDataAccessLayer.java:361)
at cherrypick.ck.emailinterface.CKMailMonitor.processIncomingMessage(CKMailMonitor.java:170)
at cherrypick.ck.emailinterface.CKMailMonitor.monitorNewMessages(CKMailMonitor.java:253)
at cherrypick.ck.emailinterface.CKMailMonitor.run(CKMailMonitor.java:275)
Caused by: java.lang.InterruptedException
at java.util.concurrent.locks.AbstractQueuedSynchronizer.tryAcquireSharedNanos(AbstractQueuedSynchronizer.java:1325)
at java.util.concurrent.Semaphore.tryAcquire(Semaphore.java:414)
at com.mongodb.util.SimplePool.permitAcquired(SimplePool.java:148)
at com.mongodb.util.SimplePool.get(SimplePool.java:110)
at com.mongodb.DBPortPool.get(DBPortPool.java:214)

My connection settings are

MongoOptions options = new MongoOptions();

        options.autoConnectRetry = true;
        options.connectionsPerHost = 40;
        options.threadsAllowedToBlockForConnectionMultiplier = 25;

Please help to solve this issue.

Jeff Yemin

unread,
Mar 14, 2014, 11:43:00 AM3/14/14
to mongod...@googlegroups.com
The Java driver itself does not interrupt any threads, so it must be something in your application (or application server) that is interrupting this thread.  Some application servers will interrupt a thread that has not responded after a certain time period, so that is a likely cause.

You might try bumping up connectionsPerHost to a higher value, as it looks like you have contention for connections in the pool.


Regards,
Jeff


--
--
You received this message because you are subscribed to the Google
Groups "mongodb-user" group.
To post to this group, send email to mongod...@googlegroups.com
To unsubscribe from this group, send email to
mongodb-user...@googlegroups.com
See also the IRC channel -- freenode.net#mongodb

---
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Srividhya Shanmugam

unread,
Mar 20, 2014, 6:11:16 AM3/20/14
to mongod...@googlegroups.com
I m doing DB operations in a Thread and I get this exception while querying mongodb. But I m not calling any Thread.interrupt. Please help me to find the problem.

please help me to simulate the problem.

Thanks and Regards,
Vidya

mchelyada

unread,
Sep 23, 2014, 7:07:17 AM9/23/14
to mongod...@googlegroups.com
Btw, 

Looks like I am faced to connection contention issue as well. And I have a suspicion that it is caused not only by small number of connection configured(I have not so small value - 30) and/or big number of threads accessing mongo client, but also "fairness" disabled.
I.e. as far as I can see:

public SimplePool(String name, int size){
        _name = name;
        _size = size;
        _sem = new Semaphore(size);
    }

so semaphore is being instantiated with "fairness" disabled. 
Can that be the case? Have somebody been faced to similar issue?

Thanks,

Jeff Yemin

unread,
Sep 23, 2014, 9:17:20 AM9/23/14
to mongod...@googlegroups.com
Looks like you are using an older version of the driver.  If you upgrade to 2.12.3, fairness is enabled on the Semaphore.  See https://github.com/mongodb/mongo-java-driver/blob/2.12.x/src/main/com/mongodb/ConcurrentPool.java#L54-54.

mchelyada

unread,
Sep 24, 2014, 8:00:39 AM9/24/14
to mongod...@googlegroups.com
Oh, thanks.

I was looking into legacy deprecated class SimplePool instead of this new one.
Will upgrade driver than.
Reply all
Reply to author
Forward
0 new messages