133 mongodb runtime_error ai_generated partial

MongoServerError: OplogStartMissing: no oplog entry found for timestamp

ID: mongodb/oplog-too-small-for-replication

Also available as: JSON · Markdown · 中文
85%Fix Rate
87%Confidence
1Evidence
2024-03-05First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
mongodb 7.0 active — — —
mongodb 6.0 active — — —
mongodb 5.0 active — — —
mongodb 4.4 active — — —

Root Cause

The secondary replica set member fell too far behind and the primary's oplog has already rolled over the required entry.

generic

中文

副本集从节点落后太多,主节点的操作日志已覆盖所需条目。

Official Documentation

https://www.mongodb.com/docs/manual/tutorial/resync-replica-set-member/

Workarounds

  1. 95% success Resync the secondary by deleting its data directory and restarting: rm -rf /var/lib/mongodb/* && systemctl restart mongod
    Resync the secondary by deleting its data directory and restarting: rm -rf /var/lib/mongodb/* && systemctl restart mongod
  2. 80% success Increase the primary's oplog size to prevent future gaps: db.adminCommand({ replSetResizeOplog: 1, size: 40960 }) (set to 40GB)
    Increase the primary's oplog size to prevent future gaps: db.adminCommand({ replSetResizeOplog: 1, size: 40960 }) (set to 40GB)

中文步骤

  1. 通过删除从节点的数据目录并重启来重新同步:rm -rf /var/lib/mongodb/* && systemctl restart mongod
  2. 增加主节点的操作日志大小以防止未来差距:db.adminCommand({ replSetResizeOplog: 1, size: 40960 })(设置为40GB)

Dead Ends

Common approaches that don't work:

  1. 90% fail

    The oplog gap remains; the secondary will still fail to sync.

  2. 95% fail

    Oplog size is set on the primary; secondary can't modify it.