diff options
author | Randolph Tan <randolph@10gen.com> | 2018-03-19 15:00:44 -0400 |
---|---|---|
committer | Randolph Tan <randolph@10gen.com> | 2018-04-24 10:01:15 -0400 |
commit | 2d77fd7d723e98e9dc398aea0c6d639e322dc691 (patch) | |
tree | 645c2858b377ac402305f5c4eeb030f113771373 | |
parent | 0e374292088c87a86fee802160ca2467b81d4620 (diff) | |
download | mongo-2d77fd7d723e98e9dc398aea0c6d639e322dc691.tar.gz |
SERVER-33297 mongos create will make a capped collection with size 0 if not specified
-rw-r--r-- | jstests/core/create_collection.js | 2 | ||||
-rw-r--r-- | src/mongo/s/commands/cluster_create_cmd.cpp | 5 |
2 files changed, 7 insertions, 0 deletions
diff --git a/jstests/core/create_collection.js b/jstests/core/create_collection.js index 2ebbd4c0335..1d7f35236bd 100644 --- a/jstests/core/create_collection.js +++ b/jstests/core/create_collection.js @@ -134,4 +134,6 @@ indexSpec = GetIndexHelpers.findByName(db.create_collection.getIndexes(), "_id_"); assert.neq(indexSpec, null); assert.eq(indexSpec.collation.locale, "en_US", tojson(indexSpec)); + + assert.commandFailed(db.createCollection('capped_no_size', {capped: true})); })(); diff --git a/src/mongo/s/commands/cluster_create_cmd.cpp b/src/mongo/s/commands/cluster_create_cmd.cpp index 37ad3d8c0fc..bf8df8a8e54 100644 --- a/src/mongo/s/commands/cluster_create_cmd.cpp +++ b/src/mongo/s/commands/cluster_create_cmd.cpp @@ -74,6 +74,11 @@ public: uassertStatusOK(createShardDatabase(opCtx, dbName)); + uassert(ErrorCodes::InvalidOptions, + "specify size:<n> when capped is true", + !cmdObj["capped"].trueValue() || cmdObj["size"].isNumber() || + cmdObj.hasField("$nExtents")); + ConfigsvrCreateCollection configCreateCmd; configCreateCmd.setNs(nss); |