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

when running db.getSlaveReplicationInfo() on secondary it treats "self" as "master"

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 3.0.0-rc6
    • Affects Version/s: 2.5.1, 2.8.0-rc4
    • Component/s: Replication, Shell
    • Fully Compatible
    • ALL

      When db.printReplicationInfo() is run on secondary, it call db.printSlaveReplicationInfo() which is written to only work correctly when called on a primary as it uses "self" as "master" in getMaster():

          function getMaster(members) {
              var found;
              members.forEach(function(row) {
                  if (row.self) {
                      found = row;
                      return false;
                  }
              });
      
              if (found) {
                  return found;
              }
          };
      

      This is wrong in that it (a) tests "self" when trying to getMaster. If it finds "self" it ends up returning that member.

      Now printSlaveReplicationInfo is setting this node's optime to compare other nodes against and ends up printing things like:

        -308 secs (-0.09 hrs) behind the primary 
      

      Either it should find primary correctly (change check of "self" to be "state"==1 check) or it should print "behind" me rather than "behind the primary"

            Assignee:
            matt.dannenberg Matt Dannenberg
            Reporter:
            asya.kamsky@mongodb.com Asya Kamsky
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: