mongodb system_error ai_generated true

MongoServerError: OplogTruncated: replication has fallen too far behind

ID: mongodb/oplog-truncated-during-replication

Also available as: JSON · Markdown · 中文
90%Fix Rate
85%Confidence
1Evidence
2023-09-05First Seen

Version Compatibility

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

Root Cause

A secondary member's replication lag exceeds the oplog window, so the oplog entries needed for catch-up have been overwritten.

generic

中文

从节点的复制延迟超过 oplog 窗口,导致追赶所需的 oplog 条目已被覆盖。

Official Documentation

https://www.mongodb.com/docs/manual/replication/#oplog-size

Workarounds

  1. 95% success Resync the secondary from scratch by removing its data directory and allowing initial sync.
    Resync the secondary from scratch by removing its data directory and allowing initial sync.
  2. 80% success Increase oplog size proactively to prevent future truncation, then resync.
    Increase oplog size proactively to prevent future truncation, then resync.

中文步骤

  1. Resync the secondary from scratch by removing its data directory and allowing initial sync.
  2. Increase oplog size proactively to prevent future truncation, then resync.

Dead Ends

Common approaches that don't work:

  1. 95% fail

    Restarting the secondary does not recover lost oplog; it will still be behind.

  2. 85% fail

    Increasing oplog size after the truncation does not restore already lost entries.