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

Adding repl set member as a non-repl set shard succeeds

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.5.3
    • Affects Version/s: 2.5.3
    • Component/s: Sharding
    • Labels:
    • ALL
    • Hide

      Run this jstest:

      /* Startup config servers */
      var configServers = [];
      var configNames = [];
      for (var i = 0; i < 3; i++) {
          var configConf = {
              useHostname: "localhost",
              noJournalPrealloc: true,
              port: 29000 + i,
              pathOpts: { testName: "test", config: i },
              dbpath: "$testName-config$config",
              configsvr: ""
          };
      
          var conn = MongoRunner.runMongod(configConf);
          configServers.push(conn);
          configNames.push(conn.name);
      }
      
      /* Startup mongos */
      var mongosConf = {
          useHostname: "localhost",
          port: 32000,
          pathOpts: { testName: "test", mongos: 0 },
          configdb: configNames.join(','),
          verbose: 1
      };
      
      var mongos = MongoRunner.runMongos(mongosConf);
      
      /* Test adding a replica set member as a non-repl set shard */
      var rst2 = new ReplSetTest({ nodes: 2, smallfiles: '', noprealloc: '' });
      rst2.startSet();
      var cfg2 = rst2.getReplSetConfig();
      rst2.initiate(cfg2);
      
      res = mongos.adminCommand({ addShard: cfg2.members[1].host });
      assert.eq(res.ok, 0, JSON.stringify(res));
      
      Show
      Run this jstest: /* Startup config servers */ var configServers = []; var configNames = []; for ( var i = 0; i < 3; i++) { var configConf = { useHostname: "localhost" , noJournalPrealloc: true , port: 29000 + i, pathOpts: { testName: "test" , config: i }, dbpath: "$testName-config$config" , configsvr: "" }; var conn = MongoRunner.runMongod(configConf); configServers.push(conn); configNames.push(conn.name); } /* Startup mongos */ var mongosConf = { useHostname: "localhost" , port: 32000, pathOpts: { testName: "test" , mongos: 0 }, configdb: configNames.join( ',' ), verbose: 1 }; var mongos = MongoRunner.runMongos(mongosConf); /* Test adding a replica set member as a non-repl set shard */ var rst2 = new ReplSetTest({ nodes: 2, smallfiles: '', noprealloc: ' ' }); rst2.startSet(); var cfg2 = rst2.getReplSetConfig(); rst2.initiate(cfg2); res = mongos.adminCommand({ addShard: cfg2.members[1].host }); assert .eq(res.ok, 0, JSON.stringify(res));

      Repl set members should not be allowed to be added as standalone shards to a cluster. Example:

      If localhost:30000 is part of repl set rs1 it should be added like this:

      db.runCommand({addShard: "rs1/localhost:30000"});
      

      Not this:

      db.runCommand({addShard: "localhost:30000"});
      

      This is a regression. 2.4.6 works fine.

            Assignee:
            randolph@mongodb.com Randolph Tan
            Reporter:
            phillip.quiza Phillip Quiza
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: