summaryrefslogtreecommitdiff
path: root/src/mongo/db/index_builds_coordinator.h
diff options
context:
space:
mode:
authorDianna Hohensee <dianna.hohensee@10gen.com>2019-02-05 10:38:51 -0500
committerDianna Hohensee <dianna.hohensee@10gen.com>2019-02-11 22:33:22 -0500
commit8e76d8c9040aa15f3acbf56bda7e91cce3d37b5a (patch)
treed3995a21f0dff6ac59398e51740db470fd9038cc /src/mongo/db/index_builds_coordinator.h
parentd8cef1c71c1e9d8c59e354e08db121046af68c21 (diff)
downloadmongo-8e76d8c9040aa15f3acbf56bda7e91cce3d37b5a.tar.gz
SERVER-39368 refactor IndexBuildsCoordinator::_runIndexBuild to facilitate future changes and code re-use
Diffstat (limited to 'src/mongo/db/index_builds_coordinator.h')
-rw-r--r--src/mongo/db/index_builds_coordinator.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/mongo/db/index_builds_coordinator.h b/src/mongo/db/index_builds_coordinator.h
index ec8eee35344..933aabbbfd6 100644
--- a/src/mongo/db/index_builds_coordinator.h
+++ b/src/mongo/db/index_builds_coordinator.h
@@ -38,6 +38,7 @@
#include "mongo/db/catalog/commit_quorum_options.h"
#include "mongo/db/catalog/index_builds_manager.h"
#include "mongo/db/collection_index_builds_tracker.h"
+#include "mongo/db/concurrency/d_concurrency.h"
#include "mongo/db/database_index_builds_tracker.h"
#include "mongo/db/namespace_string.h"
#include "mongo/db/repl_index_build_state.h"
@@ -312,6 +313,39 @@ protected:
*/
virtual void _runIndexBuild(OperationContext* opCtx, const UUID& buildUUID) noexcept;
+ /**
+ * Modularizes the _indexBuildsManager calls part of _runIndexBuild. Throws on error.
+ */
+ void _buildIndex(OperationContext* opCtx,
+ Collection* collection,
+ const NamespaceString& nss,
+ std::shared_ptr<ReplIndexBuildState> replState,
+ const std::vector<BSONObj>& filteredSpecs,
+ Lock::DBLock* dbLock);
+ /**
+ * Returns total number of indexes in collection, including unfinished/in-progress indexes.
+ *
+ * Helper function that is used in sub-classes. Used to set statistics on index build results.
+ *
+ * Expects a lock to be held by the caller, so that 'collection' is safe to use.
+ */
+ int _getNumIndexesTotal(OperationContext* opCtx, Collection* collection);
+
+ /**
+ * Adds collation defaults to 'indexSpecs', as well as filtering out existing indexes (ready or
+ * building) and checking uniqueness constraints are compatible with sharding.
+ *
+ * Helper function that is used in sub-classes. Produces final specs that the Coordinator will
+ * register and use for the build, if the result is non-empty.
+ *
+ * This function throws on error. Expects a DB X lock to be held by the caller.
+ */
+ std::vector<BSONObj> _addDefaultsAndFilterExistingIndexes(
+ OperationContext* opCtx,
+ Collection* collection,
+ const NamespaceString& nss,
+ const std::vector<BSONObj>& indexSpecs);
+
// Protects the below state.
mutable stdx::mutex _mutex;