mongodb
resource_error
ai_generated
true
MongoServerError:连接池耗尽:已达到maxPoolSize 100
MongoServerError: connection pool exhausted: maxPoolSize of 100 reached
ID: mongodb/atlas-connection-pool-exhausted
85%修复率
86%置信度
1证据数
2023-09-12首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| mongodb 7.0 | active | — | — | — |
| mongodb 6.0 | active | — | — | — |
| mongodb 5.0 | active | — | — | — |
| mongodb 4.4 | active | — | — | — |
| mongodb-atlas 1.0 | active | — | — | — |
根因分析
应用程序打开的连接数超过了maxPoolSize限制,通常是由于未关闭的游标或连接泄漏。
English
The application opened more connections than the maxPoolSize limit, often due to unclosed cursors or connection leaks.
官方文档
https://www.mongodb.com/docs/manual/reference/connection-string-options/#maxPoolSize解决方案
-
确保所有游标在try-finally块中关闭:try { cursor = collection.find(); ... } finally { cursor.close(); } -
设置较低的maxPoolSize并监控连接:MongoClient.connect(uri, { maxPoolSize: 50, minPoolSize: 10 })
无效尝试
常见但无效的做法:
-
80% 失败
Leaks will still exhaust the pool eventually, and high connections may overwhelm the server.
-
90% 失败
The leak will reoccur and exhaust the pool again.