summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFaustoleyva54 <fausto.leyva@mongodb.com>2022-09-28 14:44:52 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-09-30 18:43:15 +0000
commit564b1554dce09835efc08a6b7add93590aaaf2b7 (patch)
treed1e07e3db25433c73037189a56a5f77545935a65
parentc8980c27cc9f6bb9cf9836daf503981c48afb235 (diff)
downloadmongo-564b1554dce09835efc08a6b7add93590aaaf2b7.tar.gz
SERVER-68394 Ensure we do not yield strong locks upon startup recovery when _id index is missing
-rw-r--r--src/mongo/db/startup_recovery.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/mongo/db/startup_recovery.cpp b/src/mongo/db/startup_recovery.cpp
index f9ab1c1052d..85510a5c8c0 100644
--- a/src/mongo/db/startup_recovery.cpp
+++ b/src/mongo/db/startup_recovery.cpp
@@ -156,6 +156,10 @@ bool checkIdIndexExists(OperationContext* opCtx, const CollectionPtr& coll) {
Status buildMissingIdIndex(OperationContext* opCtx, Collection* collection) {
LOGV2(4805002, "Building missing _id index", logAttrs(*collection));
MultiIndexBlock indexer;
+ // This method is called in startup recovery so we can safely build the id index in foreground
+ // mode. This prevents us from yielding a MODE_X lock (which is disallowed).
+ indexer.setIndexBuildMethod(IndexBuildMethod::kForeground);
+
ScopeGuard abortOnExit([&] {
CollectionWriter collWriter(collection);
indexer.abortIndexBuild(opCtx, collWriter, MultiIndexBlock::kNoopOnCleanUpFn);