summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2019-10-21 16:59:14 +0000
committerevergreen <evergreen@mongodb.com>2019-10-21 16:59:14 +0000
commitd97cca2c6d5be0324da0dc4d56ca269714af8f34 (patch)
treec151a2d14ab7fdd450bb7483df5ce08c9ce5f9a4
parent95584cd484eb94e8a3266e23f6594338ed878b88 (diff)
downloadmongo-d97cca2c6d5be0324da0dc4d56ca269714af8f34.tar.gz
SERVER-44122 createIndexes should pass IndexBuildProtocol::kTwoPhase to IndexBuildsCoordinator if supported
-rw-r--r--src/mongo/db/commands/create_indexes.cpp17
1 files changed, 7 insertions, 10 deletions
diff --git a/src/mongo/db/commands/create_indexes.cpp b/src/mongo/db/commands/create_indexes.cpp
index 4d2bd0c1cd6..5d827ea27b0 100644
--- a/src/mongo/db/commands/create_indexes.cpp
+++ b/src/mongo/db/commands/create_indexes.cpp
@@ -405,8 +405,7 @@ bool runCreateIndexesForMobile(OperationContext* opCtx,
const std::string& dbname,
const BSONObj& cmdObj,
std::string& errmsg,
- BSONObjBuilder& result,
- bool runTwoPhaseBuild) {
+ BSONObjBuilder& result) {
NamespaceString ns(CommandHelpers::parseNsCollectionRequired(dbname, cmdObj));
uassertStatusOK(userAllowedWriteNS(ns));
@@ -642,8 +641,7 @@ bool runCreateIndexesWithCoordinator(OperationContext* opCtx,
const std::string& dbname,
const BSONObj& cmdObj,
std::string& errmsg,
- BSONObjBuilder& result,
- bool runTwoPhaseBuild) {
+ BSONObjBuilder& result) {
const NamespaceString ns(CommandHelpers::parseNsCollectionRequired(dbname, cmdObj));
uassertStatusOK(userAllowedWriteNS(ns));
@@ -698,8 +696,9 @@ bool runCreateIndexesWithCoordinator(OperationContext* opCtx,
auto indexBuildsCoord = IndexBuildsCoordinator::get(opCtx);
auto buildUUID = UUID::gen();
- auto protocol =
- (runTwoPhaseBuild) ? IndexBuildProtocol::kTwoPhase : IndexBuildProtocol::kSinglePhase;
+ auto protocol = indexBuildsCoord->supportsTwoPhaseIndexBuild()
+ ? IndexBuildProtocol::kTwoPhase
+ : IndexBuildProtocol::kSinglePhase;
log() << "Registering index build: " << buildUUID;
ReplIndexBuildState::IndexCatalogStats stats;
IndexBuildsCoordinator::IndexBuildOptions indexBuildOptions = {commitQuorum};
@@ -829,11 +828,9 @@ public:
// TODO(SERVER-42513): Remove runCreateIndexesForMobile() when the mobile storage
// engine is supported by runCreateIndexesWithCoordinator().
if (storageGlobalParams.engine == "mobile") {
- return runCreateIndexesForMobile(
- opCtx, dbname, cmdObj, errmsg, result, false /*two phase build*/);
+ return runCreateIndexesForMobile(opCtx, dbname, cmdObj, errmsg, result);
}
- return runCreateIndexesWithCoordinator(
- opCtx, dbname, cmdObj, errmsg, result, false /*two phase build*/);
+ return runCreateIndexesWithCoordinator(opCtx, dbname, cmdObj, errmsg, result);
} catch (const DBException& ex) {
if (ex.toStatus() != ErrorCodes::IndexBuildAlreadyInProgress) {
throw;