Hi
When a secondary node starts approaching the end of the available oplog window, the priority should be to increase the oplog retention period before the secondary falls too far behind and requires a full resync. The good news is that modern MongoDB deployments allow you to increase the oplog size online without taking the replica set offline.
Before making changes, I recommend checking the current replication lag and oplog window to understand how much additional headroom is required. As a general best practice, size the oplog to comfortably cover your peak write volume plus any expected maintenance or outage windows. This helps ensure that secondaries have enough time to catch up during periods of heavy load or temporary network issues.
When increasing the oplog size, make sure sufficient free disk space is available on the affected replica set member. Apply the change during a maintenance window if possible, and continue monitoring replication lag, disk utilization, and the oplog window afterward to confirm the adjustment achieved the desired effect. If lag continues to grow even after enlarging the oplog, investigate underlying causes such as slow storage, network bottlenecks, long-running operations, or resource contention on the secondary.
In many environments, increasing the oplog is only part of the solution. Improving secondary performance and reducing write pressure during peak periods can be just as important for maintaining healthy replication. A combination of adequate oplog sizing and ongoing monitoring typically provides the most reliable long-term result.
I hope this helps point you in the right direction. If you find this answer helpful, please hit "accept answer" so I know it addressed your concern.
Jason