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

Auto- and User-Generated-Shard Names May Colide

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Minor - P4 Minor - P4
    • 3.4.9
    • Affects Version/s: 3.0.1
    • Component/s: Sharding
    • None
    • Sharding
    • Fully Compatible
    • ALL
    • Hide
      echo "===> create directories"
      mkdir config s1 s2 s3
      
      echo "===> start mongodb instances:"
      mongod --logpath s1.log --dbpath s1 --port 27016 --fork
      mongod --logpath s2.log --dbpath s2 --port 27015 --fork
      mongod --logpath s3.log --dbpath s3 --port 27014 --fork
      
      mongod --logpath config.log --dbpath config --configsvr --port 27013 --fork
      
      mongos --logpath mongos.log --port 27012 --configdb localhost:27013 --fork
      
      ps -ef | grep mongo
      echo -e "-----\n"
      
      echo "===> add first shard with manual name"
      mongo --port 27012 admin --eval 'printjson(db.runCommand({addShard: "127.0.0.1:27016", name: "shard1"}));'
      echo -e "-----\n"
      
      echo "===> add second shard with automatic name"
      mongo --port 27012 admin --eval 'printjson(sh.addShard("127.0.0.1:27015"));'
      echo -e "-----\n"
      
      echo "===> add third shard with automatic name"
      mongo --port 27012 admin --eval 'printjson(sh.addShard("127.0.0.1:27014"));'
      echo -e "-----\n"
      
      echo "===> sh.status()"
      mongo --port 27012 admin --eval 'printjson(sh.status());'
      echo -e "-----\n"
      
      echo "shutting things down:"
      for port in 27016 27015 27014 27013 27012; do
          echo "shutting down server on $port"
          mongo --port $port admin --quiet --eval "db.shutdownServer()"
      done
      echo -e "-----\n"
      
      ps -ef | grep mongo
      
      Show
      echo "===> create directories" mkdir config s1 s2 s3 echo "===> start mongodb instances:" mongod --logpath s1.log --dbpath s1 --port 27016 --fork mongod --logpath s2.log --dbpath s2 --port 27015 --fork mongod --logpath s3.log --dbpath s3 --port 27014 --fork mongod --logpath config.log --dbpath config --configsvr --port 27013 --fork mongos --logpath mongos.log --port 27012 --configdb localhost:27013 --fork ps -ef | grep mongo echo -e "-----\n" echo "===> add first shard with manual name" mongo --port 27012 admin --eval 'printjson(db.runCommand({addShard: "127.0.0.1:27016", name: "shard1"}));' echo -e "-----\n" echo "===> add second shard with automatic name" mongo --port 27012 admin --eval 'printjson(sh.addShard("127.0.0.1:27015"));' echo -e "-----\n" echo "===> add third shard with automatic name" mongo --port 27012 admin --eval 'printjson(sh.addShard("127.0.0.1:27014"));' echo -e "-----\n" echo "===> sh.status()" mongo --port 27012 admin --eval 'printjson(sh.status());' echo -e "-----\n" echo "shutting things down:" for port in 27016 27015 27014 27013 27012; do echo "shutting down server on $port" mongo --port $port admin --quiet --eval "db.shutdownServer()" done echo -e "-----\n" ps -ef | grep mongo

      When I add a third shard to a cluster where the first one was explicitly named and the second wasn't I get a duplicate key error and cannot add the shard.

      I saw this starting a cluster with mlaunch then adding a second shard.

            Assignee:
            backlog-server-sharding [DO NOT USE] Backlog - Sharding Team
            Reporter:
            john.page@mongodb.com John Page
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: