Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-65850

db.printReplication info not consistent when resizing the oplog

    • Type: Icon: Bug Bug
    • Resolution: Works as Designed
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Labels:
      None
    • ALL

      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");
      

      }

            Assignee:
            chris.kelly@mongodb.com Chris Kelly
            Reporter:
            vgrippa@gmail.com Vinicius Grippa
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: