# MongoServerError: OplogTruncationFailed: oplog entry truncated during recovery for namespace local.oplog.rs

- **ID:** `mongodb/oplog-truncation-after-point-in-time-recovery`
- **Domain:** mongodb
- **Category:** data_error
- **Verification:** ai_generated
- **Fix Rate:** 70%

## Root Cause

During point-in-time recovery from a backup, the oplog was truncated because the recovery timestamp exceeded the oplog window or the oplog was corrupted.

## Version Compatibility

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

## Workarounds

1. **Perform a full resync of the affected secondary from a healthy primary using rs.reconfig() or initial sync.** (80% success)
   ```
   Perform a full resync of the affected secondary from a healthy primary using rs.reconfig() or initial sync.
   ```
2. **Use mongodump/mongorestore with --oplogReplay to restore from a backup that includes a consistent oplog window.** (75% success)
   ```
   Use mongodump/mongorestore with --oplogReplay to restore from a backup that includes a consistent oplog window.
   ```
3. **If the primary is affected, promote a secondary with a valid oplog using rs.stepDown() and rs.reconfig().** (70% success)
   ```
   If the primary is affected, promote a secondary with a valid oplog using rs.stepDown() and rs.reconfig().
   ```

## Dead Ends

- **** — Oplog size change affects future operations, not past truncation. (90% fail)
- **** — Incompatible backup may have different oplog range, causing further errors. (70% fail)
- **** — Direct modification can corrupt the replica set and cause data loss. (100% fail)
