summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlberto Massari <alberto.massari@mongodb.com>2022-09-13 08:43:13 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-09-13 09:35:57 +0000
commitc70bc17083cc73c2b2d32b4fc693fe22c58a863d (patch)
treec04df9e948c2f1f3b4ce9691a56a9095c14672a4
parent5a6d6a46b809a2a35099b18e1ee693e70a67f28d (diff)
downloadmongo-c70bc17083cc73c2b2d32b4fc693fe22c58a863d.tar.gz
SERVER-63851 Derive ExecutionContext flags from OperationContext
-rw-r--r--src/mongo/db/commands/find_cmd.cpp4
-rw-r--r--src/mongo/db/commands/map_reduce_agg.cpp4
-rw-r--r--src/mongo/db/commands/run_aggregate.cpp9
-rw-r--r--src/mongo/db/pipeline/expression_context.cpp9
-rw-r--r--src/mongo/db/pipeline/expression_context.h3
5 files changed, 10 insertions, 19 deletions
diff --git a/src/mongo/db/commands/find_cmd.cpp b/src/mongo/db/commands/find_cmd.cpp
index bf40647a9cf..ba45ad6b615 100644
--- a/src/mongo/db/commands/find_cmd.cpp
+++ b/src/mongo/db/commands/find_cmd.cpp
@@ -142,10 +142,6 @@ boost::intrusive_ptr<ExpressionContext> makeExpressionContext(
findCommand.getLet(), // let
CurOp::get(opCtx)->dbProfileLevel() > 0 // mayDbProfile
);
- if (opCtx->readOnly()) {
- // Disallow disk use if in read-only mode.
- expCtx->allowDiskUse = false;
- }
expCtx->tempDir = storageGlobalParams.dbpath + "/_tmp";
expCtx->startExpressionCounters();
diff --git a/src/mongo/db/commands/map_reduce_agg.cpp b/src/mongo/db/commands/map_reduce_agg.cpp
index 073e655dcb3..1f31ec3c78f 100644
--- a/src/mongo/db/commands/map_reduce_agg.cpp
+++ b/src/mongo/db/commands/map_reduce_agg.cpp
@@ -107,10 +107,6 @@ auto makeExpressionContext(OperationContext* opCtx,
boost::none, // let
CurOp::get(opCtx)->dbProfileLevel() > 0 // mayDbProfile
);
- if (opCtx->readOnly()) {
- // Disallow disk use if in read-only mode.
- expCtx->allowDiskUse = false;
- }
expCtx->tempDir = storageGlobalParams.dbpath + "/_tmp";
return expCtx;
}
diff --git a/src/mongo/db/commands/run_aggregate.cpp b/src/mongo/db/commands/run_aggregate.cpp
index e61f799620c..4fe8a736ad7 100644
--- a/src/mongo/db/commands/run_aggregate.cpp
+++ b/src/mongo/db/commands/run_aggregate.cpp
@@ -443,15 +443,10 @@ boost::intrusive_ptr<ExpressionContext> makeExpressionContext(
MongoProcessInterface::create(opCtx),
uassertStatusOK(resolveInvolvedNamespaces(opCtx, request)),
uuid,
- CurOp::get(opCtx)->dbProfileLevel() > 0);
+ CurOp::get(opCtx)->dbProfileLevel() > 0,
+ allowDiskUseByDefault.load());
expCtx->tempDir = storageGlobalParams.dbpath + "/_tmp";
expCtx->collationMatchesDefault = collationMatchesDefault;
- expCtx->forPerShardCursor = request.getPassthroughToShard().has_value();
- expCtx->allowDiskUse = request.getAllowDiskUse().value_or(allowDiskUseByDefault.load());
- if (opCtx->readOnly()) {
- // Disallow disk use if in read-only mode.
- expCtx->allowDiskUse = false;
- }
// If the request explicitly specified NOT to use v2 resume tokens for change streams, set this
// on the expCtx. This can happen if a the request originated from 6.0 mongos, or in test mode.
diff --git a/src/mongo/db/pipeline/expression_context.cpp b/src/mongo/db/pipeline/expression_context.cpp
index b3b433a8c45..9d36a21b888 100644
--- a/src/mongo/db/pipeline/expression_context.cpp
+++ b/src/mongo/db/pipeline/expression_context.cpp
@@ -49,12 +49,13 @@ ExpressionContext::ExpressionContext(OperationContext* opCtx,
std::shared_ptr<MongoProcessInterface> processInterface,
StringMap<ResolvedNamespace> resolvedNamespaces,
boost::optional<UUID> collUUID,
- bool mayDbProfile)
+ bool mayDbProfile,
+ bool allowDiskUseByDefault)
: ExpressionContext(opCtx,
request.getExplain(),
request.getFromMongos(),
request.getNeedsMerge(),
- request.getAllowDiskUse(),
+ request.getAllowDiskUse().value_or(allowDiskUseByDefault),
request.getBypassDocumentValidation().value_or(false),
request.getIsMapReduceCommand(),
request.getNamespace(),
@@ -71,6 +72,7 @@ ExpressionContext::ExpressionContext(OperationContext* opCtx,
// 'jsHeapLimitMB' limit.
jsHeapLimitMB = boost::none;
}
+ forPerShardCursor = request.getPassthroughToShard().has_value();
}
ExpressionContext::ExpressionContext(
@@ -92,7 +94,8 @@ ExpressionContext::ExpressionContext(
: explain(explain),
fromMongos(fromMongos),
needsMerge(needsMerge),
- allowDiskUse(allowDiskUse),
+ allowDiskUse(allowDiskUse &&
+ !(opCtx && opCtx->readOnly())), // Disallow disk use if in read-only mode.
bypassDocumentValidation(bypassDocumentValidation),
ns(ns),
uuid(std::move(collUUID)),
diff --git a/src/mongo/db/pipeline/expression_context.h b/src/mongo/db/pipeline/expression_context.h
index 0d2d87fd361..8629311709a 100644
--- a/src/mongo/db/pipeline/expression_context.h
+++ b/src/mongo/db/pipeline/expression_context.h
@@ -123,7 +123,8 @@ public:
std::shared_ptr<MongoProcessInterface> mongoProcessInterface,
StringMap<ExpressionContext::ResolvedNamespace> resolvedNamespaces,
boost::optional<UUID> collUUID,
- bool mayDbProfile = true);
+ bool mayDbProfile = true,
+ bool allowDiskUseByDefault = false);
/**
* Constructs an ExpressionContext to be used for Pipeline parsing and evaluation. This version