|
Summary: it seems like a read-only load isn't flushing the router config correctly.
I think this was all the steps I did, but it was quite a process so I may have missed something. Basically, I set up two replica set shards, 3 config servers, and two mongoses. I used one mongos as a "admin" mongos that just does setup. I configured another to be an "application" mongos that just does RW (and, once the collection is populated, only reads).
- Start two replica sets:
> // shell 1
|
> rs1 = new ReplSetTest({nodes:3, name:"rs1", startPort:31000})
|
> rs1.startSet()
|
> rs1.initiate()
|
>
|
> // shell 2
|
> rs2 = new ReplSetTest({nodes:3, name:"rs2", startPort:31100})
|
> rs2.startSet()
|
> rs2.initiate()
|
- Start 3 config servers:
$ # shell 3
|
$ ./mongod --port 28000 --dbpath /tmp/config0
|
$
|
$ # shell 4
|
$ ./mongod --port 28001 --dbpath /tmp/config1
|
$
|
$ # shell 5
|
$ ./mongod --port 28002 --dbpath /tmp/config2
|
- Start two mongos processes:
$ # shell 6
|
$ ./mongos --port 30999 --configdb ubuntu:28000,ubuntu:28001,ubuntu:28002
|
$
|
$ # shell 5
|
$ ./mongos --port 40000 --configdb ubuntu:28000,ubuntu:28001,ubuntu:28002
|
- Now, down to business. Connect a new shell to the 30999 mongos. This is the "admin mongos": all sharding config commands will go through here. Add r1 as a shard.
- Open up another shell, this one connected to the mongos at port 40000. This is the "app mongos": all inserts and queries go through this one. Add some data that is trackable:
> ids = []
|
> write = function () {
|
rid=ObjectId();
|
db.foo.insert({_rid:rid});
|
ids.push(rid);
|
}
|
> for (i=0; i<100000; i++) { write(); }
|
- Make the chunk size 1 (through the admin shell).
- Create a loop in the app shell to do random reads of the writes:
> x = function () {
|
var target = ids[Math.floor(Math.random()*ids.length)];
|
if (db.foo.findOne({_rid:target}) == null) {
|
print("Couldn't find "+target);
|
}
|
}
|
> while (true) { x(); sleep(1000); }
|
At this point, the loop should just be sitting there, printing nothing.
- Add the other shard (through the admin shell):
> sh.addShard("rs2/ubuntu:31100")
|
- Enable sharding on the db (through the admin shell):
> sh.enableSharding("test")
|
- Create an index on _rid (through the admin shell):
> use test
|
> db.foo.ensureIndex({_rid:1})
|
- Finally, shard the collection (through the admin shell):
> sh.shardCollection("test.foo", {_rid:1})
|
After ~30 seconds, the infinite "app" loop starts printing that it cannot find ObjectIds!
|