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

Update mongo shell sh.getBalancerHost() method for 3.4

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.4.0-rc3
    • Affects Version/s: None
    • Component/s: Sharding
    • None
    • Fully Compatible
    • ALL
    • Hide

      1. Start up a sharded cluster.
      2. Shard a collection.
      3. run sh.getBalancerHost()

      Show
      1. Start up a sharded cluster. 2. Shard a collection. 3. run sh.getBalancerHost()
    • Sharding 2016-11-21

      Since in 3.4, balancer runs on primary of CSRS and the lock document is:

      db.locks.findOne( {_id: "balancer"})
      {
      	"_id" : "balancer",
      	"state" : 2,
      	"ts" : ObjectId("581178035b3b7dcb772022cd"),
      	"who" : "ConfigServer:Balancer",
      	"process" : "ConfigServer",
      	"when" : ISODate("2016-10-27T03:44:03.007Z"),
      	"why" : "CSRS Balancer"
      }
      

      The sh.getBalancerHost() method needs to be updated since it still expects the hostname for the mongos:

      function (configDB) {
          if (configDB === undefined)
              configDB = sh._getConfigDB();
          var x = configDB.locks.findOne({_id: "balancer"});
          if (x == null) {
              print(
                  "config.locks collection does not contain balancer lock. be sure you
      are connected to a mongos");
              return "";
          }
          return x.process.match(/[^:]+:[^:]+/)[0];
      }
      
      

            Assignee:
            misha.tyulenev@mongodb.com Misha Tyulenev (Inactive)
            Reporter:
            kay.kim@mongodb.com Kay Kim (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: