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

Cannot add an arbiter to the replicaSet

    • Type: Icon: Bug Bug
    • Resolution: Community Answered
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 5.0.0, 5.0.1
    • Component/s: None
    • Labels:
    • ALL
    • Hide

      Try to add an arbiter node to a replicaSet

      Show
      Try to add an arbiter node to a replicaSet

      TheĀ rs.addArb command doesn't work in MongoDB 5.x.

      rs.addArb('mongodb-arbiter:27017')
      

      We have a replicaSet with 1 primary node, 1 secondary node and are trying to add the arbiter to the replicaSet. However, when running the rs.addArb command, we get this error message

      Error: assert.soon failed: function() {
              var cfg = hostport;
      
              var local = db.getSiblingDB("local");
              assert(local.system.replset.count() <= 1,
                     "error: local.system.replset has unexpected contents");
              var c = local.system.replset.findOne();
              assert(c, "no config object retrievable from local.system.replset");
      
              const attemptedVersion = c.version++;
      
              var max = 0;
              for (var i in c.members) {
                  // Omit 'newlyAdded' field if it exists in the config.
                  delete c.members[i].newlyAdded;
                  if (c.members[i]._id > max)
                      max = c.members[i]._id;
              }
              if (isString(hostport)) {
                  cfg = {_id: max + 1, host: hostport};
                  if (arb)
                      cfg.arbiterOnly = true;
              } else if (arb == true) {
                  throw Error(
                      "Expected first parameter to be a host-and-port string of arbiter, but got " +
                      tojson(hostport));
              }
      
              if (cfg._id == null) {
                  cfg._id = max + 1;
              }
              c.members.push(cfg);
      
              res = self._runCmd({replSetReconfig: c});
              if (res === "") {
                  // _runCmd caught an exception.
                  return true;
              }
              if (res.ok) {
                  return true;
              }
              if (res.code === ErrorCodes.ConfigurationInProgress ||
                  res.code === ErrorCodes.CurrentConfigNotCommittedYet) {
                  return false;  // keep retrying
              }
              if (res.code === ErrorCodes.NewReplicaSetConfigurationIncompatible) {
                  // We will retry only if this error was due to our config version being too low.
                  const cfgState = local.system.replset.findOne();
                  if (cfgState.version >= attemptedVersion) {
                      return false;  // keep retrying
                  }
              }
              // Take no action on other errors.
              return true;
          } : {
              "ok" : 0,
              "errmsg" : "Reconfig attempted to install a config that would change the implicit default write concern. Use the setDefaultRWConcern command to set a cluster-wide write concern and try the reconfig again.",
              "code" : 103,
              "codeName" : "NewReplicaSetConfigurationIncompatible",
              "$clusterTime" : {
                      "clusterTime" : Timestamp(1627634005, 1),
                      "signature" : {
                              "hash" : BinData(0,"0HvodHFBd9MboNymy6f1RCY2YZs="),
                              "keyId" : NumberLong("6990612431667986435")
                      }
              },
              "operationTime" : Timestamp(1627634005, 1)
      } The hang analyzer is automatically called in assert.soon functions. If you are *expecting* assert.soon to possibly fail, call assert.soon with {runHangAnalyzer: false} as the fifth argument (you can fill unused arguments with `undefined`). :
      doassert@src/mongo/shell/assert.js:20:14
      assert.soon@src/mongo/shell/assert.js:382:17
      rs.add@src/mongo/shell/utils.js:1624:5
      rs.addArb@src/mongo/shell/utils.js:1696:12
      @(shell):1:1
      

      The version of MongoDB we are currently using is 5.0.1 and the scripts we use to configure the replicaSet work properly with MongoDB 4.x. We also tried to use rs.add('mongodb-secondary:27017', true) but got the same error. I can confirm that there is connectivity between the primary/secondary node and the arbiter one.

            Assignee:
            dmitry.agranat@mongodb.com Dmitry Agranat
            Reporter:
            jotamartos@gmail.com Juan Jose Martos
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: