summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/mongo/db/auth/auth_index_d.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/mongo/db/auth/auth_index_d.cpp b/src/mongo/db/auth/auth_index_d.cpp
index 0284e561bc0..47987ac40c4 100644
--- a/src/mongo/db/auth/auth_index_d.cpp
+++ b/src/mongo/db/auth/auth_index_d.cpp
@@ -47,6 +47,7 @@
#include "mongo/db/db_raii.h"
#include "mongo/db/index/index_descriptor.h"
#include "mongo/db/jsobj.h"
+#include "mongo/db/storage/storage_options.h"
#include "mongo/util/assert_util.h"
#include "mongo/util/log.h"
@@ -97,6 +98,13 @@ void generateSystemIndexForExistingCollection(OperationContext* opCtx,
Collection* collection,
const NamespaceString& ns,
const IndexSpec& spec) {
+ // Do not try and generate any system indexes in read only mode.
+ if (storageGlobalParams.readOnly) {
+ warning() << "Running in queryable backup mode. Unable to create authorization index on "
+ << ns;
+ return;
+ }
+
try {
auto indexSpecStatus = index_key_validate::validateIndexSpec(
spec.toBSON(), ns, serverGlobalParams.featureCompatibility);