diff options
author | Randolph Tan <randolph@10gen.com> | 2014-07-07 16:04:56 -0400 |
---|---|---|
committer | Randolph Tan <randolph@10gen.com> | 2014-07-23 16:25:23 -0400 |
commit | 0e8a436fdedc9a56ddd4e773d45d7963a8f358a6 (patch) | |
tree | b50e5a3a32d58c358f0baf83b534326f49ee9b75 /jstests/sharding/split_large_key.js | |
parent | eda239c6d3caeb6f68189672cf331e80bbc7faae (diff) | |
download | mongo-0e8a436fdedc9a56ddd4e773d45d7963a8f358a6.tar.gz |
SERVER-14431 Invalid chunk data after splitting on a key that's too large to index
Diffstat (limited to 'jstests/sharding/split_large_key.js')
-rw-r--r-- | jstests/sharding/split_large_key.js | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/jstests/sharding/split_large_key.js b/jstests/sharding/split_large_key.js new file mode 100644 index 00000000000..5184a120ad6 --- /dev/null +++ b/jstests/sharding/split_large_key.js @@ -0,0 +1,34 @@ +// Test for splitting a chunk with a very large shard key value should not be allowed +// and does not corrupt the config.chunks metadata. + +var st = new ShardingTest({ shards: 1 }); +var configDB = st.s.getDB('config'); + +configDB.adminCommand({ enableSharding: 'test' }); +configDB.adminCommand({ shardCollection: 'test.user', key: { x: 1 }}); + +var str1k = new Array(512).join('a'); +var res = configDB.adminCommand({ split: 'test.user', middle: { x: str1k }}); +assert(!res.ok); +assert(res.errmsg != null); + +// Verify chunk document +assert.eq(1, configDB.chunks.find().count()); +var chunkDoc = configDB.chunks.findOne(); +assert.eq(0, bsonWoCompare(chunkDoc.min, { x: MinKey })); +assert.eq(0, bsonWoCompare(chunkDoc.max, { x: MaxKey })); + +configDB.adminCommand({ shardCollection: 'test.user2', key: { x: 1, y: 1 }}); +var strHalfk = new Array(256).join('a'); +res = configDB.adminCommand({ split: 'test.user2', middle: { x: strHalfk, y: strHalfk }}); +assert(!res.ok); +assert(res.errmsg != null); + +// Verify chunk document +assert.eq(1, configDB.chunks.find({ ns: 'test.user2' }).count()); +chunkDoc = configDB.chunks.findOne({ ns: 'test.user2' }); +assert.eq(0, bsonWoCompare(chunkDoc.min, { x: MinKey, y: MinKey })); +assert.eq(0, bsonWoCompare(chunkDoc.max, { x: MaxKey, y: MaxKey })); + +st.stop(); + |