# MongoServerError: OplogTruncated: replication has fallen too far behind

- **ID:** `mongodb/oplog-truncated-during-replication`
- **Domain:** mongodb
- **Category:** system_error
- **Verification:** ai_generated
- **Fix Rate:** 90%

## Root Cause

A secondary member's replication lag exceeds the oplog window, so the oplog entries needed for catch-up have been overwritten.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| mongodb-4.4 | active | — | — |
| mongodb-5.0 | active | — | — |
| mongodb-6.0 | active | — | — |
| mongodb-7.0 | active | — | — |

## Workarounds

1. **Resync the secondary from scratch by removing its data directory and allowing initial sync.** (95% success)
   ```
   Resync the secondary from scratch by removing its data directory and allowing initial sync.
   ```
2. **Increase oplog size proactively to prevent future truncation, then resync.** (80% success)
   ```
   Increase oplog size proactively to prevent future truncation, then resync.
   ```

## Dead Ends

- **** — Restarting the secondary does not recover lost oplog; it will still be behind. (95% fail)
- **** — Increasing oplog size after the truncation does not restore already lost entries. (85% fail)
