MongoDB rollback recovery

MongoDB rollback can remove writes from a former primary so it can rejoin the replica set's accepted history.

During failover, a former primary may contain writes that never reached the replica-set majority. When it reconnects, MongoDB finds a common oplog point, reverses divergent operations and may export affected documents into a rollback directory.

Understand the symptom

Recovery reconciles two valid-looking histories around the last common oplog point.

WHY

What is happening

Replica-set terms, optimes, write concern and rollback identifiers establish which history became authoritative. Rollback files can contain document versions but may not capture every operation after an oplog hole; application logs and surviving snapshots help determine what must be re-applied.

What you may see

Symptoms that change the recovery path.

01

ROLLBACK state appears

The member is reversing operations that diverged from the current primary.

02

Rollback BSON files are created

MongoDB exported documents affected by reverted operations.

03

Users report missing recent writes

Acknowledged data did not become part of the winning replica-set history.

04

Member becomes too stale

Required oplog entries were overwritten and initial sync is requested.

Protect the source

Actions that can make the situation worse.

01

Initial sync overwrites the divergent copy

Unique rolled-back records and oplog context can be removed.

02

Blind BSON import can duplicate or regress data

Documents may have newer valid versions on the current primary.

03

Removing members erases topology evidence

Terms, optimes and common points are needed for reconciliation.

Do this now

Safe steps before evaluation.

01

Freeze member rebuilds

Stop initial sync, data-path deletion and replica reconfiguration.

02

Preserve every dbPath

Snapshot or copy all members and the rollback directory before writes.

03

Capture replica state

Record rs.status, terms, optimes, member IDs, rollback IDs and timestamps.

04

Collect application evidence

Retain order, payment or event logs that identify the business writes in question.

NEPFOSYS process

How a data-first evaluation proceeds.

01

History comparison

NEPFOSYS maps oplogs, common points, rollback files and replica snapshots.

02

Document-level reconciliation

Rolled-back versions are compared with current documents and application evidence.

03

Controlled restoration

Approved missing changes are reintroduced to a protected copy and validated for conflicts.

A clear next step

Preserve the original device before another repair or recovery attempt.

Start a case with the exact symptoms, incident timeline, prior attempts, encryption details, and the files that matter most. NEPFOSYS will route the case to the appropriate DFW intake or nationwide mail-in path.

Start with a case review

Questions, answered

What customers ask before starting.

Does MongoDB save every rolled-back write?

Not always. Rollback files help, but certain interrupted or oplog-hole scenarios can leave gaps that require other evidence.

Can I import the rollback BSON files directly?

Only after comparing current document versions and application rules; blind imports can overwrite newer valid data.

How does majority write concern help?

It reduces the chance that acknowledged writes exist only on a primary that later loses the accepted history, though no design replaces backups.

DFW local · Nationwide mail-in

Protect the device. Start with the facts.

Start my recovery case