mongodb
runtime_error
ai_generated
partial
MongoServerError:RollbackDetected:副本集成员 rs1:27017 上发生回滚
MongoServerError: RollbackDetected: rollback occurred on replica set member rs1:27017
ID: mongodb/rollback-detected-on-replica-set
80%修复率
86%置信度
1证据数
2024-11-05首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| mongodb-5.0 | active | — | — | — |
| mongodb-6.0 | active | — | — | — |
| mongodb-7.0 | active | — | — | — |
根因分析
副本集中的从节点发生了回滚,因为它应用了后来被主节点覆盖的写入操作。
English
A secondary node in a replica set experienced a rollback because it applied writes that were later overwritten by the primary.
官方文档
https://www.mongodb.com/docs/manual/core/replica-set-rollbacks/解决方案
-
Check the rollback data in the rollback/ directory on the affected node and manually restore any necessary documents using mongorestore.
-
Ensure all secondary nodes have caught up with the primary by monitoring replication lag and increasing oplog size if needed.
-
Set writeConcern to majority to reduce the chance of rollbacks by ensuring writes are acknowledged by a majority of nodes.
无效尝试
常见但无效的做法:
-
50% 失败
Ignoring the rollback and continuing operations can cause data inconsistency between nodes.
-
50% 失败
Manually forcing the secondary to become primary without resolving the rollback can cause data loss.
-
50% 失败
Decreasing the oplog size to save disk space increases the likelihood of future rollbacks.