The oplog minimum retention period sets an age threshold for oplog entries. A secondary performing logical initial sync needs older entries to remain available while it copies data and applies ongoing changes. If those entries disappear first, the secondary can fall off the oplog. section 9.1.3
Configure the threshold for the deployment you operate:
- For mongod, set storage.oplogMinRetentionHours in its configuration file or pass --oplogMinRetentionHours at startup. Without a minimum, MongoDB trims the oldest entries to stay within the oplog size limit. With one set, an entry is deleted only when the size limit has been reached and its age exceeds the specified hours. section 9.1.3
- For an Atlas cluster with storage autoscaling enabled, adjust the minimum oplog retention window in the Atlas UI; its default is 24 hours. Atlas also describes a maximum oplog size, so consider the configured retention window alongside storage limits. section 10.2.4
Listing 9.5 Output of the db.getReplicationInfo() command
db.getReplicationInfo()
{
configuredLogSizeMB: 4096,
logSizeMB: 4096,
usedMB: 4074.63,
timeDiff: 635133,
timeDiffHours: 176.43,
tFirst: 'Wed Mar 20 2024 10:44:15 GMT+0000 (Coordinated Universal Time)',
tLast: 'Wed Mar 27 2024 19:09:48 GMT+0000 (Coordinated Universal Time)',
now: 'Wed Mar 27 2024 19:09:49 GMT+0000 (Coordinated Universal Time)'
}
Use db.getReplicationInfo() to inspect the observed oplog window. The sample reports 176.43 hours between its oldest and newest entries; that observed span is not itself the configured minimum. section 9.1.3
