[SERVER-8789] mongos 2.2 can route to incorrect shard because it doesn't know about hashed shard keys Created: 28/Feb/13  Updated: 14/Mar/17  Resolved: 13/Jun/13

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: 2.4.0-rc1
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Michael O'Brien Assignee: Daniel Pasette (Inactive)
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Documented
is documented by DOCS-9022 mongos 2.2 can route to incorrect sha... Closed
Duplicate
is duplicated by SERVER-9776 Block migrations on hashed shardkeys ... Closed
Related
Operating System: ALL
Participants:

 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.


Generated at Thu Feb 08 03:18:27 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.