summaryrefslogtreecommitdiff
path: root/src/mongo
diff options
context:
space:
mode:
authorJack Mulrow <jack.mulrow@mongodb.com>2018-04-09 12:49:21 -0400
committerJack Mulrow <jack.mulrow@mongodb.com>2018-04-09 15:46:07 -0400
commit2a61597c7c72e82790f35b51f31358ded60e40fd (patch)
tree3fd69f9908dcde98dfedb3836eca3fa977c701c1 /src/mongo
parent322f89e07af85e3f61d42fa97b09a89830054915 (diff)
downloadmongo-2a61597c7c72e82790f35b51f31358ded60e40fd.tar.gz
SERVER-34197 Only allow global snapshot reads when test commands are enabled
Diffstat (limited to 'src/mongo')
-rw-r--r--src/mongo/s/SConscript1
-rw-r--r--src/mongo/s/commands/strategy.cpp5
-rw-r--r--src/mongo/s/sharding_task_executor.cpp4
3 files changed, 9 insertions, 1 deletions
diff --git a/src/mongo/s/SConscript b/src/mongo/s/SConscript
index b815dc7b38e..5309e78a5ad 100644
--- a/src/mongo/s/SConscript
+++ b/src/mongo/s/SConscript
@@ -285,6 +285,7 @@ env.Library(
],
LIBDEPS=[
'$BUILD_DIR/mongo/base',
+ '$BUILD_DIR/mongo/db/commands/test_commands_enabled',
'$BUILD_DIR/mongo/executor/thread_pool_task_executor',
'$BUILD_DIR/mongo/s/client/sharding_client',
'cluster_last_error_info',
diff --git a/src/mongo/s/commands/strategy.cpp b/src/mongo/s/commands/strategy.cpp
index 769b4968c34..d8c4eff7db2 100644
--- a/src/mongo/s/commands/strategy.cpp
+++ b/src/mongo/s/commands/strategy.cpp
@@ -41,6 +41,7 @@
#include "mongo/db/auth/action_type.h"
#include "mongo/db/auth/authorization_session.h"
#include "mongo/db/commands.h"
+#include "mongo/db/commands/test_commands_enabled.h"
#include "mongo/db/curop.h"
#include "mongo/db/initialize_operation_session_info.h"
#include "mongo/db/lasterror.h"
@@ -217,6 +218,10 @@ void execCommandClient(OperationContext* opCtx,
auto& readConcernArgs = repl::ReadConcernArgs::get(opCtx);
if (readConcernArgs.getLevel() == repl::ReadConcernLevel::kSnapshotReadConcern) {
+ uassert(ErrorCodes::InvalidOptions,
+ "readConcern level snapshot is not supported on mongos",
+ getTestCommandsEnabled());
+
// TODO SERVER-33708.
if (!invocation->supportsReadConcern(readConcernArgs.getLevel())) {
auto body = result->getBodyBuilder();
diff --git a/src/mongo/s/sharding_task_executor.cpp b/src/mongo/s/sharding_task_executor.cpp
index 4e9e2df599b..aef915f4782 100644
--- a/src/mongo/s/sharding_task_executor.cpp
+++ b/src/mongo/s/sharding_task_executor.cpp
@@ -35,6 +35,7 @@
#include "mongo/base/disallow_copying.h"
#include "mongo/base/status_with.h"
#include "mongo/bson/timestamp.h"
+#include "mongo/db/commands/test_commands_enabled.h"
#include "mongo/db/logical_time.h"
#include "mongo/db/operation_time_tracker.h"
#include "mongo/executor/thread_pool_task_executor.h"
@@ -131,7 +132,8 @@ StatusWith<TaskExecutor::CallbackHandle> ShardingTaskExecutor::scheduleRemoteCom
}
// TODO SERVER-33991.
- if (request.opCtx->getTxnNumber() && request.cmdObj.hasField("getMore") &&
+ if (getTestCommandsEnabled() && request.opCtx->getTxnNumber() &&
+ request.cmdObj.hasField("getMore") &&
!request.cmdObj.hasField(OperationSessionInfo::kTxnNumberFieldName)) {
bob.append(OperationSessionInfo::kTxnNumberFieldName, *(request.opCtx->getTxnNumber()));
}