From 134a4083953270e8a11430395357fb70a29047ad Mon Sep 17 00:00:00 2001 From: "clang-format-7.0.1" Date: Fri, 26 Jul 2019 18:20:35 -0400 Subject: SERVER-41772 Apply clang-format 7.0.1 to the codebase --- src/mongo/db/catalog/capped_utils.cpp | 14 +- src/mongo/db/catalog/catalog_control.cpp | 7 +- src/mongo/db/catalog/coll_mod.cpp | 17 +- src/mongo/db/catalog/collection_catalog.h | 5 +- src/mongo/db/catalog/collection_catalog_test.cpp | 2 +- src/mongo/db/catalog/collection_compact.cpp | 4 +- src/mongo/db/catalog/collection_compact.h | 6 +- src/mongo/db/catalog/collection_impl.cpp | 37 +- src/mongo/db/catalog/collection_options.cpp | 8 +- src/mongo/db/catalog/collection_options.h | 2 +- src/mongo/db/catalog/collection_validation.cpp | 6 +- src/mongo/db/catalog/create_collection.cpp | 9 +- src/mongo/db/catalog/database_holder_impl.cpp | 8 +- src/mongo/db/catalog/database_impl.cpp | 22 +- src/mongo/db/catalog/database_test.cpp | 73 ++-- src/mongo/db/catalog/document_validation.h | 2 +- src/mongo/db/catalog/drop_database.cpp | 25 +- src/mongo/db/catalog/drop_database_test.cpp | 8 +- src/mongo/db/catalog/drop_indexes.cpp | 33 +- src/mongo/db/catalog/health_log.cpp | 4 +- src/mongo/db/catalog/health_log.h | 2 +- src/mongo/db/catalog/index_build_block.cpp | 20 +- src/mongo/db/catalog/index_builds_manager.cpp | 3 +- src/mongo/db/catalog/index_builds_manager_test.cpp | 3 +- src/mongo/db/catalog/index_catalog_entry_impl.cpp | 12 +- src/mongo/db/catalog/index_catalog_impl.cpp | 81 ++--- src/mongo/db/catalog/index_consistency.cpp | 3 +- src/mongo/db/catalog/index_key_validate.cpp | 74 ++-- src/mongo/db/catalog/index_key_validate_test.cpp | 6 +- src/mongo/db/catalog/index_spec_validate_test.cpp | 379 +++++++-------------- src/mongo/db/catalog/index_timestamp_helper.h | 4 +- src/mongo/db/catalog/multi_index_block.cpp | 17 +- .../db/catalog/record_store_validate_adaptor.cpp | 20 +- .../db/catalog/record_store_validate_adaptor.h | 2 +- src/mongo/db/catalog/rename_collection.cpp | 29 +- src/mongo/db/catalog/rename_collection_test.cpp | 37 +- src/mongo/db/catalog/util/partitioned.h | 2 +- src/mongo/db/catalog/util/partitioned_test.cpp | 1 - 38 files changed, 380 insertions(+), 607 deletions(-) (limited to 'src/mongo/db/catalog') diff --git a/src/mongo/db/catalog/capped_utils.cpp b/src/mongo/db/catalog/capped_utils.cpp index c7ceead85a0..89d3719d095 100644 --- a/src/mongo/db/catalog/capped_utils.cpp +++ b/src/mongo/db/catalog/capped_utils.cpp @@ -64,8 +64,8 @@ Status emptyCapped(OperationContext* opCtx, const NamespaceString& collectionNam if (userInitiatedWritesAndNotPrimary) { return Status(ErrorCodes::NotMaster, - str::stream() << "Not primary while truncating collection: " - << collectionName); + str::stream() + << "Not primary while truncating collection: " << collectionName); } Database* db = autoDb.getDb(); @@ -86,8 +86,8 @@ Status emptyCapped(OperationContext* opCtx, const NamespaceString& collectionNam repl::ReplicationCoordinator::modeNone) && collectionName.isOplog()) { return Status(ErrorCodes::OplogOperationUnsupported, - str::stream() << "Cannot truncate a live oplog while replicating: " - << collectionName); + str::stream() + << "Cannot truncate a live oplog while replicating: " << collectionName); } BackgroundOperation::assertNoBgOpInProgForNs(collectionName.ns()); @@ -134,8 +134,7 @@ void cloneCollectionAsCapped(OperationContext* opCtx, uassert(ErrorCodes::NamespaceExists, str::stream() << "cloneCollectionAsCapped failed - destination collection " << toNss - << " already exists. source collection: " - << fromNss, + << " already exists. source collection: " << fromNss, !db->getCollection(opCtx, toNss)); // create new collection @@ -263,8 +262,7 @@ void convertToCapped(OperationContext* opCtx, uassertStatusOKWithContext(tmpNameResult, str::stream() << "Cannot generate temporary collection namespace to convert " - << collectionName - << " to a capped collection"); + << collectionName << " to a capped collection"); const auto& longTmpName = tmpNameResult.getValue(); const auto shortTmpName = longTmpName.coll().toString(); diff --git a/src/mongo/db/catalog/catalog_control.cpp b/src/mongo/db/catalog/catalog_control.cpp index ab925ab0a97..4bc4dde890d 100644 --- a/src/mongo/db/catalog/catalog_control.cpp +++ b/src/mongo/db/catalog/catalog_control.cpp @@ -125,8 +125,7 @@ void openCatalog(OperationContext* opCtx, const MinVisibleTimestampMap& minVisib fassert(40689, {ErrorCodes::InternalError, str::stream() << "failed to get index spec for index " << indexName - << " in collection " - << collNss.toString()}); + << " in collection " << collNss.toString()}); } auto indexesToRebuild = indexSpecs.getValue(); invariant( @@ -171,8 +170,8 @@ void openCatalog(OperationContext* opCtx, const MinVisibleTimestampMap& minVisib // Note that the collection name already includes the database component. auto collection = db->getCollection(opCtx, collNss); invariant(collection, - str::stream() << "failed to get valid collection pointer for namespace " - << collNss); + str::stream() + << "failed to get valid collection pointer for namespace " << collNss); if (minVisibleTimestampMap.count(collection->uuid()) > 0) { collection->setMinimumVisibleSnapshot( diff --git a/src/mongo/db/catalog/coll_mod.cpp b/src/mongo/db/catalog/coll_mod.cpp index 45c57acc17a..c881c88df99 100644 --- a/src/mongo/db/catalog/coll_mod.cpp +++ b/src/mongo/db/catalog/coll_mod.cpp @@ -134,8 +134,8 @@ StatusWith parseCollModRequest(OperationContext* opCtx, cmr.idx = coll->getIndexCatalog()->findIndexByName(opCtx, indexName); if (!cmr.idx) { return Status(ErrorCodes::IndexNotFound, - str::stream() << "cannot find index " << indexName << " for ns " - << nss); + str::stream() + << "cannot find index " << indexName << " for ns " << nss); } } else { std::vector indexes; @@ -145,17 +145,14 @@ StatusWith parseCollModRequest(OperationContext* opCtx, if (indexes.size() > 1) { return Status(ErrorCodes::AmbiguousIndexKeyPattern, str::stream() << "index keyPattern " << keyPattern << " matches " - << indexes.size() - << " indexes," + << indexes.size() << " indexes," << " must use index name. " - << "Conflicting indexes:" - << indexes[0]->infoObj() - << ", " - << indexes[1]->infoObj()); + << "Conflicting indexes:" << indexes[0]->infoObj() + << ", " << indexes[1]->infoObj()); } else if (indexes.empty()) { return Status(ErrorCodes::IndexNotFound, - str::stream() << "cannot find index " << keyPattern << " for ns " - << nss); + str::stream() + << "cannot find index " << keyPattern << " for ns " << nss); } cmr.idx = indexes[0]; diff --git a/src/mongo/db/catalog/collection_catalog.h b/src/mongo/db/catalog/collection_catalog.h index 6e508db8f5c..2021ba83cec 100644 --- a/src/mongo/db/catalog/collection_catalog.h +++ b/src/mongo/db/catalog/collection_catalog.h @@ -252,9 +252,8 @@ private: mongo::stdx::unordered_map> _shadowCatalog; - using CollectionCatalogMap = mongo::stdx::unordered_map, - CollectionUUID::Hash>; + using CollectionCatalogMap = mongo::stdx:: + unordered_map, CollectionUUID::Hash>; using OrderedCollectionMap = std::map, Collection*>; using NamespaceCollectionMap = mongo::stdx::unordered_map; CollectionCatalogMap _catalog; diff --git a/src/mongo/db/catalog/collection_catalog_test.cpp b/src/mongo/db/catalog/collection_catalog_test.cpp index e9985074fd8..205a5647e75 100644 --- a/src/mongo/db/catalog/collection_catalog_test.cpp +++ b/src/mongo/db/catalog/collection_catalog_test.cpp @@ -121,7 +121,7 @@ public: void checkCollections(std::string dbName) { unsigned long counter = 0; - for (auto[orderedIt, catalogIt] = std::tuple{collsIterator(dbName), catalog.begin(dbName)}; + for (auto [orderedIt, catalogIt] = std::tuple{collsIterator(dbName), catalog.begin(dbName)}; catalogIt != catalog.end() && orderedIt != collsIteratorEnd(dbName); ++catalogIt, ++orderedIt) { diff --git a/src/mongo/db/catalog/collection_compact.cpp b/src/mongo/db/catalog/collection_compact.cpp index eae4770532d..93281c0e541 100644 --- a/src/mongo/db/catalog/collection_compact.cpp +++ b/src/mongo/db/catalog/collection_compact.cpp @@ -148,9 +148,7 @@ StatusWith compactCollection(OperationContext* opCtx, return StatusWith( ErrorCodes::CannotCreateIndex, str::stream() << "Cannot compact collection due to invalid index " << spec - << ": " - << keyStatus.reason() - << " For more info see" + << ": " << keyStatus.reason() << " For more info see" << " http://dochub.mongodb.org/core/index-validation"); } indexSpecs.push_back(spec); diff --git a/src/mongo/db/catalog/collection_compact.h b/src/mongo/db/catalog/collection_compact.h index a3aefc1833e..719ae06c47b 100644 --- a/src/mongo/db/catalog/collection_compact.h +++ b/src/mongo/db/catalog/collection_compact.h @@ -35,9 +35,9 @@ namespace mongo { /** - * Compacts collection. - * See record_store.h for CompactStats and CompactOptions definitions. - */ + * Compacts collection. + * See record_store.h for CompactStats and CompactOptions definitions. + */ StatusWith compactCollection(OperationContext* opCtx, const NamespaceString& collectionNss, const CompactOptions* options); diff --git a/src/mongo/db/catalog/collection_impl.cpp b/src/mongo/db/catalog/collection_impl.cpp index de9a80f070d..6ebdaf1ec51 100644 --- a/src/mongo/db/catalog/collection_impl.cpp +++ b/src/mongo/db/catalog/collection_impl.cpp @@ -320,17 +320,13 @@ StatusWithMatchExpression CollectionImpl::parseValidator( if (ns().isSystem() && !ns().isDropPendingNamespace()) { return {ErrorCodes::InvalidOptions, str::stream() << "Document validators not allowed on system collection " << ns() - << " with UUID " - << _uuid}; + << " with UUID " << _uuid}; } if (ns().isOnInternalDb()) { return {ErrorCodes::InvalidOptions, str::stream() << "Document validators are not allowed on collection " << ns().ns() - << " with UUID " - << _uuid - << " in the " - << ns().db() + << " with UUID " << _uuid << " in the " << ns().db() << " internal database"}; } @@ -418,8 +414,9 @@ Status CollectionImpl::insertDocuments(OperationContext* opCtx, const auto firstIdElem = data["first_id"]; // If the failpoint specifies no collection or matches the existing one, hang. if ((!collElem || _ns.ns() == collElem.str()) && - (!firstIdElem || (begin != end && firstIdElem.type() == mongo::String && - begin->doc["_id"].str() == firstIdElem.str()))) { + (!firstIdElem || + (begin != end && firstIdElem.type() == mongo::String && + begin->doc["_id"].str() == firstIdElem.str()))) { string whenFirst = firstIdElem ? (string(" when first _id is ") + firstIdElem.str()) : ""; while (MONGO_FAIL_POINT(hangAfterCollectionInserts)) { @@ -675,9 +672,7 @@ RecordId CollectionImpl::updateDocument(OperationContext* opCtx, if (_recordStore->isCapped() && oldSize != newDoc.objsize()) uasserted(ErrorCodes::CannotGrowDocumentInCappedNamespace, str::stream() << "Cannot change the size of a document in a capped collection: " - << oldSize - << " != " - << newDoc.objsize()); + << oldSize << " != " << newDoc.objsize()); args->preImageDoc = oldDoc.value().getOwned(); @@ -850,11 +845,9 @@ Status CollectionImpl::setValidator(OperationContext* opCtx, BSONObj validatorDo DurableCatalog::get(opCtx)->updateValidator( opCtx, ns(), validatorDoc, getValidationLevel(), getValidationAction()); - opCtx->recoveryUnit()->onRollback([ - this, - oldValidator = std::move(_validator), - oldValidatorDoc = std::move(_validatorDoc) - ]() mutable { + opCtx->recoveryUnit()->onRollback([this, + oldValidator = std::move(_validator), + oldValidatorDoc = std::move(_validatorDoc)]() mutable { this->_validator = std::move(oldValidator); this->_validatorDoc = std::move(oldValidatorDoc); }); @@ -930,13 +923,11 @@ Status CollectionImpl::updateValidator(OperationContext* opCtx, StringData newAction) { invariant(opCtx->lockState()->isCollectionLockedForMode(ns(), MODE_X)); - opCtx->recoveryUnit()->onRollback([ - this, - oldValidator = std::move(_validator), - oldValidatorDoc = std::move(_validatorDoc), - oldValidationLevel = _validationLevel, - oldValidationAction = _validationAction - ]() mutable { + opCtx->recoveryUnit()->onRollback([this, + oldValidator = std::move(_validator), + oldValidatorDoc = std::move(_validatorDoc), + oldValidationLevel = _validationLevel, + oldValidationAction = _validationAction]() mutable { this->_validator = std::move(oldValidator); this->_validatorDoc = std::move(oldValidatorDoc); this->_validationLevel = oldValidationLevel; diff --git a/src/mongo/db/catalog/collection_options.cpp b/src/mongo/db/catalog/collection_options.cpp index b9ca30d8bc6..75c5fb91d14 100644 --- a/src/mongo/db/catalog/collection_options.cpp +++ b/src/mongo/db/catalog/collection_options.cpp @@ -255,9 +255,9 @@ StatusWith CollectionOptions::parse(const BSONObj& options, P collectionOptions.idIndex = std::move(tempIdIndex); } else if (!createdOn24OrEarlier && !mongo::isGenericArgument(fieldName)) { return Status(ErrorCodes::InvalidOptions, - str::stream() << "The field '" << fieldName - << "' is not a valid collection option. Options: " - << options); + str::stream() + << "The field '" << fieldName + << "' is not a valid collection option. Options: " << options); } } @@ -413,4 +413,4 @@ bool CollectionOptions::matchesStorageOptions(const CollectionOptions& other, return true; } -} +} // namespace mongo diff --git a/src/mongo/db/catalog/collection_options.h b/src/mongo/db/catalog/collection_options.h index ca55a98a5c8..f5f63b0f72f 100644 --- a/src/mongo/db/catalog/collection_options.h +++ b/src/mongo/db/catalog/collection_options.h @@ -148,4 +148,4 @@ struct CollectionOptions { // The aggregation pipeline that defines this view. BSONObj pipeline; }; -} +} // namespace mongo diff --git a/src/mongo/db/catalog/collection_validation.cpp b/src/mongo/db/catalog/collection_validation.cpp index 4eff8a7f9a4..9b6c87d55e0 100644 --- a/src/mongo/db/catalog/collection_validation.cpp +++ b/src/mongo/db/catalog/collection_validation.cpp @@ -300,10 +300,8 @@ void addErrorIfUnequal(T stored, T cached, StringData name, ValidateResults* res if (stored != cached) { results->valid = false; results->errors.push_back(str::stream() << "stored value for " << name - << " does not match cached value: " - << stored - << " != " - << cached); + << " does not match cached value: " << stored + << " != " << cached); } } diff --git a/src/mongo/db/catalog/create_collection.cpp b/src/mongo/db/catalog/create_collection.cpp index 5813440c265..d5fa352e829 100644 --- a/src/mongo/db/catalog/create_collection.cpp +++ b/src/mongo/db/catalog/create_collection.cpp @@ -237,11 +237,10 @@ Status createCollectionForApplyOps(OperationContext* opCtx, << " - existing collection with conflicting UUID " << uuid << " is in a drop-pending state: " << *currentName; return Result(Status(ErrorCodes::NamespaceExists, - str::stream() << "existing collection " - << currentName->toString() - << " with conflicting UUID " - << uuid.toString() - << " is in a drop-pending state.")); + str::stream() + << "existing collection " << currentName->toString() + << " with conflicting UUID " << uuid.toString() + << " is in a drop-pending state.")); } // In the case of oplog replay, a future command may have created or renamed a diff --git a/src/mongo/db/catalog/database_holder_impl.cpp b/src/mongo/db/catalog/database_holder_impl.cpp index b3561aa2958..7ce5474e987 100644 --- a/src/mongo/db/catalog/database_holder_impl.cpp +++ b/src/mongo/db/catalog/database_holder_impl.cpp @@ -123,9 +123,7 @@ Database* DatabaseHolderImpl::openDb(OperationContext* opCtx, StringData ns, boo auto duplicates = _getNamesWithConflictingCasing_inlock(dbname); uassert(ErrorCodes::DatabaseDifferCase, str::stream() << "db already exists with different case already have: [" - << *duplicates.cbegin() - << "] trying to create [" - << dbname.toString() + << *duplicates.cbegin() << "] trying to create [" << dbname.toString() << "]", duplicates.empty()); @@ -241,8 +239,8 @@ void DatabaseHolderImpl::closeAll(OperationContext* opCtx) { // It is the caller's responsibility to ensure that no index builds are active in the // database. invariant(!coll->getIndexCatalog()->haveAnyIndexesInProgress(), - str::stream() << "An index is building on collection '" << coll->ns() - << "'."); + str::stream() + << "An index is building on collection '" << coll->ns() << "'."); } dbs.insert(i->first); } diff --git a/src/mongo/db/catalog/database_impl.cpp b/src/mongo/db/catalog/database_impl.cpp index d5c57cc8db4..cc5c3b33792 100644 --- a/src/mongo/db/catalog/database_impl.cpp +++ b/src/mongo/db/catalog/database_impl.cpp @@ -354,8 +354,7 @@ Status DatabaseImpl::dropCollectionEvenIfSystem(OperationContext* opCtx, auto numIndexesInProgress = collection->getIndexCatalog()->numIndexesInProgress(opCtx); massert(ErrorCodes::BackgroundOperationInProgressForNamespace, str::stream() << "cannot drop collection " << nss << " (" << uuid << ") when " - << numIndexesInProgress - << " index builds in progress.", + << numIndexesInProgress << " index builds in progress.", numIndexesInProgress == 0); audit::logDropCollection(&cc(), nss.toString()); @@ -605,8 +604,8 @@ Collection* DatabaseImpl::createCollection(OperationContext* opCtx, bool generatedUUID = false; if (!optionsWithUUID.uuid) { if (!canAcceptWrites) { - std::string msg = str::stream() << "Attempted to create a new collection " << nss - << " without a UUID"; + std::string msg = str::stream() + << "Attempted to create a new collection " << nss << " without a UUID"; severe() << msg; uasserted(ErrorCodes::InvalidOptions, msg); } else { @@ -700,10 +699,10 @@ StatusWith DatabaseImpl::makeUniqueCollectionNamespace( auto numPercentSign = std::count(collectionNameModel.begin(), collectionNameModel.end(), '%'); if (numPercentSign == 0) { return Status(ErrorCodes::FailedToParse, - str::stream() << "Cannot generate collection name for temporary collection: " - "model for collection name " - << collectionNameModel - << " must contain at least one percent sign."); + str::stream() + << "Cannot generate collection name for temporary collection: " + "model for collection name " + << collectionNameModel << " must contain at least one percent sign."); } if (!_uniqueCollectionNamespacePseudoRandom) { @@ -742,9 +741,7 @@ StatusWith DatabaseImpl::makeUniqueCollectionNamespace( return Status( ErrorCodes::NamespaceExists, str::stream() << "Cannot generate collection name for temporary collection with model " - << collectionNameModel - << " after " - << numGenerationAttempts + << collectionNameModel << " after " << numGenerationAttempts << " attempts due to namespace conflicts with existing collections."); } @@ -873,8 +870,7 @@ Status DatabaseImpl::userCreateNS(OperationContext* opCtx, } else { invariant(createCollection(opCtx, nss, collectionOptions, createDefaultIndexes, idIndex), str::stream() << "Collection creation failed after validating options: " << nss - << ". Options: " - << collectionOptions.toBSON()); + << ". Options: " << collectionOptions.toBSON()); } return Status::OK(); diff --git a/src/mongo/db/catalog/database_test.cpp b/src/mongo/db/catalog/database_test.cpp index 28173e8fbb0..542cae76e80 100644 --- a/src/mongo/db/catalog/database_test.cpp +++ b/src/mongo/db/catalog/database_test.cpp @@ -160,13 +160,13 @@ TEST_F(DatabaseTest, CreateCollectionThrowsExceptionWhenDatabaseIsInADropPending // tests. ON_BLOCK_EXIT([&wuow] { wuow.commit(); }); - ASSERT_THROWS_CODE_AND_WHAT( - db->createCollection(_opCtx.get(), _nss), - AssertionException, - ErrorCodes::DatabaseDropPending, - (StringBuilder() << "Cannot create collection " << _nss - << " - database is in the process of being dropped.") - .stringData()); + ASSERT_THROWS_CODE_AND_WHAT(db->createCollection(_opCtx.get(), _nss), + AssertionException, + ErrorCodes::DatabaseDropPending, + (StringBuilder() + << "Cannot create collection " << _nss + << " - database is in the process of being dropped.") + .stringData()); }); } @@ -299,11 +299,10 @@ void _testDropCollectionThrowsExceptionIfThereAreIndexesInProgress(OperationCont auto indexCatalog = collection->getIndexCatalog(); ASSERT_EQUALS(indexCatalog->numIndexesInProgress(opCtx), 0); - auto indexInfoObj = BSON( - "v" << int(IndexDescriptor::kLatestIndexVersion) << "key" << BSON("a" << 1) << "name" - << "a_1" - << "ns" - << nss.ns()); + auto indexInfoObj = BSON("v" << int(IndexDescriptor::kLatestIndexVersion) << "key" + << BSON("a" << 1) << "name" + << "a_1" + << "ns" << nss.ns()); auto indexBuildBlock = std::make_unique( indexCatalog, collection->ns(), indexInfoObj, IndexBuildMethod::kHybrid); @@ -410,8 +409,7 @@ TEST_F(DatabaseTest, MakeUniqueCollectionNamespaceReplacesPercentSignsWithRandom auto nss1 = unittest::assertGet(db->makeUniqueCollectionNamespace(_opCtx.get(), model)); if (!re.FullMatch(nss1.ns())) { FAIL((StringBuilder() << "First generated namespace \"" << nss1.ns() - << "\" does not match reqular expression \"" - << re.pattern() + << "\" does not match reqular expression \"" << re.pattern() << "\"") .str()); } @@ -428,8 +426,7 @@ TEST_F(DatabaseTest, MakeUniqueCollectionNamespaceReplacesPercentSignsWithRandom auto nss2 = unittest::assertGet(db->makeUniqueCollectionNamespace(_opCtx.get(), model)); if (!re.FullMatch(nss2.ns())) { FAIL((StringBuilder() << "Second generated namespace \"" << nss2.ns() - << "\" does not match reqular expression \"" - << re.pattern() + << "\" does not match reqular expression \"" << re.pattern() << "\"") .str()); } @@ -522,28 +519,28 @@ TEST_F(DatabaseTest, AutoGetCollectionForReadCommandSucceedsWithDeadlineMin) { } TEST_F(DatabaseTest, CreateCollectionProhibitsReplicatedCollectionsWithoutIdIndex) { - writeConflictRetry( - _opCtx.get(), - "testÇreateCollectionProhibitsReplicatedCollectionsWithoutIdIndex", - _nss.ns(), - [this] { - AutoGetOrCreateDb autoDb(_opCtx.get(), _nss.db(), MODE_X); - auto db = autoDb.getDb(); - ASSERT_TRUE(db); - - WriteUnitOfWork wuow(_opCtx.get()); - - CollectionOptions options; - options.setNoIdIndex(); - - ASSERT_THROWS_CODE_AND_WHAT( - db->createCollection(_opCtx.get(), _nss, options), - AssertionException, - 50001, - (StringBuilder() << "autoIndexId:false is not allowed for collection " << _nss - << " because it can be replicated") - .stringData()); - }); + writeConflictRetry(_opCtx.get(), + "testÇreateCollectionProhibitsReplicatedCollectionsWithoutIdIndex", + _nss.ns(), + [this] { + AutoGetOrCreateDb autoDb(_opCtx.get(), _nss.db(), MODE_X); + auto db = autoDb.getDb(); + ASSERT_TRUE(db); + + WriteUnitOfWork wuow(_opCtx.get()); + + CollectionOptions options; + options.setNoIdIndex(); + + ASSERT_THROWS_CODE_AND_WHAT( + db->createCollection(_opCtx.get(), _nss, options), + AssertionException, + 50001, + (StringBuilder() + << "autoIndexId:false is not allowed for collection " << _nss + << " because it can be replicated") + .stringData()); + }); } diff --git a/src/mongo/db/catalog/document_validation.h b/src/mongo/db/catalog/document_validation.h index 27a7969c6d6..e27dfb11b66 100644 --- a/src/mongo/db/catalog/document_validation.h +++ b/src/mongo/db/catalog/document_validation.h @@ -84,4 +84,4 @@ public: private: boost::optional _documentValidationDisabler; }; -} +} // namespace mongo diff --git a/src/mongo/db/catalog/drop_database.cpp b/src/mongo/db/catalog/drop_database.cpp index fd471f8ad50..7cb0b952f4d 100644 --- a/src/mongo/db/catalog/drop_database.cpp +++ b/src/mongo/db/catalog/drop_database.cpp @@ -275,12 +275,11 @@ Status dropDatabase(OperationContext* opCtx, const std::string& dbName) { } if (!result.status.isOK()) { - return result.status.withContext( - str::stream() << "dropDatabase " << dbName << " failed waiting for " - << numCollectionsToDrop - << " collection drop(s) (most recent drop optime: " - << awaitOpTime.toString() - << ") to replicate."); + return result.status.withContext(str::stream() + << "dropDatabase " << dbName << " failed waiting for " + << numCollectionsToDrop + << " collection drop(s) (most recent drop optime: " + << awaitOpTime.toString() << ") to replicate."); } log() << "dropDatabase " << dbName << " - successfully dropped " << numCollectionsToDrop @@ -301,8 +300,7 @@ Status dropDatabase(OperationContext* opCtx, const std::string& dbName) { return Status(ErrorCodes::NamespaceNotFound, str::stream() << "Could not drop database " << dbName << " because it does not exist after dropping " - << numCollectionsToDrop - << " collection(s)."); + << numCollectionsToDrop << " collection(s)."); } bool userInitiatedWritesAndNotPrimary = @@ -310,12 +308,11 @@ Status dropDatabase(OperationContext* opCtx, const std::string& dbName) { if (userInitiatedWritesAndNotPrimary) { return Status(ErrorCodes::PrimarySteppedDown, - str::stream() << "Could not drop database " << dbName - << " because we transitioned from PRIMARY to " - << replCoord->getMemberState().toString() - << " while waiting for " - << numCollectionsToDrop - << " pending collection drop(s)."); + str::stream() + << "Could not drop database " << dbName + << " because we transitioned from PRIMARY to " + << replCoord->getMemberState().toString() << " while waiting for " + << numCollectionsToDrop << " pending collection drop(s)."); } // _finishDropDatabase creates its own scope guard to ensure drop-pending is unset. diff --git a/src/mongo/db/catalog/drop_database_test.cpp b/src/mongo/db/catalog/drop_database_test.cpp index 2eb37e80a36..af36872c701 100644 --- a/src/mongo/db/catalog/drop_database_test.cpp +++ b/src/mongo/db/catalog/drop_database_test.cpp @@ -432,10 +432,10 @@ TEST_F(DropDatabaseTest, auto status = dropDatabase(_opCtx.get(), _nss.db().toString()); ASSERT_EQUALS(ErrorCodes::NamespaceNotFound, status); - ASSERT_EQUALS( - status.reason(), - std::string(str::stream() << "Could not drop database " << _nss.db() - << " because it does not exist after dropping 1 collection(s).")); + ASSERT_EQUALS(status.reason(), + std::string(str::stream() + << "Could not drop database " << _nss.db() + << " because it does not exist after dropping 1 collection(s).")); ASSERT_FALSE(AutoGetDb(_opCtx.get(), _nss.db(), MODE_X).getDb()); } diff --git a/src/mongo/db/catalog/drop_indexes.cpp b/src/mongo/db/catalog/drop_indexes.cpp index cd56e85e2b6..3e212385757 100644 --- a/src/mongo/db/catalog/drop_indexes.cpp +++ b/src/mongo/db/catalog/drop_indexes.cpp @@ -105,7 +105,6 @@ Status wrappedRun(OperationContext* opCtx, collection->uuid(), desc->indexName(), desc->infoObj()); - }); anObjBuilder->append("msg", "non-_id indexes dropped for collection"); @@ -121,16 +120,14 @@ Status wrappedRun(OperationContext* opCtx, opCtx, indexElem.embeddedObject(), false, &indexes); if (indexes.empty()) { return Status(ErrorCodes::IndexNotFound, - str::stream() << "can't find index with key: " - << indexElem.embeddedObject()); + str::stream() + << "can't find index with key: " << indexElem.embeddedObject()); } else if (indexes.size() > 1) { return Status(ErrorCodes::AmbiguousIndexKeyPattern, - str::stream() << indexes.size() << " indexes found for key: " - << indexElem.embeddedObject() + str::stream() << indexes.size() + << " indexes found for key: " << indexElem.embeddedObject() << ", identify by name instead." - << " Conflicting indexes: " - << indexes[0]->infoObj() - << ", " + << " Conflicting indexes: " << indexes[0]->infoObj() << ", " << indexes[1]->infoObj()); } @@ -166,23 +163,19 @@ Status wrappedRun(OperationContext* opCtx, for (auto indexNameElem : indexElem.Array()) { if (indexNameElem.type() != String) { return Status(ErrorCodes::TypeMismatch, - str::stream() << "dropIndexes " << collection->ns() << " (" - << collection->uuid() - << ") failed to drop multiple indexes " - << indexElem.toString(false) - << ": index name must be a string"); + str::stream() + << "dropIndexes " << collection->ns() << " (" + << collection->uuid() << ") failed to drop multiple indexes " + << indexElem.toString(false) << ": index name must be a string"); } auto indexToDelete = indexNameElem.String(); auto status = dropIndexByName(opCtx, collection, indexCatalog, indexToDelete); if (!status.isOK()) { - return status.withContext(str::stream() << "dropIndexes " << collection->ns() - << " (" - << collection->uuid() - << ") failed to drop multiple indexes " - << indexElem.toString(false) - << ": " - << indexToDelete); + return status.withContext( + str::stream() << "dropIndexes " << collection->ns() << " (" + << collection->uuid() << ") failed to drop multiple indexes " + << indexElem.toString(false) << ": " << indexToDelete); } } diff --git a/src/mongo/db/catalog/health_log.cpp b/src/mongo/db/catalog/health_log.cpp index 0bd4171c262..2703dee4aa1 100644 --- a/src/mongo/db/catalog/health_log.cpp +++ b/src/mongo/db/catalog/health_log.cpp @@ -48,7 +48,7 @@ CollectionOptions getOptions(void) { options.cappedSize = kDefaultHealthlogSize; return options; } -} +} // namespace HealthLog::HealthLog() : _writer(nss, getOptions(), kMaxBufferSize) {} @@ -78,4 +78,4 @@ bool HealthLog::log(const HealthLogEntry& entry) { } const NamespaceString HealthLog::nss("local", "system.healthlog"); -} +} // namespace mongo diff --git a/src/mongo/db/catalog/health_log.h b/src/mongo/db/catalog/health_log.h index 2b312f741fa..ba2bcbf440a 100644 --- a/src/mongo/db/catalog/health_log.h +++ b/src/mongo/db/catalog/health_log.h @@ -91,4 +91,4 @@ public: private: DeferredWriter _writer; }; -} +} // namespace mongo diff --git a/src/mongo/db/catalog/index_build_block.cpp b/src/mongo/db/catalog/index_build_block.cpp index 7666f5b0900..60eb8152cbf 100644 --- a/src/mongo/db/catalog/index_build_block.cpp +++ b/src/mongo/db/catalog/index_build_block.cpp @@ -119,14 +119,14 @@ Status IndexBuildBlock::init(OperationContext* opCtx, Collection* collection) { } if (isBackgroundIndex) { - opCtx->recoveryUnit()->onCommit([ entry = _indexCatalogEntry, coll = collection ]( - boost::optional commitTime) { - // This will prevent the unfinished index from being visible on index iterators. - if (commitTime) { - entry->setMinimumVisibleSnapshot(commitTime.get()); - coll->setMinimumVisibleSnapshot(commitTime.get()); - } - }); + opCtx->recoveryUnit()->onCommit( + [entry = _indexCatalogEntry, coll = collection](boost::optional commitTime) { + // This will prevent the unfinished index from being visible on index iterators. + if (commitTime) { + entry->setMinimumVisibleSnapshot(commitTime.get()); + coll->setMinimumVisibleSnapshot(commitTime.get()); + } + }); } // Register this index with the CollectionInfoCache to regenerate the cache. This way, updates @@ -177,8 +177,8 @@ void IndexBuildBlock::success(OperationContext* opCtx, Collection* collection) { collection->indexBuildSuccess(opCtx, _indexCatalogEntry); - opCtx->recoveryUnit()->onCommit([ opCtx, entry = _indexCatalogEntry, coll = collection ]( - boost::optional commitTime) { + opCtx->recoveryUnit()->onCommit([opCtx, entry = _indexCatalogEntry, coll = collection]( + boost::optional commitTime) { // Note: this runs after the WUOW commits but before we release our X lock on the // collection. This means that any snapshot created after this must include the full // index, and no one can try to read this index before we set the visibility. diff --git a/src/mongo/db/catalog/index_builds_manager.cpp b/src/mongo/db/catalog/index_builds_manager.cpp index fe816ce7dc4..2720ffd09c7 100644 --- a/src/mongo/db/catalog/index_builds_manager.cpp +++ b/src/mongo/db/catalog/index_builds_manager.cpp @@ -86,8 +86,7 @@ Status IndexBuildsManager::setUpIndexBuild(OperationContext* opCtx, const auto& nss = collection->ns(); invariant(opCtx->lockState()->isCollectionLockedForMode(nss, MODE_X), str::stream() << "Unable to set up index build " << buildUUID << ": collection " - << nss.ns() - << " is not locked in exclusive mode."); + << nss.ns() << " is not locked in exclusive mode."); auto builder = _getBuilder(buildUUID); diff --git a/src/mongo/db/catalog/index_builds_manager_test.cpp b/src/mongo/db/catalog/index_builds_manager_test.cpp index 3ecb5dca2a1..df5e50d244c 100644 --- a/src/mongo/db/catalog/index_builds_manager_test.cpp +++ b/src/mongo/db/catalog/index_builds_manager_test.cpp @@ -76,8 +76,7 @@ std::vector makeSpecs(const NamespaceString& nss, std::vector indexSpecs; for (auto keyName : keys) { indexSpecs.push_back(BSON("ns" << nss.toString() << "v" << 2 << "key" << BSON(keyName << 1) - << "name" - << (keyName + "_1"))); + << "name" << (keyName + "_1"))); } return indexSpecs; } diff --git a/src/mongo/db/catalog/index_catalog_entry_impl.cpp b/src/mongo/db/catalog/index_catalog_entry_impl.cpp index 2bcb83ce3ac..9a30dfc9687 100644 --- a/src/mongo/db/catalog/index_catalog_entry_impl.cpp +++ b/src/mongo/db/catalog/index_catalog_entry_impl.cpp @@ -317,8 +317,10 @@ void IndexCatalogEntryImpl::setMultikey(OperationContext* opCtx, fassert(31164, status); indexMetadataHasChanged = DurableCatalog::get(opCtx)->setIndexIsMultikey( opCtx, _ns, _descriptor->indexName(), paths); - opCtx->recoveryUnit()->onCommit([onMultikeyCommitFn, indexMetadataHasChanged]( - boost::optional) { onMultikeyCommitFn(indexMetadataHasChanged); }); + opCtx->recoveryUnit()->onCommit( + [onMultikeyCommitFn, indexMetadataHasChanged](boost::optional) { + onMultikeyCommitFn(indexMetadataHasChanged); + }); wuow.commit(); }); } else { @@ -326,8 +328,10 @@ void IndexCatalogEntryImpl::setMultikey(OperationContext* opCtx, opCtx, _ns, _descriptor->indexName(), paths); } - opCtx->recoveryUnit()->onCommit([onMultikeyCommitFn, indexMetadataHasChanged]( - boost::optional) { onMultikeyCommitFn(indexMetadataHasChanged); }); + opCtx->recoveryUnit()->onCommit( + [onMultikeyCommitFn, indexMetadataHasChanged](boost::optional) { + onMultikeyCommitFn(indexMetadataHasChanged); + }); // Within a multi-document transaction, reads should be able to see the effect of previous // writes done within that transaction. If a previous write in a transaction has set the index diff --git a/src/mongo/db/catalog/index_catalog_impl.cpp b/src/mongo/db/catalog/index_catalog_impl.cpp index 0bddaac7c57..f060325141d 100644 --- a/src/mongo/db/catalog/index_catalog_impl.cpp +++ b/src/mongo/db/catalog/index_catalog_impl.cpp @@ -171,8 +171,7 @@ string IndexCatalogImpl::_getAccessMethodName(const BSONObj& keyPattern) const { // supports an index plugin unsupported by this version. uassert(17197, str::stream() << "Invalid index type '" << pluginName << "' " - << "in index " - << keyPattern, + << "in index " << keyPattern, IndexNames::isKnownName(pluginName)); return pluginName; @@ -392,17 +391,16 @@ IndexCatalogEntry* IndexCatalogImpl::createIndexEntry(OperationContext* opCtx, } if (!initFromDisk) { - opCtx->recoveryUnit()->onRollback( - [ this, opCtx, isReadyIndex, descriptor = descriptorPtr ] { - // Need to preserve indexName as descriptor no longer exists after remove(). - const std::string indexName = descriptor->indexName(); - if (isReadyIndex) { - _readyIndexes.remove(descriptor); - } else { - _buildingIndexes.remove(descriptor); - } - _collection->infoCache()->droppedIndex(opCtx, indexName); - }); + opCtx->recoveryUnit()->onRollback([this, opCtx, isReadyIndex, descriptor = descriptorPtr] { + // Need to preserve indexName as descriptor no longer exists after remove(). + const std::string indexName = descriptor->indexName(); + if (isReadyIndex) { + _readyIndexes.remove(descriptor); + } else { + _buildingIndexes.remove(descriptor); + } + _collection->infoCache()->droppedIndex(opCtx, indexName); + }); } return save; @@ -413,10 +411,8 @@ StatusWith IndexCatalogImpl::createIndexOnEmptyCollection(OperationCont invariant(opCtx->lockState()->isCollectionLockedForMode(_collection->ns(), MODE_X)); invariant(_collection->numRecords(opCtx) == 0, str::stream() << "Collection must be empty. Collection: " << _collection->ns() - << " UUID: " - << _collection->uuid() - << " Count: " - << _collection->numRecords(opCtx)); + << " UUID: " << _collection->uuid() + << " Count: " << _collection->numRecords(opCtx)); _checkMagic(); @@ -523,8 +519,7 @@ Status IndexCatalogImpl::_isSpecOk(OperationContext* opCtx, const BSONObj& spec) if (!IndexDescriptor::isIndexVersionSupported(indexVersion)) { return Status(ErrorCodes::CannotCreateIndex, str::stream() << "this version of mongod cannot build new indexes " - << "of version number " - << static_cast(indexVersion)); + << "of version number " << static_cast(indexVersion)); } if (nss.isOplog()) @@ -542,9 +537,7 @@ Status IndexCatalogImpl::_isSpecOk(OperationContext* opCtx, const BSONObj& spec) return Status(ErrorCodes::CannotCreateIndex, str::stream() << "the \"ns\" field of the index spec '" << specNamespace.valueStringData() - << "' does not match the collection name '" - << nss - << "'"); + << "' does not match the collection name '" << nss << "'"); } // logical name of the index @@ -563,8 +556,8 @@ Status IndexCatalogImpl::_isSpecOk(OperationContext* opCtx, const BSONObj& spec) const Status keyStatus = index_key_validate::validateKeyPattern(key, indexVersion); if (!keyStatus.isOK()) { return Status(ErrorCodes::CannotCreateIndex, - str::stream() << "bad index key pattern " << key << ": " - << keyStatus.reason()); + str::stream() + << "bad index key pattern " << key << ": " << keyStatus.reason()); } const string pluginName = IndexNames::findPluginName(key); @@ -593,18 +586,16 @@ Status IndexCatalogImpl::_isSpecOk(OperationContext* opCtx, const BSONObj& spec) if (static_cast(vElt.numberInt()) < IndexVersion::kV2) { return {ErrorCodes::CannotCreateIndex, str::stream() << "Index version " << vElt.fieldNameStringData() << "=" - << vElt.numberInt() - << " does not support the '" - << collationElement.fieldNameStringData() - << "' option"}; + << vElt.numberInt() << " does not support the '" + << collationElement.fieldNameStringData() << "' option"}; } if ((pluginName != IndexNames::BTREE) && (pluginName != IndexNames::GEO_2DSPHERE) && (pluginName != IndexNames::HASHED) && (pluginName != IndexNames::WILDCARD)) { return Status(ErrorCodes::CannotCreateIndex, - str::stream() << "Index type '" << pluginName - << "' does not support collation: " - << collator->getSpec().toBSON()); + str::stream() + << "Index type '" << pluginName + << "' does not support collation: " << collator->getSpec().toBSON()); } } @@ -625,8 +616,8 @@ Status IndexCatalogImpl::_isSpecOk(OperationContext* opCtx, const BSONObj& spec) if (spec.getField("expireAfterSeconds")) { return Status(ErrorCodes::CannotCreateIndex, - str::stream() << "Index type '" << pluginName - << "' cannot be a TTL index"); + str::stream() + << "Index type '" << pluginName << "' cannot be a TTL index"); } } @@ -736,21 +727,18 @@ Status IndexCatalogImpl::_doesSpecConflictWithExisting(OperationContext* opCtx, << "An index with the same key pattern, but a different " << "collation already exists with the same name. Try again with " << "a unique name. " - << "Existing index: " - << desc->infoObj() - << " Requested index: " - << spec); + << "Existing index: " << desc->infoObj() + << " Requested index: " << spec); } if (SimpleBSONObjComparator::kInstance.evaluate(desc->keyPattern() != key) || SimpleBSONObjComparator::kInstance.evaluate( desc->infoObj().getObjectField("collation") != collation)) { return Status(ErrorCodes::IndexKeySpecsConflict, - str::stream() << "Index must have unique name." - << "The existing index: " - << desc->infoObj() - << " has the same name as the requested index: " - << spec); + str::stream() + << "Index must have unique name." + << "The existing index: " << desc->infoObj() + << " has the same name as the requested index: " << spec); } IndexDescriptor temp(_collection, _getAccessMethodName(key), spec); @@ -776,9 +764,9 @@ Status IndexCatalogImpl::_doesSpecConflictWithExisting(OperationContext* opCtx, IndexDescriptor temp(_collection, _getAccessMethodName(key), spec); if (!desc->areIndexOptionsEquivalent(&temp)) return Status(ErrorCodes::IndexOptionsConflict, - str::stream() << "Index: " << spec - << " already exists with different options: " - << desc->infoObj()); + str::stream() + << "Index: " << spec + << " already exists with different options: " << desc->infoObj()); return Status(ErrorCodes::IndexOptionsConflict, str::stream() << "Index with name: " << name @@ -803,8 +791,7 @@ Status IndexCatalogImpl::_doesSpecConflictWithExisting(OperationContext* opCtx, return Status(ErrorCodes::CannotCreateIndex, str::stream() << "only one text index per collection allowed, " << "found existing text index \"" - << textIndexes[0]->indexName() - << "\""); + << textIndexes[0]->indexName() << "\""); } } return Status::OK(); diff --git a/src/mongo/db/catalog/index_consistency.cpp b/src/mongo/db/catalog/index_consistency.cpp index b1d6f13390d..7491916b87a 100644 --- a/src/mongo/db/catalog/index_consistency.cpp +++ b/src/mongo/db/catalog/index_consistency.cpp @@ -303,8 +303,7 @@ BSONObj IndexConsistency::_generateInfo(const IndexInfo& indexInfo, if (idKey) { return BSON("indexName" << indexName << "recordId" << recordId.repr() << "idKey" << *idKey - << "indexKey" - << rehydratedKey); + << "indexKey" << rehydratedKey); } else { return BSON("indexName" << indexName << "recordId" << recordId.repr() << "indexKey" << rehydratedKey); diff --git a/src/mongo/db/catalog/index_key_validate.cpp b/src/mongo/db/catalog/index_key_validate.cpp index 191194f47f6..2bc450516fb 100644 --- a/src/mongo/db/catalog/index_key_validate.cpp +++ b/src/mongo/db/catalog/index_key_validate.cpp @@ -108,7 +108,7 @@ static const std::set allowedIdIndexFieldNames = { IndexDescriptor::kNamespaceFieldName, // Index creation under legacy writeMode can result in an index spec with an _id field. "_id"}; -} +} // namespace Status validateKeyPattern(const BSONObj& key, IndexDescriptor::IndexVersion indexVersion) { const ErrorCodes::Error code = ErrorCodes::CannotCreateIndex; @@ -134,8 +134,7 @@ Status validateKeyPattern(const BSONObj& key, IndexDescriptor::IndexVersion inde if (keyElement.type() == BSONType::Object || keyElement.type() == BSONType::Array) { return {code, str::stream() << "Values in index key pattern cannot be of type " - << typeName(keyElement.type()) - << " for index version v:" + << typeName(keyElement.type()) << " for index version v:" << static_cast(indexVersion)}; } @@ -276,9 +275,9 @@ StatusWith validateIndexSpec( if (IndexDescriptor::kKeyPatternFieldName == indexSpecElemFieldName) { if (indexSpecElem.type() != BSONType::Object) { return {ErrorCodes::TypeMismatch, - str::stream() << "The field '" << IndexDescriptor::kKeyPatternFieldName - << "' must be an object, but got " - << typeName(indexSpecElem.type())}; + str::stream() + << "The field '" << IndexDescriptor::kKeyPatternFieldName + << "' must be an object, but got " << typeName(indexSpecElem.type())}; } std::vector keys; @@ -321,18 +320,18 @@ StatusWith validateIndexSpec( } else if (IndexDescriptor::kIndexNameFieldName == indexSpecElemFieldName) { if (indexSpecElem.type() != BSONType::String) { return {ErrorCodes::TypeMismatch, - str::stream() << "The field '" << IndexDescriptor::kIndexNameFieldName - << "' must be a string, but got " - << typeName(indexSpecElem.type())}; + str::stream() + << "The field '" << IndexDescriptor::kIndexNameFieldName + << "' must be a string, but got " << typeName(indexSpecElem.type())}; } hasIndexNameField = true; } else if (IndexDescriptor::kNamespaceFieldName == indexSpecElemFieldName) { if (indexSpecElem.type() != BSONType::String) { return {ErrorCodes::TypeMismatch, - str::stream() << "The field '" << IndexDescriptor::kNamespaceFieldName - << "' must be a string, but got " - << typeName(indexSpecElem.type())}; + str::stream() + << "The field '" << IndexDescriptor::kNamespaceFieldName + << "' must be a string, but got " << typeName(indexSpecElem.type())}; } StringData ns = indexSpecElem.valueStringData(); @@ -344,22 +343,19 @@ StatusWith validateIndexSpec( if (ns != expectedNamespace.ns()) { return {ErrorCodes::BadValue, - str::stream() << "The value of the field '" - << IndexDescriptor::kNamespaceFieldName - << "' (" - << ns - << ") doesn't match the namespace '" - << expectedNamespace - << "'"}; + str::stream() + << "The value of the field '" << IndexDescriptor::kNamespaceFieldName + << "' (" << ns << ") doesn't match the namespace '" << expectedNamespace + << "'"}; } hasNamespaceField = true; } else if (IndexDescriptor::kIndexVersionFieldName == indexSpecElemFieldName) { if (!indexSpecElem.isNumber()) { return {ErrorCodes::TypeMismatch, - str::stream() << "The field '" << IndexDescriptor::kIndexVersionFieldName - << "' must be a number, but got " - << typeName(indexSpecElem.type())}; + str::stream() + << "The field '" << IndexDescriptor::kIndexVersionFieldName + << "' must be a number, but got " << typeName(indexSpecElem.type())}; } auto requestedIndexVersionAsInt = representAs(indexSpecElem.number()); @@ -383,9 +379,9 @@ StatusWith validateIndexSpec( } else if (IndexDescriptor::kCollationFieldName == indexSpecElemFieldName) { if (indexSpecElem.type() != BSONType::Object) { return {ErrorCodes::TypeMismatch, - str::stream() << "The field '" << IndexDescriptor::kCollationFieldName - << "' must be an object, but got " - << typeName(indexSpecElem.type())}; + str::stream() + << "The field '" << IndexDescriptor::kCollationFieldName + << "' must be an object, but got " << typeName(indexSpecElem.type())}; } if (indexSpecElem.Obj().isEmpty()) { @@ -398,10 +394,9 @@ StatusWith validateIndexSpec( } else if (IndexDescriptor::kPartialFilterExprFieldName == indexSpecElemFieldName) { if (indexSpecElem.type() != BSONType::Object) { return {ErrorCodes::TypeMismatch, - str::stream() << "The field '" - << IndexDescriptor::kPartialFilterExprFieldName - << "' must be an object, but got " - << typeName(indexSpecElem.type())}; + str::stream() + << "The field '" << IndexDescriptor::kPartialFilterExprFieldName + << "' must be an object, but got " << typeName(indexSpecElem.type())}; } // Just use the simple collator, even though the index may have a separate collation @@ -427,10 +422,9 @@ StatusWith validateIndexSpec( const auto key = indexSpec.getObjectField(IndexDescriptor::kKeyPatternFieldName); if (IndexNames::findPluginName(key) != IndexNames::WILDCARD) { return {ErrorCodes::BadValue, - str::stream() << "The field '" << IndexDescriptor::kPathProjectionFieldName - << "' is only allowed in an '" - << IndexNames::WILDCARD - << "' index"}; + str::stream() + << "The field '" << IndexDescriptor::kPathProjectionFieldName + << "' is only allowed in an '" << IndexNames::WILDCARD << "' index"}; } if (indexSpecElem.type() != BSONType::Object) { return {ErrorCodes::TypeMismatch, @@ -440,10 +434,10 @@ StatusWith validateIndexSpec( } if (!key.hasField("$**")) { return {ErrorCodes::FailedToParse, - str::stream() << "The field '" << IndexDescriptor::kPathProjectionFieldName - << "' is only allowed when '" - << IndexDescriptor::kKeyPatternFieldName - << "' is {\"$**\": ±1}"}; + str::stream() + << "The field '" << IndexDescriptor::kPathProjectionFieldName + << "' is only allowed when '" << IndexDescriptor::kKeyPatternFieldName + << "' is {\"$**\": ±1}"}; } if (indexSpecElem.embeddedObject().isEmpty()) { @@ -486,10 +480,8 @@ StatusWith validateIndexSpec( return {ErrorCodes::CannotCreateIndex, str::stream() << "Invalid index specification " << indexSpec << "; cannot create an index with the '" - << IndexDescriptor::kCollationFieldName - << "' option and " - << IndexDescriptor::kIndexVersionFieldName - << "=" + << IndexDescriptor::kCollationFieldName << "' option and " + << IndexDescriptor::kIndexVersionFieldName << "=" << static_cast(*resolvedIndexVersion)}; } diff --git a/src/mongo/db/catalog/index_key_validate_test.cpp b/src/mongo/db/catalog/index_key_validate_test.cpp index bbb55b5281a..d61cbb8e0d7 100644 --- a/src/mongo/db/catalog/index_key_validate_test.cpp +++ b/src/mongo/db/catalog/index_key_validate_test.cpp @@ -127,8 +127,7 @@ TEST(IndexKeyValidateTest, KeyElementBooleanValueFailsForV2Indexes) { ASSERT_EQ(ErrorCodes::CannotCreateIndex, validateKeyPattern(BSON("a" << "2dsphere" - << "b" - << true), + << "b" << true), IndexVersion::kV2)); } @@ -137,8 +136,7 @@ TEST(IndexKeyValidateTest, KeyElementBooleanValueSucceedsForV1Indexes) { ASSERT_OK(validateKeyPattern(BSON("x" << false), IndexVersion::kV1)); ASSERT_OK(validateKeyPattern(BSON("a" << "2dsphere" - << "b" - << true), + << "b" << true), IndexVersion::kV1)); } diff --git a/src/mongo/db/catalog/index_spec_validate_test.cpp b/src/mongo/db/catalog/index_spec_validate_test.cpp index 560f4820579..6b472d09073 100644 --- a/src/mongo/db/catalog/index_spec_validate_test.cpp +++ b/src/mongo/db/catalog/index_spec_validate_test.cpp @@ -50,8 +50,8 @@ namespace mongo { namespace { -using index_key_validate::validateIndexSpec; using index_key_validate::validateIdIndexSpec; +using index_key_validate::validateIndexSpec; using index_key_validate::validateIndexSpecCollation; using unittest::EnsureFCV; @@ -140,16 +140,14 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfNamespaceIsNotAString) { validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("field" << 1) << "name" << "indexName" - << "ns" - << 1), + << "ns" << 1), kTestNamespace, serverGlobalParams.featureCompatibility)); ASSERT_EQ(ErrorCodes::TypeMismatch, validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("field" << 1) << "name" << "indexName" - << "ns" - << BSONObj()), + << "ns" << BSONObj()), kTestNamespace, serverGlobalParams.featureCompatibility)); } @@ -181,8 +179,7 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfNamespaceDoesNotMatch) { validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("field" << 1) << "name" << "indexName" - << "ns" - << kTestNamespace.coll()), + << "ns" << kTestNamespace.coll()), kTestNamespace, serverGlobalParams.featureCompatibility)); } @@ -191,8 +188,7 @@ TEST(IndexSpecValidateTest, ReturnsIndexSpecWithNamespaceFilledInIfItIsNotPresen auto result = validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("field" << 1) << "name" << "indexName" - << "v" - << 1), + << "v" << 1), kTestNamespace, serverGlobalParams.featureCompatibility); ASSERT_OK(result.getStatus()); @@ -200,10 +196,7 @@ TEST(IndexSpecValidateTest, ReturnsIndexSpecWithNamespaceFilledInIfItIsNotPresen // We don't care about the order of the fields in the resulting index specification. ASSERT_BSONOBJ_EQ(sorted(BSON("key" << BSON("field" << 1) << "name" << "indexName" - << "ns" - << kTestNamespace.ns() - << "v" - << 1)), + << "ns" << kTestNamespace.ns() << "v" << 1)), sorted(result.getValue())); // Verify that the index specification we returned is still considered valid. @@ -215,10 +208,7 @@ TEST(IndexSpecValidateTest, ReturnsIndexSpecUnchangedIfNamespaceAndVersionArePre auto result = validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("field" << 1) << "name" << "indexName" - << "ns" - << kTestNamespace.ns() - << "v" - << 1), + << "ns" << kTestNamespace.ns() << "v" << 1), kTestNamespace, serverGlobalParams.featureCompatibility); ASSERT_OK(result.getStatus()); @@ -228,8 +218,7 @@ TEST(IndexSpecValidateTest, ReturnsIndexSpecUnchangedIfNamespaceAndVersionArePre << "indexName" << "ns" << "test.index_spec_validate" - << "v" - << 1)), + << "v" << 1)), sorted(result.getValue())); } @@ -246,8 +235,7 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfVersionIsNotANumber) { validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("field" << 1) << "name" << "indexName" - << "v" - << BSONObj()), + << "v" << BSONObj()), kTestNamespace, serverGlobalParams.featureCompatibility)); } @@ -257,32 +245,28 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfVersionIsNotRepresentableAsInt) { validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("field" << 1) << "name" << "indexName" - << "v" - << 2.2), + << "v" << 2.2), kTestNamespace, serverGlobalParams.featureCompatibility)); ASSERT_EQ(ErrorCodes::BadValue, validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("field" << 1) << "name" << "indexName" - << "v" - << std::nan("1")), + << "v" << std::nan("1")), kTestNamespace, serverGlobalParams.featureCompatibility)); ASSERT_EQ(ErrorCodes::BadValue, validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("field" << 1) << "name" << "indexName" - << "v" - << std::numeric_limits::infinity()), + << "v" << std::numeric_limits::infinity()), kTestNamespace, serverGlobalParams.featureCompatibility)); ASSERT_EQ(ErrorCodes::BadValue, validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("field" << 1) << "name" << "indexName" - << "v" - << std::numeric_limits::max()), + << "v" << std::numeric_limits::max()), kTestNamespace, serverGlobalParams.featureCompatibility)); } @@ -292,8 +276,7 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfVersionIsV0) { validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("field" << 1) << "name" << "indexName" - << "v" - << 0), + << "v" << 0), kTestNamespace, serverGlobalParams.featureCompatibility)); } @@ -303,9 +286,7 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfVersionIsUnsupported) { validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("field" << 1) << "name" << "indexName" - << "v" - << 3 - << "collation" + << "v" << 3 << "collation" << BSON("locale" << "en")), kTestNamespace, @@ -315,8 +296,7 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfVersionIsUnsupported) { validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("field" << 1) << "name" << "indexName" - << "v" - << -3LL), + << "v" << -3LL), kTestNamespace, serverGlobalParams.featureCompatibility)); } @@ -325,8 +305,7 @@ TEST(IndexSpecValidateTest, AcceptsIndexVersionsThatAreAllowedForCreation) { auto result = validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("field" << 1) << "name" << "indexName" - << "v" - << 1), + << "v" << 1), kTestNamespace, serverGlobalParams.featureCompatibility); ASSERT_OK(result.getStatus()); @@ -334,17 +313,13 @@ TEST(IndexSpecValidateTest, AcceptsIndexVersionsThatAreAllowedForCreation) { // We don't care about the order of the fields in the resulting index specification. ASSERT_BSONOBJ_EQ(sorted(BSON("key" << BSON("field" << 1) << "name" << "indexName" - << "ns" - << kTestNamespace.ns() - << "v" - << 1)), + << "ns" << kTestNamespace.ns() << "v" << 1)), sorted(result.getValue())); result = validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("field" << 1) << "name" << "indexName" - << "v" - << 2LL), + << "v" << 2LL), kTestNamespace, serverGlobalParams.featureCompatibility); ASSERT_OK(result.getStatus()); @@ -352,10 +327,7 @@ TEST(IndexSpecValidateTest, AcceptsIndexVersionsThatAreAllowedForCreation) { // We don't care about the order of the fields in the resulting index specification. ASSERT_BSONOBJ_EQ(sorted(BSON("key" << BSON("field" << 1) << "name" << "indexName" - << "ns" - << kTestNamespace.ns() - << "v" - << 2LL)), + << "ns" << kTestNamespace.ns() << "v" << 2LL)), sorted(result.getValue())); } @@ -363,8 +335,7 @@ TEST(IndexSpecValidateTest, DefaultIndexVersionIsV2) { auto result = validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("field" << 1) << "name" << "indexName" - << "ns" - << kTestNamespace.ns()), + << "ns" << kTestNamespace.ns()), kTestNamespace, serverGlobalParams.featureCompatibility); ASSERT_OK(result.getStatus()); @@ -372,10 +343,7 @@ TEST(IndexSpecValidateTest, DefaultIndexVersionIsV2) { // We don't care about the order of the fields in the resulting index specification. ASSERT_BSONOBJ_EQ(sorted(BSON("key" << BSON("field" << 1) << "name" << "indexName" - << "ns" - << kTestNamespace.ns() - << "v" - << 2)), + << "ns" << kTestNamespace.ns() << "v" << 2)), sorted(result.getValue())); // Verify that the index specification we returned is still considered valid. @@ -387,8 +355,7 @@ TEST(IndexSpecValidateTest, AcceptsIndexVersionV1) { auto result = validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("field" << 1) << "name" << "indexName" - << "v" - << 1), + << "v" << 1), kTestNamespace, serverGlobalParams.featureCompatibility); ASSERT_OK(result.getStatus()); @@ -396,10 +363,7 @@ TEST(IndexSpecValidateTest, AcceptsIndexVersionV1) { // We don't care about the order of the fields in the resulting index specification. ASSERT_BSONOBJ_EQ(sorted(BSON("key" << BSON("field" << 1) << "name" << "indexName" - << "ns" - << kTestNamespace.ns() - << "v" - << 1)), + << "ns" << kTestNamespace.ns() << "v" << 1)), sorted(result.getValue())); } @@ -408,8 +372,7 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfCollationIsNotAnObject) { validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("field" << 1) << "name" << "indexName" - << "collation" - << 1), + << "collation" << 1), kTestNamespace, serverGlobalParams.featureCompatibility)); ASSERT_EQ(ErrorCodes::TypeMismatch, @@ -424,8 +387,7 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfCollationIsNotAnObject) { validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("field" << 1) << "name" << "indexName" - << "collation" - << BSONArray()), + << "collation" << BSONArray()), kTestNamespace, serverGlobalParams.featureCompatibility)); } @@ -435,8 +397,7 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfCollationIsEmpty) { validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("field" << 1) << "name" << "indexName" - << "collation" - << BSONObj()), + << "collation" << BSONObj()), kTestNamespace, serverGlobalParams.featureCompatibility)); } @@ -449,8 +410,7 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfCollationIsPresentAndVersionIsLessTh << "collation" << BSON("locale" << "simple") - << "v" - << 1), + << "v" << 1), kTestNamespace, serverGlobalParams.featureCompatibility)); } @@ -459,9 +419,7 @@ TEST(IndexSpecValidateTest, AcceptsAnyNonEmptyObjectValueForCollation) { auto result = validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("field" << 1) << "name" << "indexName" - << "v" - << 2 - << "collation" + << "v" << 2 << "collation" << BSON("locale" << "simple")), kTestNamespace, @@ -471,11 +429,7 @@ TEST(IndexSpecValidateTest, AcceptsAnyNonEmptyObjectValueForCollation) { // We don't care about the order of the fields in the resulting index specification. ASSERT_BSONOBJ_EQ(sorted(BSON("key" << BSON("field" << 1) << "name" << "indexName" - << "ns" - << kTestNamespace.ns() - << "v" - << 2 - << "collation" + << "ns" << kTestNamespace.ns() << "v" << 2 << "collation" << BSON("locale" << "simple"))), sorted(result.getValue())); @@ -483,9 +437,7 @@ TEST(IndexSpecValidateTest, AcceptsAnyNonEmptyObjectValueForCollation) { result = validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("field" << 1) << "name" << "indexName" - << "v" - << 2 - << "collation" + << "v" << 2 << "collation" << BSON("unknownCollationOption" << true)), kTestNamespace, serverGlobalParams.featureCompatibility); @@ -494,11 +446,7 @@ TEST(IndexSpecValidateTest, AcceptsAnyNonEmptyObjectValueForCollation) { // We don't care about the order of the fields in the resulting index specification. ASSERT_BSONOBJ_EQ(sorted(BSON("key" << BSON("field" << 1) << "name" << "indexName" - << "ns" - << kTestNamespace.ns() - << "v" - << 2 - << "collation" + << "ns" << kTestNamespace.ns() << "v" << 2 << "collation" << BSON("unknownCollationOption" << true))), sorted(result.getValue())); } @@ -507,9 +455,7 @@ TEST(IndexSpecValidateTest, AcceptsIndexSpecIfCollationIsPresentAndVersionIsEqua auto result = validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("field" << 1) << "name" << "indexName" - << "v" - << 2 - << "collation" + << "v" << 2 << "collation" << BSON("locale" << "en")), kTestNamespace, @@ -519,11 +465,7 @@ TEST(IndexSpecValidateTest, AcceptsIndexSpecIfCollationIsPresentAndVersionIsEqua // We don't care about the order of the fields in the resulting index specification. ASSERT_BSONOBJ_EQ(sorted(BSON("key" << BSON("field" << 1) << "name" << "indexName" - << "ns" - << kTestNamespace.ns() - << "v" - << 2 - << "collation" + << "ns" << kTestNamespace.ns() << "v" << 2 << "collation" << BSON("locale" << "en"))), sorted(result.getValue())); @@ -533,10 +475,7 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfUnknownFieldIsPresentInSpecV2) { auto result = validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("field" << 1) << "name" << "indexName" - << "v" - << 2 - << "unknownField" - << 1), + << "v" << 2 << "unknownField" << 1), kTestNamespace, serverGlobalParams.featureCompatibility); ASSERT_EQ(ErrorCodes::InvalidIndexSpecificationOption, result); @@ -546,10 +485,7 @@ TEST(IndexSpecValidateTest, ReturnsAnErrorIfUnknownFieldIsPresentInSpecV1) { auto result = validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("field" << 1) << "name" << "indexName" - << "v" - << 1 - << "unknownField" - << 1), + << "v" << 1 << "unknownField" << 1), kTestNamespace, serverGlobalParams.featureCompatibility); ASSERT_EQ(ErrorCodes::InvalidIndexSpecificationOption, result); @@ -559,95 +495,59 @@ TEST(IdIndexSpecValidateTest, ReturnsAnErrorIfKeyPatternIsIncorrectForIdIndex) { ASSERT_EQ(ErrorCodes::BadValue, validateIdIndexSpec(BSON("key" << BSON("_id" << -1) << "name" << "_id_" - << "ns" - << kTestNamespace.ns() - << "v" - << 2))); + << "ns" << kTestNamespace.ns() << "v" << 2))); ASSERT_EQ(ErrorCodes::BadValue, validateIdIndexSpec(BSON("key" << BSON("a" << 1) << "name" << "_id_" - << "ns" - << kTestNamespace.ns() - << "v" - << 2))); + << "ns" << kTestNamespace.ns() << "v" << 2))); } TEST(IdIndexSpecValidateTest, ReturnsOKStatusIfKeyPatternCorrectForIdIndex) { ASSERT_OK(validateIdIndexSpec(BSON("key" << BSON("_id" << 1) << "name" << "anyname" - << "ns" - << kTestNamespace.ns() - << "v" - << 2))); + << "ns" << kTestNamespace.ns() << "v" << 2))); } TEST(IdIndexSpecValidateTest, ReturnsAnErrorIfFieldNotAllowedForIdIndex) { ASSERT_EQ(ErrorCodes::InvalidIndexSpecificationOption, validateIdIndexSpec(BSON("key" << BSON("_id" << 1) << "name" << "_id_" - << "ns" - << kTestNamespace.ns() - << "v" - << 2 - << "background" - << false))); + << "ns" << kTestNamespace.ns() << "v" << 2 + << "background" << false))); ASSERT_EQ(ErrorCodes::InvalidIndexSpecificationOption, validateIdIndexSpec(BSON("key" << BSON("_id" << 1) << "name" << "_id_" - << "ns" - << kTestNamespace.ns() - << "v" - << 2 - << "unique" + << "ns" << kTestNamespace.ns() << "v" << 2 << "unique" << true))); ASSERT_EQ(ErrorCodes::InvalidIndexSpecificationOption, validateIdIndexSpec(BSON("key" << BSON("_id" << 1) << "name" << "_id_" - << "ns" - << kTestNamespace.ns() - << "v" - << 2 - << "partialFilterExpression" - << BSON("a" << 5)))); + << "ns" << kTestNamespace.ns() << "v" << 2 + << "partialFilterExpression" << BSON("a" << 5)))); ASSERT_EQ(ErrorCodes::InvalidIndexSpecificationOption, validateIdIndexSpec(BSON("key" << BSON("_id" << 1) << "name" << "_id_" - << "ns" - << kTestNamespace.ns() - << "v" - << 2 - << "sparse" + << "ns" << kTestNamespace.ns() << "v" << 2 << "sparse" << false))); ASSERT_EQ(ErrorCodes::InvalidIndexSpecificationOption, validateIdIndexSpec(BSON("key" << BSON("_id" << 1) << "name" << "_id_" - << "ns" - << kTestNamespace.ns() - << "v" - << 2 - << "expireAfterSeconds" - << 3600))); + << "ns" << kTestNamespace.ns() << "v" << 2 + << "expireAfterSeconds" << 3600))); ASSERT_EQ(ErrorCodes::InvalidIndexSpecificationOption, validateIdIndexSpec(BSON("key" << BSON("_id" << 1) << "name" << "_id_" - << "ns" - << kTestNamespace.ns() - << "v" - << 2 - << "storageEngine" - << BSONObj()))); + << "ns" << kTestNamespace.ns() << "v" << 2 + << "storageEngine" << BSONObj()))); } TEST(IdIndexSpecValidateTest, ReturnsOKStatusIfAllFieldsAllowedForIdIndex) { - ASSERT_OK(validateIdIndexSpec(BSON("key" << BSON("_id" << 1) << "name" - << "_id_" - << "ns" - << kTestNamespace.ns() - << "v" - << 2 - << "collation" - << BSON("locale" - << "simple")))); + ASSERT_OK( + validateIdIndexSpec(BSON("key" << BSON("_id" << 1) << "name" + << "_id_" + << "ns" << kTestNamespace.ns() << "v" << 2 << "collation" + << BSON("locale" + << "simple")))); } TEST(IndexSpecCollationValidateTest, FillsInFullCollationSpec) { @@ -659,10 +559,7 @@ TEST(IndexSpecCollationValidateTest, FillsInFullCollationSpec) { auto result = validateIndexSpecCollation(opCtx.get(), BSON("key" << BSON("field" << 1) << "name" << "indexName" - << "ns" - << kTestNamespace.ns() - << "v" - << 2 + << "ns" << kTestNamespace.ns() << "v" << 2 << "collation" << BSON("locale" << "mock_reverse_string")), @@ -670,34 +567,21 @@ TEST(IndexSpecCollationValidateTest, FillsInFullCollationSpec) { ASSERT_OK(result.getStatus()); // We don't care about the order of the fields in the resulting index specification. - ASSERT_BSONOBJ_EQ(sorted(BSON("key" << BSON("field" << 1) << "name" - << "indexName" - << "ns" - << kTestNamespace.ns() - << "v" - << 2 - << "collation" - << BSON("locale" - << "mock_reverse_string" - << "caseLevel" - << false - << "caseFirst" - << "off" - << "strength" - << 3 - << "numericOrdering" - << false - << "alternate" - << "non-ignorable" - << "maxVariable" - << "punct" - << "normalization" - << false - << "backwards" - << false - << "version" - << "mock_version"))), - sorted(result.getValue())); + ASSERT_BSONOBJ_EQ( + sorted(BSON("key" << BSON("field" << 1) << "name" + << "indexName" + << "ns" << kTestNamespace.ns() << "v" << 2 << "collation" + << BSON("locale" + << "mock_reverse_string" + << "caseLevel" << false << "caseFirst" + << "off" + << "strength" << 3 << "numericOrdering" << false << "alternate" + << "non-ignorable" + << "maxVariable" + << "punct" + << "normalization" << false << "backwards" << false << "version" + << "mock_version"))), + sorted(result.getValue())); } TEST(IndexSpecCollationValidateTest, RemovesCollationFieldIfSimple) { @@ -709,10 +593,7 @@ TEST(IndexSpecCollationValidateTest, RemovesCollationFieldIfSimple) { auto result = validateIndexSpecCollation(opCtx.get(), BSON("key" << BSON("field" << 1) << "name" << "indexName" - << "ns" - << kTestNamespace.ns() - << "v" - << 2 + << "ns" << kTestNamespace.ns() << "v" << 2 << "collation" << BSON("locale" << "simple")), @@ -722,10 +603,7 @@ TEST(IndexSpecCollationValidateTest, RemovesCollationFieldIfSimple) { // We don't care about the order of the fields in the resulting index specification. ASSERT_BSONOBJ_EQ(sorted(BSON("key" << BSON("field" << 1) << "name" << "indexName" - << "ns" - << kTestNamespace.ns() - << "v" - << 2)), + << "ns" << kTestNamespace.ns() << "v" << 2)), sorted(result.getValue())); } @@ -738,50 +616,33 @@ TEST(IndexSpecCollationValidateTest, FillsInCollationFieldWithCollectionDefaultI auto result = validateIndexSpecCollation(opCtx.get(), BSON("key" << BSON("field" << 1) << "name" << "indexName" - << "ns" - << kTestNamespace.ns() - << "v" - << 2), + << "ns" << kTestNamespace.ns() << "v" << 2), &defaultCollator); ASSERT_OK(result.getStatus()); // We don't care about the order of the fields in the resulting index specification. - ASSERT_BSONOBJ_EQ(sorted(BSON("key" << BSON("field" << 1) << "name" - << "indexName" - << "ns" - << kTestNamespace.ns() - << "v" - << 2 - << "collation" - << BSON("locale" - << "mock_reverse_string" - << "caseLevel" - << false - << "caseFirst" - << "off" - << "strength" - << 3 - << "numericOrdering" - << false - << "alternate" - << "non-ignorable" - << "maxVariable" - << "punct" - << "normalization" - << false - << "backwards" - << false - << "version" - << "mock_version"))), - sorted(result.getValue())); + ASSERT_BSONOBJ_EQ( + sorted(BSON("key" << BSON("field" << 1) << "name" + << "indexName" + << "ns" << kTestNamespace.ns() << "v" << 2 << "collation" + << BSON("locale" + << "mock_reverse_string" + << "caseLevel" << false << "caseFirst" + << "off" + << "strength" << 3 << "numericOrdering" << false << "alternate" + << "non-ignorable" + << "maxVariable" + << "punct" + << "normalization" << false << "backwards" << false << "version" + << "mock_version"))), + sorted(result.getValue())); } TEST(IndexSpecPartialFilterTest, FailsIfPartialFilterIsNotAnObject) { auto result = validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("field" << 1) << "name" << "indexName" - << "partialFilterExpression" - << 1), + << "partialFilterExpression" << 1), kTestNamespace, serverGlobalParams.featureCompatibility); ASSERT_EQ(result.getStatus(), ErrorCodes::TypeMismatch); @@ -802,8 +663,7 @@ TEST(IndexSpecPartialFilterTest, AcceptsValidPartialFilterExpression) { auto result = validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("field" << 1) << "name" << "indexName" - << "partialFilterExpression" - << BSON("a" << 1)), + << "partialFilterExpression" << BSON("a" << 1)), kTestNamespace, serverGlobalParams.featureCompatibility); ASSERT_OK(result.getStatus()); @@ -811,25 +671,25 @@ TEST(IndexSpecPartialFilterTest, AcceptsValidPartialFilterExpression) { TEST(IndexSpecWildcard, SucceedsWithInclusion) { EnsureFCV guard(ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42); - auto result = validateIndexSpec(kDefaultOpCtx, - BSON("key" << BSON("$**" << 1) << "name" - << "indexName" - << "wildcardProjection" - << BSON("a" << 1 << "b" << 1)), - kTestNamespace, - serverGlobalParams.featureCompatibility); + auto result = + validateIndexSpec(kDefaultOpCtx, + BSON("key" << BSON("$**" << 1) << "name" + << "indexName" + << "wildcardProjection" << BSON("a" << 1 << "b" << 1)), + kTestNamespace, + serverGlobalParams.featureCompatibility); ASSERT_OK(result.getStatus()); } TEST(IndexSpecWildcard, SucceedsWithExclusion) { EnsureFCV guard(ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42); - auto result = validateIndexSpec(kDefaultOpCtx, - BSON("key" << BSON("$**" << 1) << "name" - << "indexName" - << "wildcardProjection" - << BSON("a" << 0 << "b" << 0)), - kTestNamespace, - serverGlobalParams.featureCompatibility); + auto result = + validateIndexSpec(kDefaultOpCtx, + BSON("key" << BSON("$**" << 1) << "name" + << "indexName" + << "wildcardProjection" << BSON("a" << 0 << "b" << 0)), + kTestNamespace, + serverGlobalParams.featureCompatibility); ASSERT_OK(result.getStatus()); } @@ -895,13 +755,13 @@ TEST(IndexSpecWildcard, FailsWithImproperFeatureCompatabilityVersion) { TEST(IndexSpecWildcard, FailsWithMixedProjection) { EnsureFCV guard(ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo42); - auto result = validateIndexSpec(kDefaultOpCtx, - BSON("key" << BSON("$**" << 1) << "name" - << "indexName" - << "wildcardProjection" - << BSON("a" << 1 << "b" << 0)), - kTestNamespace, - serverGlobalParams.featureCompatibility); + auto result = + validateIndexSpec(kDefaultOpCtx, + BSON("key" << BSON("$**" << 1) << "name" + << "indexName" + << "wildcardProjection" << BSON("a" << 1 << "b" << 0)), + kTestNamespace, + serverGlobalParams.featureCompatibility); ASSERT_EQ(result.getStatus().code(), 40178); } @@ -923,8 +783,7 @@ TEST(IndexSpecWildcard, FailsWhenProjectionPluginNotWildcard) { auto result = validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("a" << 1) << "name" << "indexName" - << "wildcardProjection" - << BSON("a" << 1)), + << "wildcardProjection" << BSON("a" << 1)), kTestNamespace, serverGlobalParams.featureCompatibility); ASSERT_EQ(result.getStatus().code(), ErrorCodes::BadValue); @@ -935,8 +794,7 @@ TEST(IndexSpecWildcard, FailsWhenProjectionIsNotAnObject) { auto result = validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("$**" << 1) << "name" << "indexName" - << "wildcardProjection" - << 4), + << "wildcardProjection" << 4), kTestNamespace, serverGlobalParams.featureCompatibility); ASSERT_EQ(result.getStatus().code(), ErrorCodes::TypeMismatch); @@ -947,8 +805,7 @@ TEST(IndexSpecWildcard, FailsWithEmptyProjection) { auto result = validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("$**" << 1) << "name" << "indexName" - << "wildcardProjection" - << BSONObj()), + << "wildcardProjection" << BSONObj()), kTestNamespace, serverGlobalParams.featureCompatibility); ASSERT_EQ(result.getStatus().code(), ErrorCodes::FailedToParse); @@ -959,8 +816,7 @@ TEST(IndexSpecWildcard, FailsWhenInclusionWithSubpath) { auto result = validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("a.$**" << 1) << "name" << "indexName" - << "wildcardProjection" - << BSON("a" << 1)), + << "wildcardProjection" << BSON("a" << 1)), kTestNamespace, serverGlobalParams.featureCompatibility); ASSERT_EQ(result.getStatus().code(), ErrorCodes::FailedToParse); @@ -971,8 +827,7 @@ TEST(IndexSpecWildcard, FailsWhenExclusionWithSubpath) { auto result = validateIndexSpec(kDefaultOpCtx, BSON("key" << BSON("a.$**" << 1) << "name" << "indexName" - << "wildcardProjection" - << BSON("b" << 0)), + << "wildcardProjection" << BSON("b" << 0)), kTestNamespace, serverGlobalParams.featureCompatibility); ASSERT_EQ(result.getStatus().code(), ErrorCodes::FailedToParse); diff --git a/src/mongo/db/catalog/index_timestamp_helper.h b/src/mongo/db/catalog/index_timestamp_helper.h index 581b1bd4740..9ae4457e409 100644 --- a/src/mongo/db/catalog/index_timestamp_helper.h +++ b/src/mongo/db/catalog/index_timestamp_helper.h @@ -55,6 +55,6 @@ void setGhostCommitTimestampForWrite(OperationContext* opCtx, const NamespaceStr * also throw WriteConflictException. */ bool setGhostCommitTimestampForCatalogWrite(OperationContext* opCtx, const NamespaceString& nss); -}; +}; // namespace IndexTimestampHelper -} // mongo +} // namespace mongo diff --git a/src/mongo/db/catalog/multi_index_block.cpp b/src/mongo/db/catalog/multi_index_block.cpp index b3c0c7e00eb..05068e4a89f 100644 --- a/src/mongo/db/catalog/multi_index_block.cpp +++ b/src/mongo/db/catalog/multi_index_block.cpp @@ -135,8 +135,8 @@ void MultiIndexBlock::cleanUpAfterBuild(OperationContext* opCtx, Collection* col replCoord->canAcceptWritesForDatabase(opCtx, "admin")) { opCtx->getServiceContext()->getOpObserver()->onOpMessage( opCtx, - BSON("msg" << std::string(str::stream() << "Failing index builds. Coll: " - << nss))); + BSON("msg" << std::string(str::stream() + << "Failing index builds. Coll: " << nss))); } else { // Simply get a timestamp to write with here; we can't write to the oplog. repl::UnreplicatedWritesBlock uwb(opCtx); @@ -182,7 +182,7 @@ MultiIndexBlock::OnInitFn MultiIndexBlock::kNoopOnInitFn = MultiIndexBlock::OnInitFn MultiIndexBlock::makeTimestampedIndexOnInitFn(OperationContext* opCtx, const Collection* coll) { - return [ opCtx, ns = coll->ns() ](std::vector & specs)->Status { + return [opCtx, ns = coll->ns()](std::vector& specs) -> Status { auto replCoord = repl::ReplicationCoordinator::get(opCtx); if (opCtx->recoveryUnit()->getCommitTimestamp().isNull() && replCoord->canAcceptWritesForDatabase(opCtx, "admin")) { @@ -213,12 +213,8 @@ StatusWith> MultiIndexBlock::init(OperationContext* opCtx, if (State::kAborted == _getState()) { return {ErrorCodes::IndexBuildAborted, str::stream() << "Index build aborted: " << _abortReason - << ". Cannot initialize index builder: " - << collection->ns() - << " (" - << collection->uuid() - << "): " - << indexSpecs.size() + << ". Cannot initialize index builder: " << collection->ns() << " (" + << collection->uuid() << "): " << indexSpecs.size() << " provided. First index spec: " << (indexSpecs.empty() ? BSONObj() : indexSpecs[0])}; } @@ -725,8 +721,7 @@ Status MultiIndexBlock::commit(OperationContext* opCtx, return { ErrorCodes::IndexBuildAborted, str::stream() << "Index build aborted: " << _abortReason - << ". Cannot commit index builder: " - << collection->ns() + << ". Cannot commit index builder: " << collection->ns() << (_collectionUUID ? (" (" + _collectionUUID->toString() + ")") : "")}; } diff --git a/src/mongo/db/catalog/record_store_validate_adaptor.cpp b/src/mongo/db/catalog/record_store_validate_adaptor.cpp index ec6d8bfb497..f86fa1e0bd5 100644 --- a/src/mongo/db/catalog/record_store_validate_adaptor.cpp +++ b/src/mongo/db/catalog/record_store_validate_adaptor.cpp @@ -57,7 +57,7 @@ KeyString::Builder makeWildCardMultikeyMetadataKeyString(const BSONObj& indexKey multikeyMetadataOrd, multikeyMetadataRecordId}; } -} +} // namespace Status RecordStoreValidateAdaptor::validate(const RecordId& recordId, const RecordData& record, @@ -107,9 +107,9 @@ Status RecordStoreValidateAdaptor::validate(const RecordId& recordId, {documentKeySet.begin(), documentKeySet.end()}, {multikeyMetadataKeys.begin(), multikeyMetadataKeys.end()}, multikeyPaths)) { - std::string msg = str::stream() << "Index " << descriptor->indexName() - << " is not multi-key but has more than one" - << " key in document " << recordId; + std::string msg = str::stream() + << "Index " << descriptor->indexName() << " is not multi-key but has more than one" + << " key in document " << recordId; ValidateResults& curRecordResults = (*_indexNsResultsMap)[descriptor->indexName()]; curRecordResults.errors.push_back(msg); curRecordResults.valid = false; @@ -183,9 +183,9 @@ void RecordStoreValidateAdaptor::traverseIndex(const IndexAccessMethod* iam, } if (results && _indexConsistency->getMultikeyMetadataPathCount(indexInfo) > 0) { - results->errors.push_back( - str::stream() << "Index '" << descriptor->indexName() - << "' has one or more missing multikey metadata index keys"); + results->errors.push_back(str::stream() + << "Index '" << descriptor->indexName() + << "' has one or more missing multikey metadata index keys"); results->valid = false; } @@ -258,9 +258,9 @@ void RecordStoreValidateAdaptor::validateIndexKeyCount(const IndexDescriptor* id if (idx->isIdIndex() && numTotalKeys != numRecs) { hasTooFewKeys = numTotalKeys < numRecs ? true : hasTooFewKeys; - std::string msg = str::stream() << "number of _id index entries (" << numTotalKeys - << ") does not match the number of documents in the index (" - << numRecs << ")"; + std::string msg = str::stream() + << "number of _id index entries (" << numTotalKeys + << ") does not match the number of documents in the index (" << numRecs << ")"; if (noErrorOnTooFewKeys && (numTotalKeys < numRecs)) { results.warnings.push_back(msg); } else { diff --git a/src/mongo/db/catalog/record_store_validate_adaptor.h b/src/mongo/db/catalog/record_store_validate_adaptor.h index 57fd4852fa1..0e64283bbc0 100644 --- a/src/mongo/db/catalog/record_store_validate_adaptor.h +++ b/src/mongo/db/catalog/record_store_validate_adaptor.h @@ -103,4 +103,4 @@ private: IndexCatalog* _indexCatalog; ValidateResultsMap* _indexNsResultsMap; }; -} // namespace +} // namespace mongo diff --git a/src/mongo/db/catalog/rename_collection.cpp b/src/mongo/db/catalog/rename_collection.cpp index 5b41b3e3539..352f2ca73b8 100644 --- a/src/mongo/db/catalog/rename_collection.cpp +++ b/src/mongo/db/catalog/rename_collection.cpp @@ -148,15 +148,8 @@ Status renameTargetCollectionToTmp(OperationContext* opCtx, if (!tmpNameResult.isOK()) { return tmpNameResult.getStatus().withContext( str::stream() << "Cannot generate a temporary collection name for the target " - << targetNs - << " (" - << targetUUID - << ") so that the source" - << sourceNs - << " (" - << sourceUUID - << ") could be renamed to " - << targetNs); + << targetNs << " (" << targetUUID << ") so that the source" << sourceNs + << " (" << sourceUUID << ") could be renamed to " << targetNs); } const auto& tmpName = tmpNameResult.getValue(); const bool stayTemp = true; @@ -290,9 +283,10 @@ Status renameCollectionWithinDB(OperationContext* opCtx, boost::optional targetLock; // To prevent deadlock, always lock system.views collection in the end because concurrent // view-related operations always lock system.views in the end. - if (!source.isSystemDotViews() && (target.isSystemDotViews() || - ResourceId(RESOURCE_COLLECTION, source.ns()) < - ResourceId(RESOURCE_COLLECTION, target.ns()))) { + if (!source.isSystemDotViews() && + (target.isSystemDotViews() || + ResourceId(RESOURCE_COLLECTION, source.ns()) < + ResourceId(RESOURCE_COLLECTION, target.ns()))) { // To prevent deadlock, always lock source and target in ascending resourceId order. sourceLock.emplace(opCtx, source, MODE_X); targetLock.emplace(opCtx, target, MODE_X); @@ -498,8 +492,7 @@ Status renameBetweenDBs(OperationContext* opCtx, if (!tmpNameResult.isOK()) { return tmpNameResult.getStatus().withContext( str::stream() << "Cannot generate temporary collection name to rename " << source - << " to " - << target); + << " to " << target); } const auto& tmpName = tmpNameResult.getValue(); @@ -586,7 +579,7 @@ Status renameBetweenDBs(OperationContext* opCtx, tmpColl->uuid(), indexToCopy, false // fromMigrate - ); + ); auto indexResult = tmpIndexCatalog->createIndexOnEmptyCollection(opCtx, indexToCopy); if (!indexResult.isOK()) { @@ -647,7 +640,7 @@ Status renameBetweenDBs(OperationContext* opCtx, } cursor->save(); // When this exits via success or WCE, we need to restore the cursor. - ON_BLOCK_EXIT([ opCtx, ns = tmpName.ns(), &cursor ]() { + ON_BLOCK_EXIT([opCtx, ns = tmpName.ns(), &cursor]() { writeConflictRetry( opCtx, "retryRestoreCursor", ns, [&cursor] { cursor->restore(); }); }); @@ -861,9 +854,7 @@ Status renameCollectionForRollback(OperationContext* opCtx, invariant(source->db() == target.db(), str::stream() << "renameCollectionForRollback: source and target namespaces must " "have the same database. source: " - << *source - << ". target: " - << target); + << *source << ". target: " << target); log() << "renameCollectionForRollback: rename " << *source << " (" << uuid << ") to " << target << "."; diff --git a/src/mongo/db/catalog/rename_collection_test.cpp b/src/mongo/db/catalog/rename_collection_test.cpp index 903461b9133..11da9388c03 100644 --- a/src/mongo/db/catalog/rename_collection_test.cpp +++ b/src/mongo/db/catalog/rename_collection_test.cpp @@ -329,8 +329,8 @@ void _createCollection(OperationContext* opCtx, << " does not exist."; WriteUnitOfWork wuow(opCtx); - ASSERT_TRUE(db->createCollection(opCtx, nss, options)) << "Failed to create collection " - << nss << " due to unknown error."; + ASSERT_TRUE(db->createCollection(opCtx, nss, options)) + << "Failed to create collection " << nss << " due to unknown error."; wuow.commit(); }); @@ -414,11 +414,8 @@ void _createIndexOnEmptyCollection(OperationContext* opCtx, ASSERT_TRUE(collection) << "Cannot create index on empty collection " << nss << " because collection " << nss << " does not exist."; - auto indexInfoObj = BSON( - "v" << int(IndexDescriptor::kLatestIndexVersion) << "key" << BSON("a" << 1) << "name" - << indexName - << "ns" - << nss.ns()); + auto indexInfoObj = BSON("v" << int(IndexDescriptor::kLatestIndexVersion) << "key" + << BSON("a" << 1) << "name" << indexName << "ns" << nss.ns()); auto indexCatalog = collection->getIndexCatalog(); WriteUnitOfWork wuow(opCtx); @@ -723,8 +720,8 @@ TEST_F(RenameCollectionTest, RenameCollectionMakesTargetCollectionDropPendingIfD ASSERT_OK(renameCollection(_opCtx.get(), _sourceNss, _targetNss, options)); ASSERT_FALSE(_collectionExists(_opCtx.get(), _sourceNss)) << "source collection " << _sourceNss << " still exists after successful rename"; - ASSERT_TRUE(_collectionExists(_opCtx.get(), _targetNss)) << "target collection " << _targetNss - << " missing after successful rename"; + ASSERT_TRUE(_collectionExists(_opCtx.get(), _targetNss)) + << "target collection " << _targetNss << " missing after successful rename"; ASSERT_TRUE(_opObserver->onRenameCollectionCalled); ASSERT(_opObserver->onRenameCollectionDropTarget); @@ -748,8 +745,8 @@ TEST_F(RenameCollectionTest, ASSERT_OK(renameCollection(_opCtx.get(), _sourceNss, _targetNss, options)); ASSERT_FALSE(_collectionExists(_opCtx.get(), _sourceNss)) << "source collection " << _sourceNss << " still exists after successful rename"; - ASSERT_TRUE(_collectionExists(_opCtx.get(), _targetNss)) << "target collection " << _targetNss - << " missing after successful rename"; + ASSERT_TRUE(_collectionExists(_opCtx.get(), _targetNss)) + << "target collection " << _targetNss << " missing after successful rename"; ASSERT_TRUE(_opObserver->onRenameCollectionCalled); ASSERT_FALSE(_opObserver->onRenameCollectionDropTarget); @@ -835,9 +832,8 @@ TEST_F(RenameCollectionTest, RenameCollectionForApplyOpsDropTargetByUUIDEvenIfSo _createCollectionWithUUID(_opCtx.get(), _targetNss); auto dropTargetUUID = _createCollectionWithUUID(_opCtx.get(), dropTargetNss); auto uuidDoc = BSON("ui" << UUID::gen()); - auto cmd = - BSON("renameCollection" << missingSourceNss.ns() << "to" << _targetNss.ns() << "dropTarget" - << dropTargetUUID); + auto cmd = BSON("renameCollection" << missingSourceNss.ns() << "to" << _targetNss.ns() + << "dropTarget" << dropTargetUUID); ASSERT_OK(renameCollectionForApplyOps( _opCtx.get(), missingSourceNss.db().toString(), uuidDoc["ui"], cmd, {})); ASSERT_TRUE(_collectionExists(_opCtx.get(), _targetNss)); @@ -875,9 +871,8 @@ TEST_F(RenameCollectionTest, RenameCollectionForApplyOpsDropTargetByUUIDEvenIfSo auto dropTargetUUID = _createCollectionWithUUID(_opCtx.get(), dropTargetNss); auto uuidDoc = BSON("ui" << _createCollectionWithUUID(_opCtx.get(), dropPendingNss)); - auto cmd = - BSON("renameCollection" << dropPendingNss.ns() << "to" << _targetNss.ns() << "dropTarget" - << dropTargetUUID); + auto cmd = BSON("renameCollection" << dropPendingNss.ns() << "to" << _targetNss.ns() + << "dropTarget" << dropTargetUUID); repl::UnreplicatedWritesBlock uwb(_opCtx.get()); repl::OpTime renameOpTime = {Timestamp(Seconds(200), 1U), 1LL}; @@ -920,8 +915,8 @@ void _testRenameCollectionStayTemp(OperationContext* opCtx, RenameCollectionOptions options; options.stayTemp = stayTemp; ASSERT_OK(renameCollection(opCtx, sourceNss, targetNss, options)); - ASSERT_FALSE(_collectionExists(opCtx, sourceNss)) << "source collection " << sourceNss - << " still exists after successful rename"; + ASSERT_FALSE(_collectionExists(opCtx, sourceNss)) + << "source collection " << sourceNss << " still exists after successful rename"; if (!isSourceCollectionTemporary) { ASSERT_FALSE(_isTempCollection(opCtx, targetNss)) @@ -1008,8 +1003,8 @@ void _testRenameCollectionAcrossDatabaseOplogEntries( _insertDocument(opCtx, sourceNss, BSON("_id" << 0)); oplogEntries->clear(); if (forApplyOps) { - auto cmd = BSON( - "renameCollection" << sourceNss.ns() << "to" << targetNss.ns() << "dropTarget" << true); + auto cmd = BSON("renameCollection" << sourceNss.ns() << "to" << targetNss.ns() + << "dropTarget" << true); ASSERT_OK(renameCollectionForApplyOps(opCtx, sourceNss.db().toString(), {}, cmd, {})); } else { RenameCollectionOptions options; diff --git a/src/mongo/db/catalog/util/partitioned.h b/src/mongo/db/catalog/util/partitioned.h index cf3dd0f3625..c449932f653 100644 --- a/src/mongo/db/catalog/util/partitioned.h +++ b/src/mongo/db/catalog/util/partitioned.h @@ -237,7 +237,7 @@ public: KeyPartitioner()(partitioned_detail::getKey(value), nPartitions); this->_partitionedContainer->_partitions[partitionId].insert(std::move(value)); } - void insert(value_type)&& = delete; + void insert(value_type) && = delete; /** * Erases one entry from the partitioned structure, returns the number of entries removed. diff --git a/src/mongo/db/catalog/util/partitioned_test.cpp b/src/mongo/db/catalog/util/partitioned_test.cpp index 06de76bfc26..1cd235c95d6 100644 --- a/src/mongo/db/catalog/util/partitioned_test.cpp +++ b/src/mongo/db/catalog/util/partitioned_test.cpp @@ -237,7 +237,6 @@ TEST(PartitionedConcurrency, ShouldProtectConcurrentAccesses) { AtomicWord ready{0}; for (size_t threadId = 1; threadId <= numThreads; ++threadId) { auto workerThreadBody = [&, threadId, opsPerThread]() { - // Busy-wait until everybody is ready ready.fetchAndAdd(1); while (ready.load() < numThreads) { -- cgit v1.2.1