summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--jstests/noPassthrough/readConcern_atClusterTime.js9
-rw-r--r--jstests/noPassthrough/readConcern_snapshot_mongos_enable_test_commands.js50
-rw-r--r--src/mongo/db/service_entry_point_common.cpp6
-rw-r--r--src/mongo/s/commands/cluster_command_test_fixture.cpp3
-rw-r--r--src/mongo/s/commands/strategy.cpp4
-rw-r--r--src/mongo/s/query/cluster_find_test.cpp3
6 files changed, 16 insertions, 59 deletions
diff --git a/jstests/noPassthrough/readConcern_atClusterTime.js b/jstests/noPassthrough/readConcern_atClusterTime.js
index a90a71feac9..b2e5b6ac9f8 100644
--- a/jstests/noPassthrough/readConcern_atClusterTime.js
+++ b/jstests/noPassthrough/readConcern_atClusterTime.js
@@ -118,8 +118,7 @@ function _getClusterTime(rst) {
session.endSession();
rst.stopSet();
- // readConcern with 'atClusterTime' should fail when 'enableTestCommands' is set to false.
- // TODO: SERVER-35643 Allow atClusterTime when enableTestCommands is false.
+ // readConcern with 'atClusterTime' should succeed regardless of value of 'enableTestCommands'.
{
jsTest.setOption('enableTestCommands', false);
let rst = new ReplSetTest({nodes: 1});
@@ -130,10 +129,8 @@ function _getClusterTime(rst) {
let sessionDb = session.getDatabase(dbName);
session.startTransaction(
{readConcern: {level: "snapshot", atClusterTime: _getClusterTime(rst)}});
- assert.commandFailedWithCode(sessionDb.runCommand({find: collName}),
- ErrorCodes.InvalidOptions);
- assert.commandFailedWithCode(session.abortTransaction_forTesting(),
- ErrorCodes.NoSuchTransaction);
+ assert.commandWorked(sessionDb.runCommand({find: collName}));
+ session.commitTransaction();
session.endSession();
rst.stopSet();
diff --git a/jstests/noPassthrough/readConcern_snapshot_mongos_enable_test_commands.js b/jstests/noPassthrough/readConcern_snapshot_mongos_enable_test_commands.js
index 5e546ce6669..e92126186fb 100644
--- a/jstests/noPassthrough/readConcern_snapshot_mongos_enable_test_commands.js
+++ b/jstests/noPassthrough/readConcern_snapshot_mongos_enable_test_commands.js
@@ -1,4 +1,4 @@
-// Verifies that snapshot readConcern on mongos is gated by the enableTestCommands flag.
+// Verifies that snapshot readConcern on mongos is not gated by the enableTestCommands flag.
//
// @tags: [requires_sharding]
(function() {
@@ -7,42 +7,9 @@
const dbName = "test";
const collName = "coll";
- // Snapshot readConcern should fail when 'enableTestCommands' is set to false.
- {
- jsTest.setOption("enableTestCommands", false);
-
- const st = new ShardingTest({shards: 1, config: 1});
- const session = st.s.startSession({causalConsistency: false});
- let txnNumber = 0;
-
- assert.commandFailedWithCode(session.getDatabase(dbName).runCommand({
- find: collName,
- readConcern: {level: "snapshot"},
- txnNumber: NumberLong(txnNumber++),
- startTransaction: true,
- autocommit: false
- }),
- ErrorCodes.InvalidOptions);
-
- assert.commandFailedWithCode(session.getDatabase(dbName).runCommand({
- aggregate: collName,
- pipeline: [],
- cursor: {},
- readConcern: {level: "snapshot"},
- txnNumber: NumberLong(txnNumber++),
- startTransaction: true,
- autocommit: false
- }),
- ErrorCodes.InvalidOptions);
-
- session.endSession();
- st.stop();
- }
-
- // Snapshot readConcern should succeed when 'enableTestCommands' is set to true.
- {
- jsTest.setOption("enableTestCommands", true);
-
+ // Runs multiple commands with read concern level "snapshot" in a session,
+ // expecting success.
+ function expectSnapshotReadConcernIsSupported() {
const st = new ShardingTest({shards: 1, config: 1});
const session = st.s.startSession({causalConsistency: false});
let txnNumber = 0;
@@ -68,4 +35,13 @@
session.endSession();
st.stop();
}
+
+ // Snapshot readConcern should succeed when 'enableTestCommands' is set to false.
+ jsTest.setOption("enableTestCommands", false);
+ expectSnapshotReadConcernIsSupported();
+
+ // Snapshot readConcern should succeed when 'enableTestCommands' is set to true.
+ jsTest.setOption("enableTestCommands", true);
+ expectSnapshotReadConcernIsSupported();
+
}());
diff --git a/src/mongo/db/service_entry_point_common.cpp b/src/mongo/db/service_entry_point_common.cpp
index 517d9c934d6..c068978aeea 100644
--- a/src/mongo/db/service_entry_point_common.cpp
+++ b/src/mongo/db/service_entry_point_common.cpp
@@ -804,12 +804,6 @@ void execCommandDatabase(OperationContext* opCtx,
_extractReadConcern(invocation.get(), request.body, upconvertToSnapshot));
}
- if (readConcernArgs.getArgsAtClusterTime()) {
- uassert(ErrorCodes::InvalidOptions,
- "atClusterTime is only used for testing",
- getTestCommandsEnabled());
- }
-
if (readConcernArgs.getLevel() == repl::ReadConcernLevel::kSnapshotReadConcern) {
uassert(ErrorCodes::InvalidOptions,
"readConcern level snapshot is only valid in multi-statement transactions",
diff --git a/src/mongo/s/commands/cluster_command_test_fixture.cpp b/src/mongo/s/commands/cluster_command_test_fixture.cpp
index d11c78d6fa4..2d3bec52e9c 100644
--- a/src/mongo/s/commands/cluster_command_test_fixture.cpp
+++ b/src/mongo/s/commands/cluster_command_test_fixture.cpp
@@ -62,9 +62,6 @@ void ClusterCommandTestFixture::setUp() {
LogicalTimeValidator::set(getServiceContext(), std::move(validator));
LogicalSessionCache::set(getServiceContext(), stdx::make_unique<LogicalSessionCacheNoop>());
-
- // ReadConcern 'snapshot' is only supported with test commands enabled.
- setTestCommandsEnabled(true);
}
void ClusterCommandTestFixture::expectReturnsError(ErrorCodes::Error code) {
diff --git a/src/mongo/s/commands/strategy.cpp b/src/mongo/s/commands/strategy.cpp
index bd0fa78ac30..fd2d3d7a840 100644
--- a/src/mongo/s/commands/strategy.cpp
+++ b/src/mongo/s/commands/strategy.cpp
@@ -222,10 +222,6 @@ 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/query/cluster_find_test.cpp b/src/mongo/s/query/cluster_find_test.cpp
index f667b6f9f48..327527d1a42 100644
--- a/src/mongo/s/query/cluster_find_test.cpp
+++ b/src/mongo/s/query/cluster_find_test.cpp
@@ -95,9 +95,6 @@ protected:
LogicalTimeValidator::set(getServiceContext(), std::move(validator));
LogicalSessionCache::set(getServiceContext(), stdx::make_unique<LogicalSessionCacheNoop>());
-
- // ReadConcern 'snapshot' is only supported with test commands enabled.
- setTestCommandsEnabled(true);
}
// The index of the shard expected to receive the response is used to prevent different shards