From a3ade6d9e919f3bd578c50f6db62da40861dfb59 Mon Sep 17 00:00:00 2001 From: Gregory Wlodarek Date: Thu, 11 Apr 2019 08:11:03 -0400 Subject: SERVER-40436 Ignore the 'flags' field from the 'create' command --- jstests/auth/lib/commands_lib.js | 2 +- .../auth/user_management_commands_edge_cases.js | 1 - jstests/auth/user_management_commands_lib.js | 7 +-- jstests/core/collmod.js | 30 ++-------- jstests/core/max_time_ms.js | 2 +- .../causally_consistent_index_builds.js | 4 +- jstests/noPassthrough/apply_ops_mode.js | 1 - jstests/noPassthroughWithMongod/ttl_repl.js | 3 +- jstests/replsets/rollback_all_op_types.js | 2 - .../database_and_shard_versioning_all_commands.js | 2 +- jstests/sharding/read_pref_cmd.js | 2 +- jstests/tool/dumprestore_auth.js | 5 +- src/mongo/db/auth/role_graph_update.cpp | 17 +----- src/mongo/db/catalog/coll_mod.cpp | 65 +--------------------- src/mongo/db/catalog/collection_catalog_entry.h | 6 -- src/mongo/db/catalog/collection_options.cpp | 15 +---- src/mongo/db/catalog/collection_options.h | 8 --- src/mongo/db/catalog/collection_options_test.cpp | 1 - src/mongo/db/commands/create.idl | 2 +- src/mongo/db/commands/dbcommands.cpp | 2 +- src/mongo/db/op_observer_impl_test.cpp | 13 ++--- src/mongo/db/repl/rollback_test_fixture.cpp | 4 +- src/mongo/db/repl/rollback_test_fixture.h | 6 +- src/mongo/db/repl/rs_rollback.cpp | 8 +-- src/mongo/db/repl/rs_rollback_test.cpp | 8 +-- .../db/storage/kv/kv_collection_catalog_entry.cpp | 7 --- .../db/storage/kv/kv_collection_catalog_entry.h | 2 - src/mongo/shell/db.js | 34 +---------- src/mongo/shell/replsettest.js | 21 ++++--- 29 files changed, 49 insertions(+), 231 deletions(-) diff --git a/jstests/auth/lib/commands_lib.js b/jstests/auth/lib/commands_lib.js index 99b6d9a6924..c7508e61cfc 100644 --- a/jstests/auth/lib/commands_lib.js +++ b/jstests/auth/lib/commands_lib.js @@ -2087,7 +2087,7 @@ var authCommandsLib = { }, { testname: "collMod", - command: {collMod: "foo", usePowerOf2Sizes: true}, + command: {collMod: "foo"}, setup: function(db) { db.foo.save({}); }, diff --git a/jstests/auth/user_management_commands_edge_cases.js b/jstests/auth/user_management_commands_edge_cases.js index 51bf9c950fd..f8447ddd7c8 100644 --- a/jstests/auth/user_management_commands_edge_cases.js +++ b/jstests/auth/user_management_commands_edge_cases.js @@ -277,7 +277,6 @@ function runTest(conn) { jsTest.log('Test standalone'); var conn = MongoRunner.runMongod({auth: ''}); -conn.getDB('admin').runCommand({setParameter: 1, newCollectionsUsePowerOf2Sizes: false}); runTest(conn); MongoRunner.stopMongod(conn); diff --git a/jstests/auth/user_management_commands_lib.js b/jstests/auth/user_management_commands_lib.js index 86bf9c13d9e..f05987c2b1d 100644 --- a/jstests/auth/user_management_commands_lib.js +++ b/jstests/auth/user_management_commands_lib.js @@ -114,8 +114,7 @@ function runAllUserManagementCommandsTests(conn, writeConcern) { (function testGrantRolesToUser() { jsTestLog("Testing grantRolesToUser"); - assert.commandFailedWithCode(db.runCommand({collMod: 'foo', usePowerOf2Sizes: true}), - ErrorCodes.Unauthorized); + assert.commandFailedWithCode(db.runCommand({collMod: 'foo'}), ErrorCodes.Unauthorized); testUserAdmin.grantRolesToUser('spencer', [ @@ -127,7 +126,7 @@ function runAllUserManagementCommandsTests(conn, writeConcern) { ], writeConcern); - assert.commandWorked(db.runCommand({collMod: 'foo', usePowerOf2Sizes: true})); + assert.commandWorked(db.runCommand({collMod: 'foo'})); assert.writeOK(db.foo.update({}, {$inc: {a: 1}})); assert.eq(3, db.foo.findOne().a); assert.eq(1, db.foo.count()); @@ -149,7 +148,7 @@ function runAllUserManagementCommandsTests(conn, writeConcern) { ], writeConcern); - assert.commandWorked(db.runCommand({collMod: 'foo', usePowerOf2Sizes: true})); + assert.commandWorked(db.runCommand({collMod: 'foo'})); hasAuthzError(db.foo.update({}, {$inc: {a: 1}})); assert.throws(function() { db.foo.findOne(); diff --git a/jstests/core/collmod.js b/jstests/core/collmod.js index 39db24f8739..6a0081edff6 100644 --- a/jstests/core/collmod.js +++ b/jstests/core/collmod.js @@ -1,6 +1,6 @@ /** * Basic js tests for the collMod command. - * Test setting the usePowerOf2Sizes flag, and modifying TTL indexes. + * Test modifying TTL indexes. * * @tags: [ * # Cannot implicitly shard accessed collections because of collection existing when none @@ -104,36 +104,14 @@ var res = debug(res); assert.eq(0, res.ok, "shouldn't be able to modify faulty index spec"); -// try with new index, this time set both expireAfterSeconds and the usePowerOf2Sizes flag +// try with new index, this time set expireAfterSeconds t.dropIndex({a: 1}); t.ensureIndex({a: 1}, {"expireAfterSeconds": 50}); -var res = db.runCommand({ - "collMod": coll, - "usePowerOf2Sizes": true, - "index": {"keyPattern": {a: 1}, "expireAfterSeconds": 100} -}); +var res = + db.runCommand({"collMod": coll, "index": {"keyPattern": {a: 1}, "expireAfterSeconds": 100}}); debug(res); assert(findTTL({a: 1}, 100), "TTL index should be 100 now"); -// Clear usePowerOf2Sizes and enable noPadding. Make sure collection options.flags is updated. -var res = db.runCommand({"collMod": coll, "usePowerOf2Sizes": false, "noPadding": true}); -debug(res); -assert.commandWorked(res); -var info = findCollectionInfo(); -assert.eq(info.options.flags, 2, tojson(info)); // 2 is CollectionOptions::Flag_NoPadding - -// Clear noPadding and check results object and options.flags. -var res = db.runCommand({"collMod": coll, "noPadding": false}); -debug(res); -assert.commandWorked(res); -if (!isMongos) { - // don't check this for sharding passthrough since mongos has a different output format. - assert.eq(res.noPadding_old, true, tojson(res)); - assert.eq(res.noPadding_new, false, tojson(res)); -} -var info = findCollectionInfo(); -assert.eq(info.options.flags, 0, tojson(info)); - // Tests for collmod over multiple indexes with the same key pattern. t.drop(); assert.commandWorked(db.createCollection(coll)); diff --git a/jstests/core/max_time_ms.js b/jstests/core/max_time_ms.js index 9633f480d62..8a539cc5493 100644 --- a/jstests/core/max_time_ms.js +++ b/jstests/core/max_time_ms.js @@ -417,7 +417,7 @@ assert(res.ok == 1, "expected aggregate with maxtime to succeed, ok=" + res.ok + ", code=" + res.code); // "collMod" command. -res = t.runCommand("collMod", {usePowerOf2Sizes: true, maxTimeMS: 60 * 1000}); +res = t.runCommand("collMod", {maxTimeMS: 60 * 1000}); assert(res.ok == 1, "expected collmod with maxtime to succeed, ok=" + res.ok + ", code=" + res.code); diff --git a/jstests/libs/override_methods/causally_consistent_index_builds.js b/jstests/libs/override_methods/causally_consistent_index_builds.js index 613886431c7..ec20a87f588 100644 --- a/jstests/libs/override_methods/causally_consistent_index_builds.js +++ b/jstests/libs/override_methods/causally_consistent_index_builds.js @@ -24,9 +24,7 @@ return res; } - // The 'usePowerOf2Sizes' option is ignored by the server so no actual collection - // modification takes place. - let collModCmd = {collMod: commandObj[commandName], usePowerOf2Sizes: true}; + let collModCmd = {collMod: commandObj[commandName]}; let collModRes = func.apply(conn, makeFuncArgs(collModCmd)); // If a follow-up collMod fails, another command was likely able to execute after the diff --git a/jstests/noPassthrough/apply_ops_mode.js b/jstests/noPassthrough/apply_ops_mode.js index a4a6e5a838f..3515f4d8040 100644 --- a/jstests/noPassthrough/apply_ops_mode.js +++ b/jstests/noPassthrough/apply_ops_mode.js @@ -85,7 +85,6 @@ db.adminCommand({applyOps: [collModOp], oplogApplicationMode: "ApplyOps"})); // Test default succeeds. - collModOp.o.usePowerOf2Sizes = true; assert.commandWorked(db.adminCommand({ applyOps: [collModOp], })); diff --git a/jstests/noPassthroughWithMongod/ttl_repl.js b/jstests/noPassthroughWithMongod/ttl_repl.js index 78ea6c5d6c6..97257da5ce6 100644 --- a/jstests/noPassthroughWithMongod/ttl_repl.js +++ b/jstests/noPassthroughWithMongod/ttl_repl.js @@ -25,9 +25,8 @@ var slave1db = slave1.getDB('d'); var mastercol = masterdb['c']; var slave1col = slave1db['c']; -// turn off usePowerOf2Sizes as this tests the flag is set automatically mastercol.drop(); -masterdb.createCollection(mastercol.getName(), {usePowerOf2Sizes: false}); +masterdb.createCollection(mastercol.getName()); // create new collection. insert 24 docs, aged at one-hour intervalss now = (new Date()).getTime(); diff --git a/jstests/replsets/rollback_all_op_types.js b/jstests/replsets/rollback_all_op_types.js index 690cff5c4db..7af1a3c654d 100644 --- a/jstests/replsets/rollback_all_op_types.js +++ b/jstests/replsets/rollback_all_op_types.js @@ -176,8 +176,6 @@ op: (db, collName) => { assert.commandWorked(db.runCommand({ collMod: collName, - usePowerOf2Sizes: false, - noPadding: true, validator: {a: 1}, validationLevel: "moderate", validationAction: "warn" diff --git a/jstests/sharding/database_and_shard_versioning_all_commands.js b/jstests/sharding/database_and_shard_versioning_all_commands.js index e3e48cd8ef9..0193cebdb8b 100644 --- a/jstests/sharding/database_and_shard_versioning_all_commands.js +++ b/jstests/sharding/database_and_shard_versioning_all_commands.js @@ -73,7 +73,7 @@ // Expects the collection to exist, and doesn't implicitly create it. assert.commandWorked(mongosConn.getDB(dbName).runCommand({create: collName})); }, - command: {collMod: collName, noPadding: false}, + command: {collMod: collName}, cleanUp: function(mongosConn) { assert(mongosConn.getDB(dbName).getCollection(collName).drop()); } diff --git a/jstests/sharding/read_pref_cmd.js b/jstests/sharding/read_pref_cmd.js index 4a2059276d0..a103338751f 100644 --- a/jstests/sharding/read_pref_cmd.js +++ b/jstests/sharding/read_pref_cmd.js @@ -168,7 +168,7 @@ var testReadPreference = function(conn, hostList, isMongos, mode, tagSets, secEx // Run a no-op command and wait for it to be applied on secondaries. Due to the asynchronous // completion nature of indexes on secondaries, we can guarantee an index build is complete // on all secondaries once all secondaries have applied this collMod command. - assert.commandWorked(testDB.runCommand({collMod: 'user', usePowerOf2Sizes: true})); + assert.commandWorked(testDB.runCommand({collMod: 'user'})); assert.commandWorked(testDB.runCommand({getLastError: 1, w: NODE_COUNT})); // Mongos doesn't implement geoSearch; test it only with ReplicaSetConnection. diff --git a/jstests/tool/dumprestore_auth.js b/jstests/tool/dumprestore_auth.js index a4a19650e77..6dbef63ffeb 100644 --- a/jstests/tool/dumprestore_auth.js +++ b/jstests/tool/dumprestore_auth.js @@ -60,7 +60,7 @@ assert.eq(0, c.count(), "setup1"); c.save({a: 22}); assert.eq(1, c.count(), "setup2"); -assert.commandWorked(c.runCommand("collMod", {usePowerOf2Sizes: false})); +assert.commandWorked(c.runCommand("collMod")); var collections = c.getDB().getCollectionInfos(); var fooColl = null; @@ -70,7 +70,6 @@ collections.forEach(function(coll) { } }); assert.neq(null, fooColl, "foo collection doesn't exist"); -assert(!fooColl.options.flags, "find namespaces 1"); t.runTool("dump", "--out", t.ext, "--username", "backup", "--password", "password"); @@ -103,7 +102,6 @@ collections.forEach(function(coll) { } }); assert.neq(null, fooColl, "foo collection doesn't exist"); -assert(!fooColl.options.flags, "find namespaces 2"); assert.eq(sysUsers, adminDB.system.users.count()); @@ -163,7 +161,6 @@ collections.forEach(function(coll) { } }); assert.neq(null, fooColl, "foo collection doesn't exist"); -assert(!fooColl.options.flags, "find namespaces 3"); assert.eq(sysUsers, adminDB.system.users.count()); diff --git a/src/mongo/db/auth/role_graph_update.cpp b/src/mongo/db/auth/role_graph_update.cpp index 33820f41233..b5956069f85 100644 --- a/src/mongo/db/auth/role_graph_update.cpp +++ b/src/mongo/db/auth/role_graph_update.cpp @@ -327,22 +327,9 @@ Status handleOplogCommand(RoleGraph* roleGraph, const BSONObj& cmdObj) { } } - if (cmdName == "collMod") { + if (cmdName == "collMod" && cmdObj.nFields() == 1) { // We don't care about empty modifications, even if they are on roles collection. - if (cmdObj.nFields() == 1) { - return Status::OK(); - } - - // Some arguments are known to be no-ops. - auto isNoOpArgument = [](const BSONElement& elem) { - return elem.fieldNameStringData() == "usePowerOf2Sizes"; - }; - - // If all arguments are known to be no-ops, we don't care about the operation. - auto argument = std::find_if_not(++cmdObj.begin(), cmdObj.end(), isNoOpArgument); - if (argument == cmdObj.end()) { - return Status::OK(); - } + return Status::OK(); } // No other commands expected. Warn. diff --git a/src/mongo/db/catalog/coll_mod.cpp b/src/mongo/db/catalog/coll_mod.cpp index 1c56a6ae270..bf0c62380c5 100644 --- a/src/mongo/db/catalog/coll_mod.cpp +++ b/src/mongo/db/catalog/coll_mod.cpp @@ -72,8 +72,6 @@ struct CollModRequest { BSONElement collValidator = {}; std::string collValidationAction = {}; std::string collValidationLevel = {}; - BSONElement usePowerOf2Sizes = {}; - BSONElement noPadding = {}; }; StatusWith parseCollModRequest(OperationContext* opCtx, @@ -230,17 +228,9 @@ StatusWith parseCollModRequest(OperationContext* opCtx, return Status(ErrorCodes::InvalidOptions, str::stream() << "option not supported on a view: " << fieldName); } - // As of SERVER-17312 we only support these two options. When SERVER-17320 is - // resolved this will need to be enhanced to handle other options. - typedef CollectionOptions CO; - - if (fieldName == "usePowerOf2Sizes") - cmr.usePowerOf2Sizes = e; - else if (fieldName == "noPadding") - cmr.noPadding = e; - else - return Status(ErrorCodes::InvalidOptions, - str::stream() << "unknown option to collMod: " << fieldName); + + return Status(ErrorCodes::InvalidOptions, + str::stream() << "unknown option to collMod: " << fieldName); } oplogEntryBuilder->append(e); @@ -249,47 +239,6 @@ StatusWith parseCollModRequest(OperationContext* opCtx, return {std::move(cmr)}; } -/** - * Set a collection option flag for 'UsePowerOf2Sizes' or 'NoPadding'. Appends both the new and - * old flag setting to the given 'result' builder. - */ -void setCollectionOptionFlag(OperationContext* opCtx, - Collection* coll, - BSONElement& collOptionElement, - BSONObjBuilder* result) { - const StringData flagName = collOptionElement.fieldNameStringData(); - - int flag; - - if (flagName == "usePowerOf2Sizes") { - flag = CollectionOptions::Flag_UsePowerOf2Sizes; - } else if (flagName == "noPadding") { - flag = CollectionOptions::Flag_NoPadding; - } else { - flag = 0; - } - - CollectionCatalogEntry* cce = coll->getCatalogEntry(); - - const int oldFlags = cce->getCollectionOptions(opCtx).flags; - const bool oldSetting = oldFlags & flag; - const bool newSetting = collOptionElement.trueValue(); - - result->appendBool(flagName.toString() + "_old", oldSetting); - result->appendBool(flagName.toString() + "_new", newSetting); - - const int newFlags = newSetting ? (oldFlags | flag) // set flag - : (oldFlags & ~flag); // clear flag - - // NOTE we do this unconditionally to ensure that we note that the user has - // explicitly set flags, even if they are just setting the default. - cce->updateFlags(opCtx, newFlags); - - const CollectionOptions newOptions = cce->getCollectionOptions(opCtx); - invariant(newOptions.flags == newFlags); - invariant(newOptions.flagsSet); -} - /** * If uuid is specified, add it to the collection specified by nss. This will error if the * collection already has a UUID. @@ -422,14 +371,6 @@ Status _collModInternal(OperationContext* opCtx, if (!cmr.collValidationLevel.empty()) invariant(coll->setValidationLevel(opCtx, cmr.collValidationLevel)); - // UsePowerof2Sizes - if (!cmr.usePowerOf2Sizes.eoo()) - setCollectionOptionFlag(opCtx, coll, cmr.usePowerOf2Sizes, result); - - // NoPadding - if (!cmr.noPadding.eoo()) - setCollectionOptionFlag(opCtx, coll, cmr.noPadding, result); - // Upgrade unique indexes if (upgradeUniqueIndexes) { // A cmdObj with an empty collMod, i.e. nFields = 1, implies that it is a Unique Index diff --git a/src/mongo/db/catalog/collection_catalog_entry.h b/src/mongo/db/catalog/collection_catalog_entry.h index ae2464f37ba..359e3714dee 100644 --- a/src/mongo/db/catalog/collection_catalog_entry.h +++ b/src/mongo/db/catalog/collection_catalog_entry.h @@ -205,12 +205,6 @@ public: virtual void updateIndexMetadata(OperationContext* opCtx, const IndexDescriptor* desc) {} - /** - * Sets the flags field of CollectionOptions to newValue. - * Subsequent calls to getCollectionOptions should have flags==newValue and flagsSet==true. - */ - virtual void updateFlags(OperationContext* opCtx, int newValue) = 0; - /** * Updates the validator for this collection. * diff --git a/src/mongo/db/catalog/collection_options.cpp b/src/mongo/db/catalog/collection_options.cpp index 941c3adf36e..a156754bf14 100644 --- a/src/mongo/db/catalog/collection_options.cpp +++ b/src/mongo/db/catalog/collection_options.cpp @@ -172,8 +172,8 @@ Status CollectionOptions::parse(const BSONObj& options, ParseKind kind) { else autoIndexId = NO; } else if (fieldName == "flags") { - flags = e.numberInt(); - flagsSet = true; + // Ignoring this field as it is deprecated. + continue; } else if (fieldName == "temp") { temp = e.trueValue(); } else if (fieldName == "storageEngine") { @@ -296,9 +296,6 @@ void CollectionOptions::appendBSON(BSONObjBuilder* builder) const { if (autoIndexId != DEFAULT) builder->appendBool("autoIndexId", autoIndexId == YES); - if (flagsSet) - builder->append("flags", flags); - if (temp) builder->appendBool("temp", true); @@ -371,14 +368,6 @@ bool CollectionOptions::matchesStorageOptions(const CollectionOptions& other, return false; } - if (flagsSet != other.flagsSet) { - return false; - } - - if (flags != other.flags) { - return false; - } - if (temp != other.temp) { return false; } diff --git a/src/mongo/db/catalog/collection_options.h b/src/mongo/db/catalog/collection_options.h index 753905d3b7d..2558df0f5ea 100644 --- a/src/mongo/db/catalog/collection_options.h +++ b/src/mongo/db/catalog/collection_options.h @@ -117,14 +117,6 @@ struct CollectionOptions { NO // do not create _id index } autoIndexId = DEFAULT; - // user flags - enum UserFlags { - Flag_UsePowerOf2Sizes = 1 << 0, - Flag_NoPadding = 1 << 1, - }; - int flags = Flag_UsePowerOf2Sizes; // a bitvector of UserFlags - bool flagsSet = false; - bool temp = false; // Storage engine collection options. Always owned or empty. diff --git a/src/mongo/db/catalog/collection_options_test.cpp b/src/mongo/db/catalog/collection_options_test.cpp index 0fe608c9e16..8065c38f207 100644 --- a/src/mongo/db/catalog/collection_options_test.cpp +++ b/src/mongo/db/catalog/collection_options_test.cpp @@ -54,7 +54,6 @@ TEST(CollectionOptions, SimpleRoundTrip) { checkRoundTrip(options); options.setNoIdIndex(); - options.flags = 5; checkRoundTrip(options); } diff --git a/src/mongo/db/commands/create.idl b/src/mongo/db/commands/create.idl index 685b56f483a..576e4521919 100644 --- a/src/mongo/db/commands/create.idl +++ b/src/mongo/db/commands/create.idl @@ -113,5 +113,5 @@ commands: optional: true flags: description: "DEPRECATED" - type: int + type: safeInt32 optional: true diff --git a/src/mongo/db/commands/dbcommands.cpp b/src/mongo/db/commands/dbcommands.cpp index cc993d30dd9..ab42a783d7b 100644 --- a/src/mongo/db/commands/dbcommands.cpp +++ b/src/mongo/db/commands/dbcommands.cpp @@ -606,7 +606,7 @@ public: } std::string help() const override { return "Sets collection options.\n" - "Example: { collMod: 'foo', usePowerOf2Sizes:true }\n" + "Example: { collMod: 'foo', viewOn: 'bar'} " "Example: { collMod: 'foo', index: {keyPattern: {a: 1}, expireAfterSeconds: 600} " "Example: { collMod: 'foo', index: {name: 'bar', expireAfterSeconds: 600} }\n"; } diff --git a/src/mongo/db/op_observer_impl_test.cpp b/src/mongo/db/op_observer_impl_test.cpp index 979e1f2169e..40adb8c515b 100644 --- a/src/mongo/db/op_observer_impl_test.cpp +++ b/src/mongo/db/op_observer_impl_test.cpp @@ -255,8 +255,6 @@ TEST_F(OpObserverTest, CollModWithCollectionOptionsAndTTLInfo) { CollectionOptions oldCollOpts; oldCollOpts.validationLevel = "strict"; oldCollOpts.validationAction = "error"; - oldCollOpts.flags = 2; - oldCollOpts.flagsSet = true; TTLCollModInfo ttlInfo; ttlInfo.expireAfterSeconds = Seconds(10); @@ -288,12 +286,11 @@ TEST_F(OpObserverTest, CollModWithCollectionOptionsAndTTLInfo) { // Ensure that the old collection metadata was saved. auto o2 = oplogEntry.getObjectField("o2"); auto o2Expected = - BSON("collectionOptions_old" << BSON("flags" << oldCollOpts.flags << "validationLevel" - << oldCollOpts.validationLevel - << "validationAction" - << oldCollOpts.validationAction) - << "expireAfterSeconds_old" - << durationCount(ttlInfo.oldExpireAfterSeconds)); + BSON("collectionOptions_old" + << BSON("validationLevel" << oldCollOpts.validationLevel << "validationAction" + << oldCollOpts.validationAction) + << "expireAfterSeconds_old" + << durationCount(ttlInfo.oldExpireAfterSeconds)); ASSERT_BSONOBJ_EQ(o2Expected, o2); } diff --git a/src/mongo/db/repl/rollback_test_fixture.cpp b/src/mongo/db/repl/rollback_test_fixture.cpp index d16e02bf290..e5548d8ad33 100644 --- a/src/mongo/db/repl/rollback_test_fixture.cpp +++ b/src/mongo/db/repl/rollback_test_fixture.cpp @@ -276,8 +276,8 @@ void RollbackResyncsCollectionOptionsTest::resyncCollectionOptionsTest( remoteCollOptionsObj, BSON("collMod" << "coll" - << "noPadding" - << false), + << "validationLevel" + << "strict"), "coll"); } void RollbackResyncsCollectionOptionsTest::resyncCollectionOptionsTest( diff --git a/src/mongo/db/repl/rollback_test_fixture.h b/src/mongo/db/repl/rollback_test_fixture.h index 4424ef7b1fe..8f03742bfd4 100644 --- a/src/mongo/db/repl/rollback_test_fixture.h +++ b/src/mongo/db/repl/rollback_test_fixture.h @@ -278,9 +278,9 @@ private: * 'remoteCollOptionsObj': the collection options object that the sync source will respond with to * the rollback node when it fetches collection metadata. * - * If no command is provided, a collMod operation with a 'noPadding' argument is used to trigger a - * collection metadata resync, since the rollback of collMod operations does not take into account - * the actual command object. It simply re-syncs all the collection options. + * If no command is provided, a collMod operation with a 'validationLevel' argument is used to + * trigger a collection metadata resync, since the rollback of collMod operations does not take into + * account the actual command object. It simply re-syncs all the collection options. */ class RollbackResyncsCollectionOptionsTest : public RollbackTest { diff --git a/src/mongo/db/repl/rs_rollback.cpp b/src/mongo/db/repl/rs_rollback.cpp index 386a688abbf..014052dcb3b 100644 --- a/src/mongo/db/repl/rs_rollback.cpp +++ b/src/mongo/db/repl/rs_rollback.cpp @@ -498,8 +498,7 @@ Status rollback_internal::updateFixUpInfoFromLocalOplogEntry(FixUpInfo& fixUpInf } if (modification == "validator" || modification == "validationAction" || - modification == "validationLevel" || modification == "usePowerOf2Sizes" || - modification == "noPadding") { + modification == "validationLevel") { fixUpInfo.collectionsToResyncMetadata.insert(*uuid); continue; } @@ -1208,11 +1207,6 @@ void rollback_internal::syncFixUp(OperationContext* opCtx, // Set collection to whatever temp status is on the sync source. cce->setIsTemp(opCtx, options.temp); - // Resets collection user flags such as noPadding and usePowerOf2Sizes. - if (options.flagsSet || cce->getCollectionOptions(opCtx).flagsSet) { - cce->updateFlags(opCtx, options.flags); - } - // Set any document validation options. We update the validator fields without // parsing/validation, since we fetched the options object directly from the sync // source, and we should set our validation options to match it exactly. diff --git a/src/mongo/db/repl/rs_rollback_test.cpp b/src/mongo/db/repl/rs_rollback_test.cpp index a9a73e9a54c..2b646b8f3a3 100644 --- a/src/mongo/db/repl/rs_rollback_test.cpp +++ b/src/mongo/db/repl/rs_rollback_test.cpp @@ -1779,8 +1779,8 @@ TEST_F(RSRollbackTest, RollbackCollectionModificationCommand) { BSONObj collModCmd = BSON("collMod" << "t" - << "noPadding" - << false); + << "validationLevel" + << "strict"); auto collectionModificationOperation = makeCommandOp(Timestamp(Seconds(2), 0), coll->uuid().get(), "test.t", collModCmd, 2); @@ -1942,8 +1942,8 @@ TEST_F(RSRollbackTest, RollbackCollectionModificationCommandInvalidCollectionOpt BSONObj collModCmd = BSON("collMod" << "t" - << "noPadding" - << false); + << "validationLevel" + << "strict"); auto collectionModificationOperation = makeCommandOp(Timestamp(Seconds(2), 0), coll->uuid().get(), "test.t", collModCmd, 2); diff --git a/src/mongo/db/storage/kv/kv_collection_catalog_entry.cpp b/src/mongo/db/storage/kv/kv_collection_catalog_entry.cpp index 7907e6d068d..20bad4a699d 100644 --- a/src/mongo/db/storage/kv/kv_collection_catalog_entry.cpp +++ b/src/mongo/db/storage/kv/kv_collection_catalog_entry.cpp @@ -378,13 +378,6 @@ bool KVCollectionCatalogEntry::isEqualToMetadataUUID(OperationContext* opCtx, return md.options.uuid && md.options.uuid == uuid; } -void KVCollectionCatalogEntry::updateFlags(OperationContext* opCtx, int newValue) { - MetaData md = _getMetaData(opCtx); - md.options.flags = newValue; - md.options.flagsSet = true; - _catalog->putMetaData(opCtx, ns().toString(), md); -} - void KVCollectionCatalogEntry::updateValidator(OperationContext* opCtx, const BSONObj& validator, StringData validationLevel, diff --git a/src/mongo/db/storage/kv/kv_collection_catalog_entry.h b/src/mongo/db/storage/kv/kv_collection_catalog_entry.h index 01b4dbe0ffe..bddbd19399a 100644 --- a/src/mongo/db/storage/kv/kv_collection_catalog_entry.h +++ b/src/mongo/db/storage/kv/kv_collection_catalog_entry.h @@ -98,8 +98,6 @@ public: StringData idxName, long long newExpireSeconds) final; - void updateFlags(OperationContext* opCtx, int newValue) final; - void updateIndexMetadata(OperationContext* opCtx, const IndexDescriptor* desc) final; void updateValidator(OperationContext* opCtx, diff --git a/src/mongo/shell/db.js b/src/mongo/shell/db.js index 29c7c549e88..d12e872e417 100644 --- a/src/mongo/shell/db.js +++ b/src/mongo/shell/db.js @@ -297,7 +297,6 @@ var DB; capped: if true, this is a capped collection (where old data rolls out).
  • max: maximum number of objects if capped (optional).
  • -
  • usePowerOf2Sizes: if true, set usePowerOf2Sizes allocation for the collection.
  • storageEngine: BSON document containing storage engine specific options. Format: { @@ -319,42 +318,11 @@ var DB; * @param {String} name Name of new collection to create * @param {Object} options Object with options for call. Options are listed above. - * @return SOMETHING_FIXME + * @return {Object} returned has member ok set to true if operation succeeds, false otherwise. */ DB.prototype.createCollection = function(name, opt) { var options = opt || {}; - // We have special handling for the 'flags' field, and provide sugar for specific flags. If - // the user specifies any flags we send the field in the command. Otherwise, we leave it - // blank and use the server's defaults. - var sendFlags = false; - var flags = 0; - if (options.usePowerOf2Sizes != undefined) { - print( - "WARNING: The 'usePowerOf2Sizes' flag is ignored in 3.0 and higher as all MMAPv1 " + - "collections use fixed allocation sizes unless the 'noPadding' flag is specified"); - - sendFlags = true; - if (options.usePowerOf2Sizes) { - flags |= 1; // Flag_UsePowerOf2Sizes - } - delete options.usePowerOf2Sizes; - } - if (options.noPadding != undefined) { - sendFlags = true; - if (options.noPadding) { - flags |= 2; // Flag_NoPadding - } - delete options.noPadding; - } - - // New flags must be added above here. - if (sendFlags) { - if (options.flags != undefined) - throw Error("Can't set 'flags' with either 'usePowerOf2Sizes' or 'noPadding'"); - options.flags = flags; - } - var cmd = {create: name}; Object.extend(cmd, options); diff --git a/src/mongo/shell/replsettest.js b/src/mongo/shell/replsettest.js index 76a6100de51..d45499ead90 100644 --- a/src/mongo/shell/replsettest.js +++ b/src/mongo/shell/replsettest.js @@ -1494,8 +1494,7 @@ var ReplSetTest = function(opts) { // Run a no-op command and wait for it to be applied on secondaries. Due to the asynchronous // completion nature of indexes on secondaries, we can guarantee an index build is complete // on all secondaries once all secondaries have applied this collMod command. - assert.commandWorked(this.getPrimary().getDB(dbName).runCommand( - {collMod: collName, usePowerOf2Sizes: true})); + assert.commandWorked(this.getPrimary().getDB(dbName).runCommand({collMod: collName})); this.awaitReplication(); }; @@ -1699,16 +1698,11 @@ var ReplSetTest = function(opts) { // filter to take advantage of the fact that a simple 'collection' filter will // skip view evaluation, and therefore won't fail on an invalid view. if (!collInfo.name.startsWith('system.')) { - // 'usePowerOf2Sizes' is ignored by the server so no actual collection - // modification takes place. We intentionally await replication without - // doing any I/O to avoid any overhead from allocating or deleting data - // files when using the MMAPv1 storage engine. We call awaitReplication() - // later on to ensure the collMod is replicated to all nodes. + // We intentionally await replication without doing any I/O to avoid any + // overhead. We call awaitReplication() later on to ensure the collMod + // is replicated to all nodes. try { - assert.commandWorked(dbHandle.runCommand({ - collMod: collInfo.name, - usePowerOf2Sizes: true, - })); + assert.commandWorked(dbHandle.runCommand({collMod: collInfo.name})); } catch (e) { // Ignore NamespaceNotFound errors because a background thread could // have dropped the collection after getCollectionInfos but before @@ -1954,6 +1948,11 @@ var ReplSetTest = function(opts) { primaryInfo.info.uuid = null; secondaryInfo.info.uuid = null; } + + // Ignore the 'flags' collection option as it was removed in 4.2 + primaryInfo.options.flags = null; + secondaryInfo.options.flags = null; + if (!bsonBinaryEqual(secondaryInfo, primaryInfo)) { print(msgPrefix + ', the primary and secondary have different ' + -- cgit v1.2.1