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

Shard depends on string comparison of replica set connection string

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 2.6.6, 2.7.5
    • Affects Version/s: None
    • Component/s: Sharding
    • None
    • ALL
    • Hide
      1. Start a sharded replica set and shard a collection.
      2. Update the shards collection in the config database so the shards are in a different order
        > db.shards.find({_id: "rs0"})
        { "_id" : "rs0", "host" : "rs0/host1.example.com:27017,host2.example.com:27017" }
        > db.shards.update({_id: "rs0"}, { $set: { "host": "rs0/host2.example.com:27017,host1.example.com:27017" }})
        WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
      3. Try to drop a sharded collection on the now-inconsistent shard - you should get
        mongos> db.testcoll.drop()
        Thu Jul 24 10:06:40.696 drop failed: {
            "code" : 13129,
            "ok" : 0,
            "errmsg" : "exception: can't find shard for: rs0/host1.example.com,host2.example.com"
        } at src/mongo/shell/collection.js:383
      Show
      Start a sharded replica set and shard a collection. Update the shards collection in the config database so the shards are in a different order > db.shards.find({_id: "rs0"}) { "_id" : "rs0", "host" : "rs0/host1.example.com:27017,host2.example.com:27017" } > db.shards.update({_id: "rs0"}, { $set: { "host": "rs0/host2.example.com:27017,host1.example.com:27017" }}) WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 }) Try to drop a sharded collection on the now-inconsistent shard - you should get mongos> db.testcoll.drop() Thu Jul 24 10:06:40.696 drop failed: { "code" : 13129, "ok" : 0, "errmsg" : "exception: can't find shard for: rs0/host1.example.com,host2.example.com" } at src/mongo/shell/collection.js:383

      If there's a replicaset reconfiguration, so the order hosts are listed in the connection string changes, then mongos won't be able to find information about the shard, because it does a string comparison of the two connection strings instead of parsing them and comparing the items in the list.

            Assignee:
            randolph@mongodb.com Randolph Tan
            Reporter:
            jonathan.reams@mongodb.com Jonathan Reams
            Votes:
            0 Vote for this issue
            Watchers:
            7 Start watching this issue

              Created:
              Updated:
              Resolved: