# MongoServerError: OplogQueryNoMoreCursors: no more cursors available for query on namespace local.oplog.rs

- **ID:** `mongodb/oplog-query-no-more-cursors`
- **Domain:** mongodb
- **Category:** resource_error
- **Verification:** ai_generated
- **Fix Rate:** 85%

## Root Cause

The oplog query exhausted all available cursors due to a long-running change stream or tailing cursor without proper cleanup.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| MongoDB 6.0 | active | — | — |
| MongoDB 7.0 | active | — | — |

## Workarounds

1. **Close stale change stream cursors by killing idle cursors: db.currentOp({‘$all’: true}) then db.killOp(opid) for cursors with secs_running > 300.** (90% success)
   ```
   Close stale change stream cursors by killing idle cursors: db.currentOp({‘$all’: true}) then db.killOp(opid) for cursors with secs_running > 300.
   ```
2. **Reduce maxTimeMS on change streams to force automatic cursor expiration: db.collection.watch([], {maxTimeMS: 60000}).** (85% success)
   ```
   Reduce maxTimeMS on change streams to force automatic cursor expiration: db.collection.watch([], {maxTimeMS: 60000}).
   ```

## Dead Ends

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