summaryrefslogtreecommitdiff
path: root/src/mongo/db/commands
diff options
context:
space:
mode:
authorKyle Suarez <kyle.suarez@mongodb.com>2022-03-08 16:41:48 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-03-08 17:17:29 +0000
commit4a29d0ad3193889a8ae6cce5dffa7c2b955f77ff (patch)
tree4a02c8c9c2bf0b478fda1ae6408b36743e174404 /src/mongo/db/commands
parent5d9d22ec27309637f1496ce9f8e10500dd3b2997 (diff)
downloadmongo-4a29d0ad3193889a8ae6cce5dffa7c2b955f77ff.tar.gz
SERVER-61333 ban snapshot read distinct cmd of sharded coll on mongod, not mongos
Diffstat (limited to 'src/mongo/db/commands')
-rw-r--r--src/mongo/db/commands/distinct.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/mongo/db/commands/distinct.cpp b/src/mongo/db/commands/distinct.cpp
index 03da360d83f..57585a88401 100644
--- a/src/mongo/db/commands/distinct.cpp
+++ b/src/mongo/db/commands/distinct.cpp
@@ -208,6 +208,14 @@ public:
"Please see http://dochub.mongodb.org/core/transaction-distinct for a recommended "
"alternative.",
!opCtx->inMultiDocumentTransaction() || !ctx->getCollection().isSharded());
+
+ // Similarly, we ban readConcern level snapshot for sharded collections.
+ uassert(
+ ErrorCodes::InvalidOptions,
+ "Cannot run 'distinct' on a sharded collection with readConcern level 'snapshot'",
+ repl::ReadConcernArgs::get(opCtx).getLevel() !=
+ repl::ReadConcernLevel::kSnapshotReadConcern ||
+ !ctx->getCollection().isSharded());
}
const ExtensionsCallbackReal extensionsCallback(opCtx, &nss);