diff options
author | Benety Goh <benety@mongodb.com> | 2019-11-20 19:48:48 +0000 |
---|---|---|
committer | evergreen <evergreen@mongodb.com> | 2019-11-20 19:48:48 +0000 |
commit | 21366accd36bd4ec40907bfc732f2ce294330606 (patch) | |
tree | 80a2925f7047a19f52cc6dc03b3c5b0641181dfe /src/mongo/db | |
parent | 81be7a190276b1afda3c8242a70a6602c6d742c6 (diff) | |
download | mongo-21366accd36bd4ec40907bfc732f2ce294330606.tar.gz |
SERVER-43642 IndexBuildsCoordinator::createIndexes() accepts index constraints
make IndexBuildsCoordinator::updateCurOpOpDescription() public
Diffstat (limited to 'src/mongo/db')
-rw-r--r-- | src/mongo/db/index_builds_coordinator.cpp | 13 | ||||
-rw-r--r-- | src/mongo/db/index_builds_coordinator.h | 15 | ||||
-rw-r--r-- | src/mongo/db/system_index.cpp | 5 |
3 files changed, 18 insertions, 15 deletions
diff --git a/src/mongo/db/index_builds_coordinator.cpp b/src/mongo/db/index_builds_coordinator.cpp index 00e4628cb46..074ce083d53 100644 --- a/src/mongo/db/index_builds_coordinator.cpp +++ b/src/mongo/db/index_builds_coordinator.cpp @@ -691,6 +691,7 @@ void IndexBuildsCoordinator::onReplicaSetReconfig() { void IndexBuildsCoordinator::createIndexes(OperationContext* opCtx, UUID collectionUUID, const std::vector<BSONObj>& specs, + IndexBuildsManager::IndexConstraints indexConstraints, bool fromMigrate) { auto collection = CollectionCatalog::get(opCtx).lookupCollectionByUUID(collectionUUID); invariant(collection, @@ -710,7 +711,7 @@ void IndexBuildsCoordinator::createIndexes(OperationContext* opCtx, auto onInitFn = MultiIndexBlock::makeTimestampedIndexOnInitFn(opCtx, collection); IndexBuildsManager::SetupOptions options; - options.indexConstraints = IndexBuildsManager::IndexConstraints::kEnforce; + options.indexConstraints = indexConstraints; uassertStatusOK(_indexBuildsManager.setUpIndexBuild( opCtx, collection, specs, buildUUID, onInitFn, options)); @@ -801,10 +802,10 @@ void IndexBuildsCoordinator::verifyNoIndexBuilds_forTestOnly() { invariant(_collectionIndexBuilds.empty()); } -void IndexBuildsCoordinator::_updateCurOpOpDescription( - OperationContext* opCtx, - const NamespaceString& nss, - const std::vector<BSONObj>& indexSpecs) const { +// static +void IndexBuildsCoordinator::updateCurOpOpDescription(OperationContext* opCtx, + const NamespaceString& nss, + const std::vector<BSONObj>& indexSpecs) { BSONObjBuilder builder; // If the collection namespace is provided, add a 'createIndexes' field with the collection name @@ -1372,7 +1373,7 @@ void IndexBuildsCoordinator::_scanCollectionAndInsertKeysIntoSorter( invariant(opCtx->lockState()->isCollectionLockedForMode(*nss, MODE_X)); // Set up the thread's currentOp information to display createIndexes cmd information. - _updateCurOpOpDescription(opCtx, *nss, replState->indexSpecs); + updateCurOpOpDescription(opCtx, *nss, replState->indexSpecs); } // Rebuilding system indexes during startup using the IndexBuildsCoordinator is done by all diff --git a/src/mongo/db/index_builds_coordinator.h b/src/mongo/db/index_builds_coordinator.h index 9183a27795f..1f2b811d8a9 100644 --- a/src/mongo/db/index_builds_coordinator.h +++ b/src/mongo/db/index_builds_coordinator.h @@ -102,6 +102,13 @@ public: static IndexBuildsCoordinator* get(OperationContext* operationContext); /** + * Updates CurOp's 'opDescription' field with the current state of this index build. + */ + static void updateCurOpOpDescription(OperationContext* opCtx, + const NamespaceString& nss, + const std::vector<BSONObj>& indexSpecs); + + /** * Returns true if two phase index builds are supported. * This is determined by the current FCV and the server parameter 'enableTwoPhaseIndexBuild'. */ @@ -322,6 +329,7 @@ public: void createIndexes(OperationContext* opCtx, UUID collectionUUID, const std::vector<BSONObj>& specs, + IndexBuildsManager::IndexConstraints indexConstraints, bool fromMigrate); /** @@ -365,13 +373,6 @@ private: void _allowIndexBuildsOnCollection(const UUID& collectionUUID); /** - * Updates CurOp's 'opDescription' field with the current state of this index build. - */ - void _updateCurOpOpDescription(OperationContext* opCtx, - const NamespaceString& nss, - const std::vector<BSONObj>& indexSpecs) const; - - /** * Registers an index build so that the rest of the system can discover it. * * If stopIndexBuildsOnNsOrDb has been called on the index build's collection or database, then diff --git a/src/mongo/db/system_index.cpp b/src/mongo/db/system_index.cpp index a36391c5bc7..66e07743167 100644 --- a/src/mongo/db/system_index.cpp +++ b/src/mongo/db/system_index.cpp @@ -109,9 +109,10 @@ void generateSystemIndexForExistingCollection(OperationContext* opCtx, log() << "No authorization index detected on " << ns << " collection. Attempting to recover by creating an index with spec: " << indexSpec; - auto indexBuildsCoord = IndexBuildsCoordinator::get(opCtx); + auto indexConstraints = IndexBuildsManager::IndexConstraints::kEnforce; auto fromMigrate = false; - indexBuildsCoord->createIndexes(opCtx, collectionUUID, {indexSpec}, fromMigrate); + IndexBuildsCoordinator::get(opCtx)->createIndexes( + opCtx, collectionUUID, {indexSpec}, indexConstraints, fromMigrate); } catch (const DBException& e) { severe() << "Failed to regenerate index for " << ns << ". Exception: " << e.what(); throw; |