BlackLabs / play-morphia

Provide mongodb access service to play.db.Model via Morphia
Apache License 2.0
130 stars 51 forks source link

Maximum permit count exceeded - problem with old mongo java driver? #120

Closed shoon closed 10 years ago

shoon commented 10 years ago

Using the latest 1.4.0 play-morphia, mongodb 2.7.0, java 8

The exception is thrown after a long time running. Looks like fixed problem with the mongo java driver:

https://jira.mongodb.org/browse/JAVA-616

Error occured : Maximum permit count exceeded

play.exceptions.JavaExecutionException: Maximum permit count exceeded
        at play.mvc.ActionInvoker.invoke(ActionInvoker.java:237)
        at Invocation.HTTP Request(Play!)
Caused by: java.lang.Error: Maximum permit count exceeded
        at java.util.concurrent.Semaphore$Sync.tryReleaseShared(Semaphore.java:192)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer.releaseShared(AbstractQueuedSynchronizer.java:1341)
        at java.util.concurrent.Semaphore.release(Semaphore.java:426)
        at com.mongodb.util.SimplePool.done(SimplePool.java:129)
        at com.mongodb.util.SimplePool.done(SimplePool.java:103)
        at com.mongodb.DBTCPConnector$MyPort.done(DBTCPConnector.java:382)
        at com.mongodb.DBTCPConnector.call(DBTCPConnector.java:235)
        at com.mongodb.DBApiLayer$MyCollection.__find(DBApiLayer.java:305)
        at com.mongodb.DBCursor._check(DBCursor.java:369)
        at com.mongodb.DBCursor._hasNext(DBCursor.java:504)
        at com.mongodb.DBCursor.hasNext(DBCursor.java:529)
        at com.google.code.morphia.query.MorphiaIterator.hasNext(MorphiaIterator.java:40)
        at com.google.code.morphia.query.QueryImpl.asList(QueryImpl.java:255)
        at play.modules.morphia.Model$MorphiaQuery.asList(Model.java:1598)
        ...
greenlaw110 commented 10 years ago

Can you try the latest play-morphia 1.5.0 which updates java-mongodb-driver to 2.12.2 version

shoon commented 10 years ago

I upgraded the dep in the dependencies.yml and changed my code with the new namespace:

 find . -name "*.java" -print | xargs sed -i 's/com.google.code.morphia/org.mongodb.morphia/g'

But the app fails to start with the following error:

Caused by: com.mongodb.CommandFailureException: { "serverUsed" : "192.168.1.10:27017" , "ok" : 0.0 , "errmsg" : "Index with name: _created_-1 already
 exists with different options" , "code" : 85}
        at com.mongodb.CommandResult.getException(CommandResult.java:76)
        at com.mongodb.CommandResult.throwOnError(CommandResult.java:131)
        at com.mongodb.DBCollectionImpl.createIndex(DBCollectionImpl.java:347)
        at com.mongodb.DBCollection.createIndex(DBCollection.java:564)
        at com.mongodb.DBCollection.ensureIndex(DBCollection.java:663)
        at org.mongodb.morphia.DatastoreImpl.ensureIndex(DatastoreImpl.java:314)
        at org.mongodb.morphia.DatastoreImpl.processEmbeddedAnnotations(DatastoreImpl.java:393)
        at org.mongodb.morphia.DatastoreImpl.ensureIndexes(DatastoreImpl.java:372)
        at org.mongodb.morphia.DatastoreImpl.ensureIndexes(DatastoreImpl.java:353)
        at org.mongodb.morphia.DatastoreImpl.ensureIndexes(DatastoreImpl.java:348)
        at org.mongodb.morphia.DatastoreImpl.ensureIndexes(DatastoreImpl.java:456)
        at org.mongodb.morphia.DatastoreImpl.ensureIndexes(DatastoreImpl.java:449)
        at play.modules.morphia.MorphiaPlugin.configureDs_(MorphiaPlugin.java:825)
        at play.modules.morphia.MorphiaPlugin.onApplicationStart(MorphiaPlugin.java:697)
        at play.plugins.PluginCollection.onApplicationStart(PluginCollection.java:512)
        at play.Play.start(Play.java:536)

I tried db.collectionName.reIndex() on each of my collections but that didn't resolve the startup error. Any thoughts on how to get past this?

greenlaw110 commented 10 years ago

Can you try to remove indexes in the mongodb shell and try again?

shoon commented 10 years ago

So far so good... here's the mongodb console script:

var collectionNames = db.getCollectionNames();
for(var i = 0, len = collectionNames.length; i < len ; i++){
    var collectionName = collectionNames[i];
    db[collectionName].dropIndexes();
    print(collectionName);
}
greenlaw110 commented 10 years ago

@shoon, if you restart the app are you going to experience the same issue or not?

shoon commented 10 years ago

No problems after deleting the indexes in each collection and restarting the app... it works just fine.

greenlaw110 commented 10 years ago

perfect! BTW thank you for reporting the missing jar issue. I will update the dist to 1.5.0a