summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2019-09-11 22:02:22 +0000
committerevergreen <evergreen@mongodb.com>2019-09-11 22:02:22 +0000
commitf27f82560f129f6ccd9b16fba887949ab197e678 (patch)
tree07d9130a60090068f58c6a717c2756859870c5b4 /src
parent1e4ecf48af15b8ee75f53601e7783e02171af982 (diff)
downloadmongo-f27f82560f129f6ccd9b16fba887949ab197e678.tar.gz
SERVER-43259 add IndexBuildsCoordinator::supportsTwoPhaseIndexBuild()
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/index_builds_coordinator.cpp18
-rw-r--r--src/mongo/db/index_builds_coordinator.h6
2 files changed, 24 insertions, 0 deletions
diff --git a/src/mongo/db/index_builds_coordinator.cpp b/src/mongo/db/index_builds_coordinator.cpp
index 3a0999821cc..f0afc33c0d8 100644
--- a/src/mongo/db/index_builds_coordinator.cpp
+++ b/src/mongo/db/index_builds_coordinator.cpp
@@ -42,6 +42,7 @@
#include "mongo/db/concurrency/write_conflict_exception.h"
#include "mongo/db/curop.h"
#include "mongo/db/db_raii.h"
+#include "mongo/db/enable_two_phase_index_build_gen.h"
#include "mongo/db/index_build_entry_helpers.h"
#include "mongo/db/op_observer.h"
#include "mongo/db/operation_context.h"
@@ -152,6 +153,23 @@ IndexBuildsCoordinator::~IndexBuildsCoordinator() {
invariant(_collectionIndexBuilds.empty());
}
+bool IndexBuildsCoordinator::supportsTwoPhaseIndexBuild() const {
+ if (!enableTwoPhaseIndexBuild) {
+ return false;
+ }
+
+ if (!serverGlobalParams.featureCompatibility.isVersionInitialized()) {
+ return false;
+ }
+
+ if (serverGlobalParams.featureCompatibility.getVersion() !=
+ ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo44) {
+ return false;
+ }
+
+ return true;
+}
+
StatusWith<std::pair<long long, long long>> IndexBuildsCoordinator::startIndexRebuildForRecovery(
OperationContext* opCtx,
const NamespaceString& nss,
diff --git a/src/mongo/db/index_builds_coordinator.h b/src/mongo/db/index_builds_coordinator.h
index ff2f75fd288..7ab40ef1e85 100644
--- a/src/mongo/db/index_builds_coordinator.h
+++ b/src/mongo/db/index_builds_coordinator.h
@@ -101,6 +101,12 @@ public:
static IndexBuildsCoordinator* get(OperationContext* operationContext);
/**
+ * Returns true if two phase index builds are supported.
+ * This is determined by the current FCV and the server parameter 'enableTwoPhaseIndexBuild'.
+ */
+ bool supportsTwoPhaseIndexBuild() const;
+
+ /**
* Sets up the in-memory and persisted state of the index build. A Future is returned upon which
* the user can await the build result.
*