mongodb runtime_error ai_generated partial

MongoServerError: RollbackDetected: rollback occurred on replica set member rs1:27017

ID: mongodb/rollback-detected-on-replica-set

Also available as: JSON · Markdown · 中文
80%Fix Rate
86%Confidence
1Evidence
2024-11-05First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
mongodb-5.0 active
mongodb-6.0 active
mongodb-7.0 active

Root Cause

A secondary node in a replica set experienced a rollback because it applied writes that were later overwritten by the primary.

generic

中文

副本集中的从节点发生了回滚,因为它应用了后来被主节点覆盖的写入操作。

Official Documentation

https://www.mongodb.com/docs/manual/core/replica-set-rollbacks/

Workarounds

  1. 80% success Check the rollback data in the rollback/ directory on the affected node and manually restore any necessary documents using mongorestore.
    Check the rollback data in the rollback/ directory on the affected node and manually restore any necessary documents using mongorestore.
  2. 85% success Ensure all secondary nodes have caught up with the primary by monitoring replication lag and increasing oplog size if needed.
    Ensure all secondary nodes have caught up with the primary by monitoring replication lag and increasing oplog size if needed.
  3. 75% success Set writeConcern to majority to reduce the chance of rollbacks by ensuring writes are acknowledged by a majority of nodes.
    Set writeConcern to majority to reduce the chance of rollbacks by ensuring writes are acknowledged by a majority of nodes.

中文步骤

  1. Check the rollback data in the rollback/ directory on the affected node and manually restore any necessary documents using mongorestore.
  2. Ensure all secondary nodes have caught up with the primary by monitoring replication lag and increasing oplog size if needed.
  3. Set writeConcern to majority to reduce the chance of rollbacks by ensuring writes are acknowledged by a majority of nodes.

Dead Ends

Common approaches that don't work:

  1. 50% fail

    Ignoring the rollback and continuing operations can cause data inconsistency between nodes.

  2. 50% fail

    Manually forcing the secondary to become primary without resolving the rollback can cause data loss.

  3. 50% fail

    Decreasing the oplog size to save disk space increases the likelihood of future rollbacks.