diff options
author | Suganthi Mani <suganthi.mani@mongodb.com> | 2020-03-25 11:24:28 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-04-09 20:30:23 +0000 |
commit | 4c41ed37fd58c4e4d4d2707f63f797f23ff9b486 (patch) | |
tree | 6955347bef25e936282e7581fd9b10586c8ca9f7 /src/mongo/db/cloner.cpp | |
parent | b69c1496a903bcdf8a99849e6420e6d6259e1770 (diff) | |
download | mongo-4c41ed37fd58c4e4d4d2707f63f797f23ff9b486.tar.gz |
SERVER-46557 Guarantees the commit quorum value gets persisted before start of the index build.
Diffstat (limited to 'src/mongo/db/cloner.cpp')
-rw-r--r-- | src/mongo/db/cloner.cpp | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/src/mongo/db/cloner.cpp b/src/mongo/db/cloner.cpp index b61227018fb..1a45051af97 100644 --- a/src/mongo/db/cloner.cpp +++ b/src/mongo/db/cloner.cpp @@ -43,6 +43,7 @@ #include "mongo/db/catalog/collection_options.h" #include "mongo/db/catalog/database.h" #include "mongo/db/catalog/database_holder.h" +#include "mongo/db/catalog/index_build_entry_gen.h" #include "mongo/db/catalog/index_catalog.h" #include "mongo/db/catalog/multi_index_block.h" #include "mongo/db/commands.h" @@ -52,6 +53,7 @@ #include "mongo/db/curop.h" #include "mongo/db/dbdirectclient.h" #include "mongo/db/index/index_descriptor.h" +#include "mongo/db/index_build_entry_helpers.h" #include "mongo/db/index_builds_coordinator.h" #include "mongo/db/jsobj.h" #include "mongo/db/namespace_string.h" @@ -405,15 +407,27 @@ void Cloner::copyIndexes(OperationContext* opCtx, MultiIndexBlock::OnInitFn onInitFn; if (opCtx->writesAreReplicated() && buildUUID) { onInitFn = [&](std::vector<BSONObj>& specs) { - // Since, we don't use IndexBuildsCoordinatorMongod thread pool to build indexes, - // it's ok to set the commit quorum option as 1. Also, this is currently only get - // called in rollback via refetch. So, onStartIndexBuild() call will be a no-op. + // TODO SERVER-47438: Should remove this onInitFn lambda function as we no longer + // need to generate startIndexBuild and commitIndexBuild oplog entries. + + // Currently, primary doesn't wait for any votes from secondaries to commit + // the index build. So, it's of no use to set the commit quorum option of any value + // greater than 0. Disabling commit quorum is just an optimization to avoid secondaries + // from trying to vote before committing index build. + // + // Persist the commit quorum value in the config.system.indexBuilds collection. + IndexBuildEntry indexbuildEntry(*buildUUID, + collection->uuid(), + CommitQuorumOptions(CommitQuorumOptions::kDisabled), + IndexBuildsCoordinator::extractIndexNames(specs)); + uassertStatusOK(indexbuildentryhelpers::addIndexBuildEntry(opCtx, indexbuildEntry)); + opObserver->onStartIndexBuild(opCtx, to_collection, collection->uuid(), *buildUUID, specs, - CommitQuorumOptions(1), + CommitQuorumOptions(CommitQuorumOptions::kDisabled), fromMigrate); return Status::OK(); }; |