# MongoServerError: OplogQueryNoMoreCursors: 命名空间 local.oplog.rs 的查询没有更多可用游标

- **ID:** `mongodb/oplog-query-no-more-cursors`
- **领域:** mongodb
- **类别:** resource_error
- **验证级别:** ai_generated
- **修复率:** 85%

## 根因

由于长时间运行的变更流或尾随游标未正确清理，oplog 查询耗尽了所有可用游标。

## 版本兼容性

| 版本 | 状态 | 引入 | 弃用 |
|------|------|------|------|
| MongoDB 6.0 | active | — | — |
| MongoDB 7.0 | active | — | — |

## 解决方案

1. ```
   关闭过期的变更流游标：使用 db.currentOp({'$all': true}) 查找游标，然后对 secs_running > 300 的游标执行 db.killOp(opid)。
   ```
2. ```
   减少变更流的 maxTimeMS 以强制自动过期游标：db.collection.watch([], {maxTimeMS: 60000})。
   ```

## 无效尝试

- **** — Restarting the mongod process temporarily clears cursors but doesn't prevent recurrence. (70% 失败率)
- **** — Increasing oplog size does not affect cursor count, only storage capacity. (90% 失败率)
- **** — Setting cursorTimeoutMillis to a higher value makes the problem worse by keeping cursors open longer. (80% 失败率)
