First oplog entry after stepdown has new term but old index

XMLWordPrintableJSON

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

      <old primary>
      rs.stepDown()
      <new primary>
      use local
      db.oplog.rs.find().sort(

      { $natural : -1 }

      ).pretty()

      Show
      <old primary> rs.stepDown() <new primary> use local db.oplog.rs.find().sort( { $natural : -1 } ).pretty()
    • Repl C (11/20/15), Repl D (12/11/15)
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      The below oplog is from the new primary, after another node did rs.stepDown()

      {
      	"ts" : Timestamp(1445630479, 2),
      	"t" : NumberLong(37),
      	"h" : NumberLong("-8385691639698850950"),
      	"v" : 2,
      	"op" : "i",
      	"ns" : "test.test",
      	"o" : {
      		"_id" : ObjectId("562a920ff4a2f080c7fb8d7d"),
      		"foo" : "bar"
      	}
      }
      {
      	"ts" : Timestamp(1445630479, 1),
      	"t" : NumberLong(37),
      	"h" : NumberLong("1854230191406083124"),
      	"v" : 2,
      	"op" : "c",
      	"ns" : "test.$cmd",
      	"o" : {
      		"create" : "test"
      	}
      }
      {
      	"ts" : Timestamp(1445629632, 1856),
      	"t" : NumberLong(37),
      	"h" : NumberLong("-7107662392271914394"),
      	"v" : 2,
      	"op" : "n",
      	"ns" : "",
      	"o" : {
      		"msg" : "new primary"
      	}
      }
      {
      	"ts" : Timestamp(1445629632, 1854),
      	"t" : NumberLong(36),
      	"h" : NumberLong("5763596409837014986"),
      	"v" : 2,
      	"op" : "u",
      	"ns" : "ycsb.usertable",
      	"o2" : {
      		"_id" : "user6709152380272356275"
      	},
      	"o" : {
      		"$set" : {
      			"field2" : BinData(0,"KU91Lj9wIl41KSB8M0RtJidqNk83MFQrOydmIkc1PDkqKFA3PCM4LTB4LV9rNk5tIyUwLTx0JF5rPypqOkAtLTk2I0s7JEA9NUhnMl41KlktNUVzMVdtNzRgMy8sIE1jLUc7KQ==")
      		}
      	}
      }
      

      Note that for the event that says "new primary", the second part of ts should be 0.

      One effect of this is that when the new primary has won its election, but didn't yet commit anything, it can't step down itself:

      319test:PRIMARY> rs.stepDown()
      {
      "ok" : 0,
      "errmsg" : "No electable secondaries caught up as of 2015-10-23T19:51:01.179+0000. Please use

      {force: true}

      to force node to step down.",
      "code" : 50
      }

      Once you issue any write (here an insert) the stepdown succeeds.

            Assignee:
            Benety Goh
            Reporter:
            Henrik Ingo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            8 Start watching this issue

              Created:
              Updated:
              Resolved: