...
This metric gets innacurate when resizing the oplog. The metric is based on the first and last entry of the oplog. If you resize it, you won't have an accurate estimation. We also should take in consideration the : replset:PRIMARY> db.oplog.rs.stats().storageSize replset:PRIMARY> db.oplog.rs.stats().maxSize if your used is space is 50% of the oplog and the oplog window is 10 hours, it would be fair to say that full oplog can retain 20 hours. Suggestion: // Switch to admin database to get a list of databases db = db.getSiblingDB("local"); // gathering oplog max size and oplog used var result = db.getReplicationInfo(); currentOpLogWindow = result.timeDiff; storageSize = result.usedMB; maxSize = result.logSizeMB;print(storageSize + " - " + maxSize)if (storageSize/maxSize < 0.98) { // Estimate oplog window totalOpLogTimeWindow = (maxSize*currentOpLogWindow)/storageSize print (totalOpLogTimeWindow/60/60 + " hours"); }
JIRAUSER1265262 commented on Wed, 4 May 2022 00:51:45 +0000: Hi Vinicius, I was able to generally see what you were talking about with this, and I think the metric you are describing would be helpful alongside what is provided by db.printReplicationInfo(). However, because this is currently working as designed, this appears to be more of a feature request. That is to say, the output of log length from start to end appears to be correct because it correlates with the first oplog event and the last oplog event time. If resized to be larger, it is expected that this would not change. Decreasing it will cause it to truncate from the oldest time. While this may not display how long your oplog can hold necessarily, it is displaying how long the range of time is currently accounted for. In this case, the best way to move would be for you to go ahead and submit this as a feature request over at feedback.mongodb.com. We're starting to direct new feature requests and improvements to that channel and preferring this JIRA project for bug reports specifically. You may also want to search and post on the MongoDB Developer Community Forums, as it's possible there are others who have guidance on how to satisfy your use-case. Thanks for your report! Regards, Christopher