In case of default replication which is chained replication in mongodb.

Say for example in a 3 NODE replica set :

NODE1 is primary and NODE2 is immediate next to NODE1 and catches up all oplog to become secondary and in sync with primary.

So my NODE3 in a chained replication gets all updates from NODE2 which is my secondary.

On what possible reasons my NODE3 will go out of sync from primary ?

like :

  1. When NODE3 is down for sometime by that time oplog grows on primary far away from this node. Is there a threshold of duration of time when a node can go out of sync?
  2. When NODE3 is far behind some size of oplog than primary. Can max oplog size be configurable so that replication cannot go out of sync ?

With chained replication enabled (by default) and if my NODE3 couldn't sync from either secondary(n2) or primary(n1) then for what reasons my NODE3 can go out of sync from n2 & n1.

How can 'out of sync' be avoided without disabling the chained replication(will add overhead on primary node)?

1 Answer 1


In Mongo 4.4 and newer you can set the storage.oplogMinRetentionHours:

Specifies the minimum number of hours to preserve an oplog entry, where the decimal values represent the fractions of an hour.

By default, the mongod process creates an oplog based on the maximum amount of space available. For 64-bit systems, the oplog is typically 5% of available disk space. When this space is full, then logs are dropped and secondary go out of sync if they were not able to catch these logs.

You can specify the oplog size with parameter replication.oplogSizeMB

  • thanks. for version < 4.4. what is the threshold when mongodb replica secondary node will go out of sync. Is it only because time duration compared to primary increases beyond the threshold or what other conditions my secondary can go out of sync and says we are too stale to sync from either primary or secondary. I want to understand what are other different possibilities where 3rd node says we are too stale to sync with any of the other nodes.
    – unknown
    Jul 22, 2021 at 6:55
  • Please see my update Jul 22, 2021 at 7:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.