mongodb
resource_error
ai_generated
true
MongoServerError: OplogQueryNoMoreCursors: 命名空间 local.oplog.rs 的查询没有更多可用游标
MongoServerError: OplogQueryNoMoreCursors: no more cursors available for query on namespace local.oplog.rs
ID: mongodb/oplog-query-no-more-cursors
85%修复率
88%置信度
1证据数
2024-02-15首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| MongoDB 6.0 | active | — | — | — |
| MongoDB 7.0 | active | — | — | — |
根因分析
由于长时间运行的变更流或尾随游标未正确清理,oplog 查询耗尽了所有可用游标。
English
The oplog query exhausted all available cursors due to a long-running change stream or tailing cursor without proper cleanup.
官方文档
https://www.mongodb.com/docs/manual/reference/operator/aggregation/changeStream/解决方案
-
关闭过期的变更流游标:使用 db.currentOp({'$all': true}) 查找游标,然后对 secs_running > 300 的游标执行 db.killOp(opid)。 -
减少变更流的 maxTimeMS 以强制自动过期游标:db.collection.watch([], {maxTimeMS: 60000})。
无效尝试
常见但无效的做法:
-
70% 失败
Restarting the mongod process temporarily clears cursors but doesn't prevent recurrence.
-
90% 失败
Increasing oplog size does not affect cursor count, only storage capacity.
-
80% 失败
Setting cursorTimeoutMillis to a higher value makes the problem worse by keeping cursors open longer.