summaryrefslogtreecommitdiff
path: root/src/mongo/db/service_entry_point_mongod.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/mongo/db/service_entry_point_mongod.cpp')
-rw-r--r--src/mongo/db/service_entry_point_mongod.cpp31
1 files changed, 14 insertions, 17 deletions
diff --git a/src/mongo/db/service_entry_point_mongod.cpp b/src/mongo/db/service_entry_point_mongod.cpp
index b50c8b95924..1281cc50106 100644
--- a/src/mongo/db/service_entry_point_mongod.cpp
+++ b/src/mongo/db/service_entry_point_mongod.cpp
@@ -289,22 +289,23 @@ void appendReplyMetadata(OperationContext* opCtx,
}
/**
- * Given the specified command and whether it supports read concern, returns an effective read
- * concern which should be used.
+ * Given the specified command, returns an effective read concern which should be used or an error
+ * if the read concern is not valid for the command.
*/
-StatusWith<repl::ReadConcernArgs> _extractReadConcern(const BSONObj& cmdObj,
- bool supportsNonLocalReadConcern) {
+StatusWith<repl::ReadConcernArgs> _extractReadConcern(const Command* command,
+ const std::string& dbName,
+ const BSONObj& cmdObj) {
repl::ReadConcernArgs readConcernArgs;
- auto readConcernParseStatus = readConcernArgs.initialize(cmdObj, Command::testCommandsEnabled);
+ auto readConcernParseStatus = readConcernArgs.initialize(cmdObj);
if (!readConcernParseStatus.isOK()) {
return readConcernParseStatus;
}
- if (!supportsNonLocalReadConcern &&
- readConcernArgs.getLevel() != repl::ReadConcernLevel::kLocalReadConcern) {
+ if (!command->supportsReadConcern(dbName, cmdObj, readConcernArgs.getLevel())) {
return {ErrorCodes::InvalidOptions,
- str::stream() << "Command does not support non local read concern"};
+ str::stream() << "Command does not support read concern "
+ << readConcernArgs.toString()};
}
return readConcernArgs;
@@ -476,10 +477,8 @@ bool runCommandImpl(OperationContext* opCtx,
// When a linearizable read command is passed in, check to make sure we're reading
// from the primary.
- if (command->supportsNonLocalReadConcern(db, cmd) &&
- (repl::ReadConcernArgs::get(opCtx).getLevel() ==
- repl::ReadConcernLevel::kLinearizableReadConcern) &&
- (request.getCommandName() != "getMore")) {
+ if (repl::ReadConcernArgs::get(opCtx).getLevel() ==
+ repl::ReadConcernLevel::kLinearizableReadConcern) {
auto linearizableReadStatus = waitForLinearizableReadConcern(opCtx);
@@ -677,8 +676,7 @@ void execCommandDatabase(OperationContext* opCtx,
}
auto& readConcernArgs = repl::ReadConcernArgs::get(opCtx);
- readConcernArgs = uassertStatusOK(_extractReadConcern(
- request.body, command->supportsNonLocalReadConcern(dbname, request.body)));
+ readConcernArgs = uassertStatusOK(_extractReadConcern(command, dbname, request.body));
auto& oss = OperationShardingState::get(opCtx);
@@ -687,7 +685,7 @@ void execCommandDatabase(OperationContext* opCtx,
(iAmPrimary ||
((serverGlobalParams.featureCompatibility.getVersion() ==
ServerGlobalParams::FeatureCompatibility::Version::kFullyUpgradedTo36) &&
- (readConcernArgs.hasLevel() || readConcernArgs.getArgsClusterTime())))) {
+ (readConcernArgs.hasLevel() || readConcernArgs.getArgsAfterClusterTime())))) {
oss.initializeShardVersion(NamespaceString(command->parseNs(dbname, request.body)),
shardVersionFieldIdx);
@@ -741,8 +739,7 @@ void execCommandDatabase(OperationContext* opCtx,
// Note: the read concern may not have been successfully or yet placed on the opCtx, so
// parsing it separately here.
const std::string db = request.getDatabase().toString();
- auto readConcernArgsStatus = _extractReadConcern(
- request.body, command->supportsNonLocalReadConcern(db, request.body));
+ auto readConcernArgsStatus = _extractReadConcern(command, db, request.body);
auto operationTime = readConcernArgsStatus.isOK()
? computeOperationTime(
opCtx, startOperationTime, readConcernArgsStatus.getValue().getLevel())