5

MongoDB开发中遇到的问题记录

 2 years ago
source link: https://www.pkslow.com/archives/mongodb-issues-in-development
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
技术之前,先读诗书:

高楼送客不能醉,寂寂寒江明月心。

MongoDB开发中遇到的问题记录

发表于 2020-07-01 | 分类于 其它 | 0 | 阅读次数 2050

com.mongodb.mongowaitqueuefullexception too many threads are already waiting for a connection

com.mongodb.MongoWaitQueueFullException: 
Too many threads are already waiting for a connection. Max number of threads (maxWaitQueueSize) of 500 has been exceeded.

本地启动了太多进程,都在请求连接,超过了最大等待连接数,所以需要增加。

在使用异步程序时,要特别注意线程数问题。

修改连接URI:&waitQueueMultiple=1000&

参考资料:

https://docs.mongodb.com/manual/reference/connection-string/

MongoClientOptions.Builder builder = new MongoClientOptions.Builder();
builder.connectionsPerHost(1000);
MongoClientOptions options = builder.build();
mongoClient = new MongoClient(URI, connectionOptions);

参考资料:

https://stackoverflow.com/questions/25346951/how-can-i-solve-mongowaitqueuefullexception

MongoDB: java.lang.IllegalStateException: state should be: open

因为MongoDB已经关闭了,但程序还在使用。本次问题出现是因为异步程序在使用连接MongoDB,但没有阻塞,直接到后面的连接池关闭。

参考资料:

https://stackoverflow.com/questions/40670865/mongodb-java-lang-illegalstateexception-state-should-be-open


欢迎关注微信公众号<南瓜慢说>,将持续为你更新...

推荐阅读:
如何制定切实可行的计划并好好执行
容器技术(Docker-Kubernetes)
SpringBoot-Cloud相关
Https专题


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK