diff options
author | Randolph Tan <randolph@10gen.com> | 2012-11-12 14:07:44 -0500 |
---|---|---|
committer | Randolph Tan <randolph@10gen.com> | 2012-11-12 18:58:08 -0500 |
commit | 53ffd6d8e442a8d09569845e02e9dee528950481 (patch) | |
tree | 0c1859769391d441e824fba353804428554e3cf3 /jstests | |
parent | 4a3336c9e74381ab67ccdb810e8b99f1c520ab33 (diff) | |
download | mongo-53ffd6d8e442a8d09569845e02e9dee528950481.tar.gz |
SERVER-7612 explicit primary read pref does not work well with shard versioning
Ensure that selectNodeUsingTags will use the same connection to the primary with checkMaster
Diffstat (limited to 'jstests')
-rw-r--r-- | jstests/sharding/read_pref_multi_mongos_stale_config.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/jstests/sharding/read_pref_multi_mongos_stale_config.js b/jstests/sharding/read_pref_multi_mongos_stale_config.js new file mode 100644 index 00000000000..1556adef9e8 --- /dev/null +++ b/jstests/sharding/read_pref_multi_mongos_stale_config.js @@ -0,0 +1,34 @@ +var st = new ShardingTest({ shards: { rs0: { quiet: '' }, rs1: { quiet: '' }}, mongos: 2 }); + +var testDB1 = st.s0.getDB('test'); +var testDB2 = st.s1.getDB('test'); + +// Trigger a query on mongos 1 so it will have a view of test.user as being unsharded. +testDB1.user.findOne(); + +testDB2.adminCommand({ enableSharding: 'test' }); +testDB2.adminCommand({ shardCollection: 'test.user', key: { x: 1 }}); + +testDB2.adminCommand({ split: 'test.user', middle: { x: 100 }}); + +var configDB2 = st.s1.getDB('config'); +var chunkToMove = configDB2.chunks.find().sort({ min: 1 }).next(); +var toShard = configDB2.shards.findOne({ _id: { $ne: chunkToMove.shard }})._id; +testDB2.adminCommand({ moveChunk: 'test.user', to: toShard, find: { x: 50 }}); + +for (var x = 0; x < 200; x++) { + testDB2.user.insert({ x: x }); +} + +testDB2.runCommand({ getLastError: 1 }); + +var cursor = testDB1.user.find({ x: 30 }).readPref('primary'); +assert(cursor.hasNext()); +assert.eq(30, cursor.next().x); + +cursor = testDB1.user.find({ x: 130 }).readPref('primary'); +assert(cursor.hasNext()); +assert.eq(130, cursor.next().x); + +st.stop(); + |