MongoDB problems
MongoDB Oplog Window: How Long a Member Can Be Down, and How to Size It
2 December 2026
The oplog is a capped collection. When it is full, the oldest entries go. The time between its first and last entry is the oplog window: how long a secondary can be down, or behind, and still catch up. The window is a time, but the oplog is sized in bytes, so a busier week makes the same oplog hold fewer hours.
Read the window
rs.printReplicationInfo()
// configured oplog size, log length start to end, first and last event time
"log length start to end" is the window. Run it on the primary and on every member that serves as a sync source; each has its own oplog.
Why it shrinks
- More writes. A new feature, a migration or a bulk job writes more oplog entries per hour into the same bytes.
- Larger writes. Updates that rewrite large documents make large entries.
- Many small updates to the same documents. Each one is an entry, even when the data barely changes.
The default size is 5% of the free disk, between 990 MB and 50 GB. That default was not chosen for your write rate.
Size it from the write rate
- Decide the time you need. The longest a member may be down for maintenance, plus the time an initial sync takes, plus a margin. A day is a common floor.
- Measure the rate. Size used divided by the window gives megabytes an hour. Take a busy hour, not an average day.
- Resize without a restart.
db.adminCommand({ replSetResizeOplog: 1, size: 102400 }), in megabytes, on every member, secondaries first. - Or keep a time.
minRetentionHourskeeps entries for that long even when the oplog is full; the oplog grows on disk to do it, so check the free space. - Check again after each new workload. The window that was a week last year can be a day now.
See it coming
Radar Engine, the detection layer of dbCove, compares the window with its own usual and gives the resize command, with no agent on the server:
| Detector | When it fires |
|---|---|
| Oplog window short | On 3 readings in a row, Watch when the window falls to half its usual (between 1 and 24 hours), Warning at a quarter of its usual (between 1 and 8 hours). The finding gives a replSetResizeOplog command with a size worked out from the measured write rate. |
| Replication lag | The time each secondary has left before it falls off the oplog. |
| Disk filling | The data volume of a member fills, with the day it is full and the collection that grew most. |
dbCove AI reads the oplog statistics and the write history and explains what made the window shrink. It changes nothing without your click.
Questions
What is the MongoDB oplog window?
The time between the oldest and the newest entry in the oplog: how long a member can be offline and still catch up by replication.
How big should the oplog be?
Large enough to hold the longest planned downtime of a member plus an initial sync, at the busiest write rate. Measure the rate with rs.printReplicationInfo() and size from it.
Does resizing the oplog need a restart?
No. replSetResizeOplog changes the size of a running member; run it on each member.
Related problems
Sources
- MongoDB Manual: Replica set oplog, replSetResizeOplog, rs.printReplicationInfo(), Change the oplog size