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

mongos 2.2 can route to incorrect shard because it doesn't know about hashed shard keys

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: Major - P3 Major - P3
    • None
    • 2.4.0-rc1
    • Sharding
    • None
    • ALL

    Description

      test:

      var options = {
          mongosOptions : {binVersion:MongoRunner.versionIterator(["2.4h","2.4h"]),
                              logpath:"/tmp/stest"},
          configOptions:{binVersion:"2.4h", logpath:"/tmp/stest-config"},
          shardOptions:{binVersion:"2.4h", logpath:"/tmp/sttest-shards"},
          rsOptions:{binVersion:MongoRunner.versionIterator(["2.4h","2.4h"]), logpath:"/tmp/sttest-rs", nopreallocj:""},
          separateConfig:true,
          sync:true,
          rs:true
      }
       
      var st = new ShardingTest({shards:2, mongos:2, other:options})
      shards = st.s0.getDB("config").shards.find().toArray();
       
      coll = st.s0.getDB("foo").bar
      admin = st.s0.getDB("admin")
      var confdb = st.s0.getDB("config")
      coll.createIndex({_id:"hashed"})
      printjson(admin.runCommand({ enableSharding : coll.getDB() + "" }));
      printjson(admin.runCommand({ shardCollection : coll + "", key : { _id : "hashed" } }));
       
      for(var i=1;i<1000;i++){
          coll.insert({_id:i})
      }
       
      var m2 = MongoRunner.runMongos({binVersion:"2.2.0", configdb:st._configDB, port:MongoRunner.nextOpenPort()})
       
      var x1 = st.s0.getDB("foo").bar.findOne({_id:3})
      var x2 = m2.getDB("foo").bar.findOne({_id:3})
      assert.eq(x1, x2)

      in .explain().shards you can see that for the 2.2, the query is being routed to the wrong shard.

      Attachments

        Activity

          People

            dan@mongodb.com Daniel Pasette (Inactive)
            mikeo@mongodb.com Michael O'Brien
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: