summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorBenety Goh <benety@mongodb.com>2018-10-01 15:17:48 -0400
committerBenety Goh <benety@mongodb.com>2018-10-01 15:17:48 -0400
commita70a8ce8cdc5734353acdd577956e58872169c64 (patch)
treeaa5dc4cc8d46db626630f4f183c645862411429a /src/mongo
parent15d15831540f2b59a889bdcb3fcf9725d6a23c96 (diff)
downloadmongo-a70a8ce8cdc5734353acdd577956e58872169c64.tar.gz
SERVER-37333 applyOps builds background indexes in the foreground
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/db/catalog/apply_ops.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/src/mongo/db/catalog/apply_ops.cpp b/src/mongo/db/catalog/apply_ops.cpp
index 770bc24b616..552376301cb 100644
--- a/src/mongo/db/catalog/apply_ops.cpp
+++ b/src/mongo/db/catalog/apply_ops.cpp
@@ -181,6 +181,15 @@ Status _applyOps(OperationContext* opCtx,
if (nss.isSystemDotIndexes()) {
invariant(opCtx->lockState()->isW());
+
+ // Disable background index builds when inserting into system.indexes.
+ // This causes the TempRelease to fail within applyOperation_inlock(),
+ // leading to the background index being built in the foreground.
+ // We do not want a background index build because we need to validate
+ // the index spec and also to avoid issues resulting from any metadata
+ // changes before the background thread starts.
+ Lock::GlobalWrite nestedGlobalWriteLock(opCtx->lockState());
+
OldClientContext ctx(opCtx, nss.ns());
status =
repl::applyOperation_inlock(opCtx, ctx.db(), opObj, alwaysUpsert);