summaryrefslogtreecommitdiff
path: root/src/mongo/db/startup_recovery.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/startup_recovery.cpp')
-rw-r--r--src/mongo/db/startup_recovery.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/mongo/db/startup_recovery.cpp b/src/mongo/db/startup_recovery.cpp
index ca1b6fb94e0..d5874eae6b4 100644
--- a/src/mongo/db/startup_recovery.cpp
+++ b/src/mongo/db/startup_recovery.cpp
@@ -42,7 +42,7 @@
#include "mongo/db/commands/feature_compatibility_version_document_gen.h"
#include "mongo/db/commands/feature_compatibility_version_documentation.h"
#include "mongo/db/commands/feature_compatibility_version_parser.h"
-#include "mongo/db/concurrency/write_conflict_exception.h"
+#include "mongo/db/concurrency/exception_util.h"
#include "mongo/db/db_raii.h"
#include "mongo/db/dbhelpers.h"
#include "mongo/db/index_builds_coordinator.h"
@@ -54,6 +54,7 @@
#include "mongo/db/repl_set_member_in_standalone_mode.h"
#include "mongo/db/server_options.h"
#include "mongo/db/storage/storage_repair_observer.h"
+#include "mongo/db/timeseries/timeseries_extended_range.h"
#include "mongo/logv2/log.h"
#include "mongo/util/exit.h"
#include "mongo/util/fail_point.h"
@@ -161,6 +162,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);
@@ -246,6 +251,11 @@ Status ensureCollectionProperties(OperationContext* opCtx,
return downgradeError;
}
}
+
+ if (coll->getTimeseriesOptions() &&
+ timeseries::collectionMayRequireExtendedRangeSupport(opCtx, coll)) {
+ coll->setRequiresTimeseriesExtendedRangeSupport(opCtx);
+ }
}
return Status::OK();
}