mongodb
runtime_error
ai_generated
partial
MongoServerError: 回滚 ID 不匹配:预期回滚 ID 5 但收到 3,中止操作
MongoServerError: Rollback ID mismatch: expected rollback ID 5 but received 3, aborting operation
ID: mongodb/rollback-id-mismatch
75%修复率
83%置信度
1证据数
2024-09-12首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| MongoDB 5.0 | active | — | — | — |
| MongoDB 6.0 | active | — | — | — |
| MongoDB 7.0 | active | — | — | — |
根因分析
在副本集回滚期间,操作记录的回滚 ID 与当前回滚 ID 不匹配,表示发生了并发回滚或节点状态更改。
English
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.
官方文档
https://www.mongodb.com/docs/manual/reference/command/replSetRollback/解决方案
-
识别不一致的节点并执行完全重新同步:删除数据目录,重启 mongod,并使用 initial sync 从主节点重新同步:db.adminCommand({replSetResync: 1})。 -
如果回滚卡住,在从节点上手动运行 rs.rollback() 强制回滚到一致点,然后重新启用复制。
无效尝试
常见但无效的做法:
-
70% 失败
Restarting the secondary node may trigger another rollback with the same mismatch if the primary has diverged.
-
85% 失败
Forcing the node to become primary with rs.stepDown() on the current primary can cause data inconsistency.