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

Nodes should update their own term from the term in heartbeats

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Replication
    • Labels:
      None
    • Replication
    • ALL
    • Hide
      (function() {
          "use strict";
          var replTest = new ReplSetTest({name: 'testSet', nodes: 2});
      
          replTest.startSet();
          replTest.initiate();
      
          var primary = replTest.getPrimary();
          var secondary = replTest.getSecondary();
      
          printjson(primary.getDB("admin").runCommand({replSetGetStatus: 1}));
          jsTestLog("Sending in heartbeat");
          printjson(assert.commandWorked(primary.getDB("admin").runCommand({ replSetHeartbeat: "testSet", configVersion: 1, from: secondary.host, fromId: 1, term: 200 })));
          printjson(primary.getDB("admin").runCommand({replSetGetStatus: 1}));
          replTest.waitForState(replTest.nodes[0], ReplSetTest.State.SECONDARY);
      })();
      
      Show
      (function() { "use strict"; var replTest = new ReplSetTest({name: 'testSet', nodes: 2}); replTest.startSet(); replTest.initiate(); var primary = replTest.getPrimary(); var secondary = replTest.getSecondary(); printjson(primary.getDB("admin").runCommand({replSetGetStatus: 1})); jsTestLog("Sending in heartbeat"); printjson(assert.commandWorked(primary.getDB("admin").runCommand({ replSetHeartbeat: "testSet", configVersion: 1, from: secondary.host, fromId: 1, term: 200 }))); printjson(primary.getDB("admin").runCommand({replSetGetStatus: 1})); replTest.waitForState(replTest.nodes[0], ReplSetTest.State.SECONDARY); })();

      Heartbeats send a term with them, and when the primary receives a term higher than it's own, it should step down. All nodes should update their own term when they see a higher term than their own. Nodes do not currently look at the term in heartbeats and consequently, primaries do not step down when they see higher terms.

            Assignee:
            backlog-server-repl [DO NOT USE] Backlog - Replication Team
            Reporter:
            judah.schvimer@mongodb.com Judah Schvimer
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved: