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

Live oplog can be dropped

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.8.0-rc0
    • Affects Version/s: None
    • Component/s: Replication
    • ALL
    • Hide

      var rt = new ReplSetTest(

      {nodes:2, useHostName:false, oplogSize:2}

      )
      rt.startSet()
      rt.initiate()
      var mFoo = rt.getMaster().getDB("test").foo;
      var sFoo = rt.getSecondary().getDB("test").foo;
      var sOplog = rt.getSecondary().getDB("local").oplog.rs
      var mOplog = rt.getPrimary().getDB("local").oplog.rs
      var counts = function () { return {m:mFoo.count(), s:sFoo.count() }}
      mFoo.insert({})
      mFoo.insert({});mFoo.getDB().getLastError(2);
      printjson(sOplog.find().sort({$natural:-1}).limit(-1).next())
      printjson(sOplog.drop())
      printjson(counts())
      mFoo.insert({});mFoo.getDB().getLastError();
      printjson(counts())
      sOplog.getDB().createCollection("oplog.rs",

      {capped:true, size:500000}

      )
      mFoo.insert({});mFoo.getDB().getLastError(2);
      var newEntry = sOplog.find().sort({$natural:-1}).limit(-1).next()
      printjson(newEntry)
      printjson(counts())

      printjson(sOplog.drop())
      mFoo.insert({});mFoo.getDB().getLastError();
      printjson(counts())
      mOplog.getDB().createCollection("oplog.rs",

      {capped:true, size:500000}

      )
      mFoo.insert({});mFoo.getDB().getLastError();
      printjson(counts())
      rt.stopSet()

      Show
      var rt = new ReplSetTest( {nodes:2, useHostName:false, oplogSize:2} ) rt.startSet() rt.initiate() var mFoo = rt.getMaster().getDB("test").foo; var sFoo = rt.getSecondary().getDB("test").foo; var sOplog = rt.getSecondary().getDB("local").oplog.rs var mOplog = rt.getPrimary().getDB("local").oplog.rs var counts = function () { return {m:mFoo.count(), s:sFoo.count() }} mFoo.insert({}) mFoo.insert({});mFoo.getDB().getLastError(2); printjson(sOplog.find().sort({$natural:-1}).limit(-1).next()) printjson(sOplog.drop()) printjson(counts()) mFoo.insert({});mFoo.getDB().getLastError(); printjson(counts()) sOplog.getDB().createCollection("oplog.rs", {capped:true, size:500000} ) mFoo.insert({});mFoo.getDB().getLastError(2); var newEntry = sOplog.find().sort({$natural:-1}).limit(-1).next() printjson(newEntry) printjson(counts()) printjson(sOplog.drop()) mFoo.insert({});mFoo.getDB().getLastError(); printjson(counts()) mOplog.getDB().createCollection("oplog.rs", {capped:true, size:500000} ) mFoo.insert({});mFoo.getDB().getLastError(); printjson(counts()) rt.stopSet()

      During the training, scotthernandez managed to drop the oplog on a slaveDelay secondary that was currently active with:

      db.getSiblingDB("local").oplog.rs.drop()
      
      db.getSiblingDB("local").oplog.rs.stats()
      

      Now returns:

      { "ok" : 0, "errmsg" : "ns not found" }
      

            Assignee:
            milkie@mongodb.com Eric Milkie
            Reporter:
            derick Derick Rethans
            Votes:
            2 Vote for this issue
            Watchers:
            11 Start watching this issue

              Created:
              Updated:
              Resolved: