Wie kann ich das Problem lösen MongoWaitQueueFullException?

Ich führe ein java-Programm, das ist ein thread executor-Programm, das fügt Tausende von Dokumenten, die zu einer Tabelle in einer mongodb. Ich bekomme die folgende Fehlermeldung

Exception in thread "pool-1-thread-301" com.mongodb.MongoWaitQueueFullException: Too many threads are already waiting for a connection. Max number of threads (maxWaitQueueSize) of 500 has been exceeded.
    at com.mongodb.PooledConnectionProvider.get(PooledConnectionProvider.java:70)
    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 ScrapResults103$MyRunnable.run(MyProgram.java:368)
    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)

Wie kann ich dies beheben? Bitte helfen Sie mir.

  • Wie viel sollte ich verwenden? Ist die 500 threads wird von meinem Java-Programm oder mongodb limit???
  • Ihr Programm läuft 500 threads. Sie sind wahrscheinlich über eine Art von executor, das erzeugt einen separaten thread für jede Aufgabe. (Eine typische Zahl wäre 5-20ish je nach Aufgabenstellung)
  • Haben Sie jemals um dieses Problem zu lösen ? Ich habe einen Kunden mit dem gleichen Problem, und es wäre toll, ein feedback auf diese.
  • Bitte lösen das problem nicht durch die Erhöhung der Anzahl der threads. Es gibt eine bessere Lösung, jetzt (2018): reactivemongo.org
InformationsquelleAutor sofs1 | 2014-08-17
Schreibe einen Kommentar