summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFaustoleyva54 <fausto.leyva@mongodb.com>2022-07-11 16:04:47 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-07-11 16:30:36 +0000
commited8fb871a38e4cb682e2e499922ef17d079eefc2 (patch)
tree4e237b6d7867b1dcfd6e4581981bf462eacc05a0
parent9b9d2338477361c04cf44ac7a098bd0cdee4bbd4 (diff)
downloadmongo-ed8fb871a38e4cb682e2e499922ef17d079eefc2.tar.gz
SERVER-66621 Add additional check for two phase index build support
-rw-r--r--src/mongo/db/index_builds_coordinator.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/mongo/db/index_builds_coordinator.cpp b/src/mongo/db/index_builds_coordinator.cpp
index c37a7c2c7a1..da506575b13 100644
--- a/src/mongo/db/index_builds_coordinator.cpp
+++ b/src/mongo/db/index_builds_coordinator.cpp
@@ -1757,6 +1757,16 @@ IndexBuildsCoordinator::_filterSpecsAndRegisterBuild(OperationContext* opCtx,
return SharedSemiFuture(indexCatalogStats);
}
+ // Ensure we can support two phase index builds when the two phase IndexBuildProtocol is
+ // specified. 'protocol' is evaluated outside of a global lock in an earlier call so there is a
+ // potential race when downgrading to a FCV version which invalidates the protocol (i.e.,
+ // downgrading from a version >= 4.4 to a version <= 4.2).
+ uassert(ErrorCodes::CannotCreateIndex,
+ "Two phase index build protocol was specified but we only support single phase index "
+ "builds.",
+ protocol != IndexBuildProtocol::kTwoPhase ||
+ IndexBuildsCoordinator::supportsTwoPhaseIndexBuild());
+
// Bypass the thread pool if we are building indexes on an empty collection.
if (shouldBuildIndexesOnEmptyCollectionSinglePhased(opCtx, collection, protocol)) {
ReplIndexBuildState::IndexCatalogStats indexCatalogStats;