MongoDB - 大量的 MongoCleaner 线程 [英] MongoDB - massive amount of MongoCleaner threads

查看:36
本文介绍了MongoDB - 大量的 MongoCleaner 线程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不知何故,我的 java 应用程序与 mongodb 交谈最终得到了大量名为 MongoCleanerXXX 的停放(休眠)线程,我认为它们来自驱动程序.其中数量约为 600.显然,数据库存在一些连接问题,在 mongod 重新启动后一段时间后确实恢复了.

Somehow my java application talking to mongodb ended up with a huge number of parked (sleeping) threads named MongoCleanerXXX which I presume come from the driver. Number of those was ~600. Apparently there were some connection problems with the database which did recover after some time after mongod was restarted.

MongoDB Java 驱动版本为 2.10.1MongoDB 版本为 2.2.0

MongoDB Java driver version is 2.10.1 MongoDB versions is 2.2.0

这可能是什么原因,作为 MongoDB 的客户端应用程序,我应该做些什么错误?

What could be the reason for this and what I should be doing wrong to cause this as a client app of MongoDB?

推荐答案

如果没有在适当的时间调用 MongoClient.close(),有时我们会看到很多这样的清理线程.

Sometimes we see a lot of these cleanup threads if MongoClient.close() is not called at the appropriate times.

例如:

  • 取消部署 Web 应用程序时(请参阅 JAVA-817)
  • 身份验证失败时(请参阅JAVA-831)

最初有一些清理这些线程的竞争条件,但已修复在 Java 驱动程序的 2.6 版中.

There were originally some race conditions around cleaning up these threads, but this was fixed in version 2.6 of the Java driver.

这篇关于MongoDB - 大量的 MongoCleaner 线程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆