# MongoServerError: Rollback ID mismatch: expected rollback ID 5 but received 3, aborting operation

- **ID:** `mongodb/rollback-id-mismatch`
- **Domain:** mongodb
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 75%

## Root Cause

During a replica set rollback, the operation's recorded rollback ID does not match the current rollback ID, indicating a concurrent rollback or node state change.

## Version Compatibility

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

## Workarounds

1. **Identify the inconsistent node and perform a full resync: remove the data directory, restart mongod, and let it resync from the primary using initial sync: db.adminCommand({replSetResync: 1}).** (80% success)
   ```
   Identify the inconsistent node and perform a full resync: remove the data directory, restart mongod, and let it resync from the primary using initial sync: db.adminCommand({replSetResync: 1}).
   ```
2. **If the rollback is stuck, manually intervene by running rs.rollback() on the secondary to force a rollback to a consistent point, then re-enable replication.** (75% success)
   ```
   If the rollback is stuck, manually intervene by running rs.rollback() on the secondary to force a rollback to a consistent point, then re-enable replication.
   ```

## Dead Ends

- **** — Restarting the secondary node may trigger another rollback with the same mismatch if the primary has diverged. (70% fail)
- **** — Forcing the node to become primary with rs.stepDown() on the current primary can cause data inconsistency. (85% fail)
