summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTess Avitabile <tess.avitabile@mongodb.com>2018-06-11 17:48:36 -0400
committerTess Avitabile <tess.avitabile@mongodb.com>2018-06-14 10:26:16 -0400
commit7fb0ba7016a7af44532f49088bcf698ac3815860 (patch)
treea8b48a3bc20c5745b3088a07e455eaf84e842e7b
parent33ea303e386cef960015143e1ff396102b2bc5ac (diff)
downloadmongo-7fb0ba7016a7af44532f49088bcf698ac3815860.tar.gz
SERVER-35513 Forbid transactions on inMemory storage engine
(cherry picked from commit 0b103f9904fe7dfc88d8a1077cf01c30cdd330d0)
-rw-r--r--buildscripts/resmokelib/testing/hooks/dbhash_background.py4
-rw-r--r--etc/evergreen.yml8
-rw-r--r--jstests/noPassthrough/afterClusterTime_committed_reads.js11
-rw-r--r--jstests/noPassthrough/readConcern_atClusterTime_snapshot_selection.js7
-rw-r--r--jstests/noPassthrough/readConcern_snapshot.js13
-rw-r--r--jstests/noPassthrough/read_concern_snapshot_aggregation.js6
-rw-r--r--jstests/noPassthrough/read_concern_snapshot_catalog_invalidation.js6
-rw-r--r--jstests/noPassthrough/read_concern_snapshot_yielding.js7
-rw-r--r--jstests/noPassthrough/read_majority.js4
-rw-r--r--jstests/noPassthrough/snapshot_cursor_integrity.js6
-rw-r--r--jstests/noPassthrough/snapshot_cursor_shutdown_stepdown.js6
-rw-r--r--jstests/noPassthrough/snapshot_reads.js6
-rw-r--r--jstests/replsets/dbhash_at_cluster_time.js6
-rw-r--r--jstests/replsets/dbhash_lock_acquisition.js6
-rw-r--r--jstests/sharding/aggregation_currentop.js11
-rw-r--r--src/mongo/db/initialize_operation_session_info.cpp7
-rw-r--r--src/mongo/db/initialize_operation_session_info.h6
-rw-r--r--src/mongo/db/logical_session_id_test.cpp28
-rw-r--r--src/mongo/db/s/session_catalog_migration_destination_test.cpp3
-rw-r--r--src/mongo/db/service_entry_point_common.cpp3
-rw-r--r--src/mongo/s/commands/strategy.cpp2
21 files changed, 75 insertions, 81 deletions
diff --git a/buildscripts/resmokelib/testing/hooks/dbhash_background.py b/buildscripts/resmokelib/testing/hooks/dbhash_background.py
index 10d49ee8e3f..b8122f458b8 100644
--- a/buildscripts/resmokelib/testing/hooks/dbhash_background.py
+++ b/buildscripts/resmokelib/testing/hooks/dbhash_background.py
@@ -36,6 +36,10 @@ class CheckReplDBHashInBackground(jsfile.JSHook):
" doesn't support snapshot reads.",
server_status["storageEngine"]["name"])
return
+ if not server_status["storageEngine"].get("persistent", False):
+ self.logger.info("Not enabling the background thread because '%s' storage engine"
+ " is not persistent.", server_status["storageEngine"]["name"])
+ return
self._background_job = _BackgroundJob()
self.logger.info("Starting the background thread.")
diff --git a/etc/evergreen.yml b/etc/evergreen.yml
index eabe895eada..b96656a7d67 100644
--- a/etc/evergreen.yml
+++ b/etc/evergreen.yml
@@ -8725,7 +8725,7 @@ buildvariants:
num_scons_link_jobs_available: $(( $(grep -c ^processor /proc/cpuinfo) / 4 ))
python: python
num_jobs_available: $(grep -c ^processor /proc/cpuinfo)
- test_flags: --storageEngine=inMemory --excludeWithAnyTags=requires_persistence,requires_journaling,requires_mmapv1
+ test_flags: --storageEngine=inMemory --excludeWithAnyTags=requires_persistence,requires_journaling,requires_mmapv1,uses_transactions
ext: zip
use_scons_cache: true
multiversion_platform: windows
@@ -11621,7 +11621,7 @@ buildvariants:
batchtime: 1440 # 1 day
expansions:
rlp_environment: MONGOD_UNITTEST_RLP_LANGUAGE_TEST_BTROOT=/opt/basis
- test_flags: --storageEngine=inMemory --excludeWithAnyTags=requires_persistence,requires_journaling,requires_mmapv1
+ test_flags: --storageEngine=inMemory --excludeWithAnyTags=requires_persistence,requires_journaling,requires_mmapv1,uses_transactions
compile_flags: --ssl MONGO_DISTMOD=rhel62 -j$(grep -c ^processor /proc/cpuinfo) --variables-files=etc/scons/mongodbtoolchain_gcc.vars CPPPATH="/opt/basis/rlp/rlp/include /opt/basis/rlp/utilities/include" --use-basis-tech-rosette-linguistics-platform=on
multiversion_platform: rhel62
multiversion_edition: enterprise
@@ -12031,7 +12031,7 @@ buildvariants:
# We need to compensate for SMT8 setting the cpu count very high and lower the amount of parallelism down
compile_flags: --dbg=on --opt=on --ssl MONGO_DISTMOD=rhel71 -j$(echo "$(grep -c processor /proc/cpuinfo)/2" | bc) CCFLAGS="-mcpu=power8 -mtune=power8 -mcmodel=medium" --variables-files=etc/scons/mongodbtoolchain_gcc.vars
num_jobs_available: $(echo "$(grep -c processor /proc/cpuinfo)/4" | bc)
- test_flags: --storageEngine=inMemory --excludeWithAnyTags=requires_persistence,requires_mmapv1,requires_journaling
+ test_flags: --storageEngine=inMemory --excludeWithAnyTags=requires_persistence,requires_mmapv1,requires_journaling,uses_transactions
gorootvars: 'PATH="/opt/go1.8/go/bin:/opt/mongodbtoolchain/v2/bin/:$PATH" GOROOT=/opt/go1.8/go CC=/opt/mongodbtoolchain/v2/bin/ppc64le-mongodb-linux-gcc'
tooltags: -tags 'sasl ssl'
build_mongoreplay: true
@@ -12112,7 +12112,7 @@ buildvariants:
expansions:
compile_flags: --dbg=on --opt=on --ssl MONGO_DISTMOD=rhel72 -j3 CCFLAGS="-march=z196 -mtune=zEC12" --variables-files=etc/scons/mongodbtoolchain_gcc.vars
num_jobs_available: 2
- test_flags: --storageEngine=inMemory --excludeWithAnyTags=requires_persistence,requires_mmapv1,requires_journaling
+ test_flags: --storageEngine=inMemory --excludeWithAnyTags=requires_persistence,requires_mmapv1,requires_journaling,uses_transactions
gorootvars: 'PATH="/opt/go1.8/go/bin:/opt/mongodbtoolchain/v2/bin/:$PATH" GOROOT=/opt/go1.8/go CC=/opt/mongodbtoolchain/v2/bin/s390x-mongodb-linux-gcc'
tooltags: -tags 'sasl ssl'
build_mongoreplay: true
diff --git a/jstests/noPassthrough/afterClusterTime_committed_reads.js b/jstests/noPassthrough/afterClusterTime_committed_reads.js
index 96091cf34f0..0f9bc1480c7 100644
--- a/jstests/noPassthrough/afterClusterTime_committed_reads.js
+++ b/jstests/noPassthrough/afterClusterTime_committed_reads.js
@@ -1,6 +1,6 @@
// Test that causally consistent majority-committed read-only transactions will wait for the
// majority commit point to move past 'afterClusterTime' before they can commit.
-// @tags: [requires_replication]
+// @tags: [uses_transactions]
(function() {
"use strict";
@@ -67,13 +67,8 @@
}));
}
- if (assert.commandWorked(primaryDB.serverStatus()).storageEngine.supportsCommittedReads) {
- testReadConcernLevel("majority");
- }
-
- if (assert.commandWorked(primaryDB.serverStatus()).storageEngine.supportsSnapshotReadConcern) {
- testReadConcernLevel("snapshot");
- }
+ testReadConcernLevel("majority");
+ testReadConcernLevel("snapshot");
rst.stopSet();
}());
diff --git a/jstests/noPassthrough/readConcern_atClusterTime_snapshot_selection.js b/jstests/noPassthrough/readConcern_atClusterTime_snapshot_selection.js
index d42e0e90b31..91a754a595a 100644
--- a/jstests/noPassthrough/readConcern_atClusterTime_snapshot_selection.js
+++ b/jstests/noPassthrough/readConcern_atClusterTime_snapshot_selection.js
@@ -2,7 +2,7 @@
// to be majority committed. If 'atClusterTime' is older than the oldest available snapshot, the
// error code SnapshotTooOld is returned.
//
-// @tags: [requires_replication]
+// @tags: [uses_transactions]
(function() {
"use strict";
@@ -19,11 +19,6 @@
rst.getPrimary().getDB(dbName).getMongo().startSession({causalConsistency: false});
const primaryDB = primarySession.getDatabase(dbName);
- if (!assert.commandWorked(primaryDB.serverStatus()).storageEngine.supportsSnapshotReadConcern) {
- rst.stopSet();
- return;
- }
-
const secondaryConns = rst.getSecondaries();
const secondaryConn0 = secondaryConns[0];
const secondaryConn1 = secondaryConns[1];
diff --git a/jstests/noPassthrough/readConcern_snapshot.js b/jstests/noPassthrough/readConcern_snapshot.js
index 20e0aaa2bd9..8926d6fd72a 100644
--- a/jstests/noPassthrough/readConcern_snapshot.js
+++ b/jstests/noPassthrough/readConcern_snapshot.js
@@ -10,18 +10,27 @@
// Configurations.
//
- // readConcern 'snapshot' should fail on storage engines that do not support it.
+ // Transactions should fail on storage engines that do not support them.
let rst = new ReplSetTest({nodes: 1});
rst.startSet();
rst.initiate();
let session =
rst.getPrimary().getDB(dbName).getMongo().startSession({causalConsistency: false});
let sessionDb = session.getDatabase(dbName);
- if (!sessionDb.serverStatus().storageEngine.supportsSnapshotReadConcern) {
+ if (!sessionDb.serverStatus().storageEngine.supportsSnapshotReadConcern ||
+ !sessionDb.serverStatus().storageEngine.persistent) {
+ // Transactions with readConcern snapshot fail.
session.startTransaction({readConcern: {level: "snapshot"}});
assert.commandFailedWithCode(sessionDb.runCommand({find: collName}),
ErrorCodes.IllegalOperation);
session.abortTransaction();
+
+ // Transactions without readConcern snapshot fail.
+ session.startTransaction();
+ assert.commandFailedWithCode(sessionDb.runCommand({find: collName}),
+ ErrorCodes.IllegalOperation);
+ session.abortTransaction();
+
rst.stopSet();
return;
}
diff --git a/jstests/noPassthrough/read_concern_snapshot_aggregation.js b/jstests/noPassthrough/read_concern_snapshot_aggregation.js
index d55598de40e..482af9a4688 100644
--- a/jstests/noPassthrough/read_concern_snapshot_aggregation.js
+++ b/jstests/noPassthrough/read_concern_snapshot_aggregation.js
@@ -1,7 +1,7 @@
/**
* Tests for the aggregate command's support for readConcern level "snapshot".
*
- * @tags: [requires_replication]
+ * @tags: [uses_transactions]
*/
(function() {
"use strict";
@@ -19,10 +19,6 @@
let session =
rst.getPrimary().getDB(kDBName).getMongo().startSession({causalConsistency: false});
let sessionDB = session.getDatabase(kDBName);
- if (!sessionDB.serverStatus().storageEngine.supportsSnapshotReadConcern) {
- rst.stopSet();
- return;
- }
let txnNumber = NumberLong(0);
assert.commandWorked(sessionDB.runCommand({create: kCollName, writeConcern: {w: "majority"}}));
diff --git a/jstests/noPassthrough/read_concern_snapshot_catalog_invalidation.js b/jstests/noPassthrough/read_concern_snapshot_catalog_invalidation.js
index 759217356ab..942e1cc54d8 100644
--- a/jstests/noPassthrough/read_concern_snapshot_catalog_invalidation.js
+++ b/jstests/noPassthrough/read_concern_snapshot_catalog_invalidation.js
@@ -1,6 +1,6 @@
// Tests that snapshot reads return an error when accessing a collection whose metadata is invalid
// for the snapshot's point in time.
-// @tags: [requires_replication]
+// @tags: [uses_transactions]
(function() {
"use strict";
@@ -12,10 +12,6 @@
rst.initiate();
const testDB = rst.getPrimary().getDB(kDbName);
- if (!testDB.serverStatus().storageEngine.supportsSnapshotReadConcern) {
- rst.stopSet();
- return;
- }
const adminDB = testDB.getSiblingDB("admin");
const coll = testDB.getCollection(kCollName);
diff --git a/jstests/noPassthrough/read_concern_snapshot_yielding.js b/jstests/noPassthrough/read_concern_snapshot_yielding.js
index c7f8cf3ffbe..3792b3bb655 100644
--- a/jstests/noPassthrough/read_concern_snapshot_yielding.js
+++ b/jstests/noPassthrough/read_concern_snapshot_yielding.js
@@ -1,7 +1,7 @@
// Test that the read concern level 'snapshot' exhibits the correct yielding behavior. That is,
// operations performed at read concern level snapshot check for interrupt but do not yield locks or
// storage engine resources.
-// @tags: [requires_replication]
+// @tags: [uses_transactions]
(function() {
"use strict";
@@ -24,11 +24,6 @@
const coll = db.coll;
TestData.numDocs = 4;
- if (!db.serverStatus().storageEngine.supportsSnapshotReadConcern) {
- rst.stopSet();
- return;
- }
-
// Set 'internalQueryExecYieldIterations' to 2 to ensure that commands yield on the second try
// (i.e. after they have established a snapshot but before they have returned any documents).
assert.commandWorked(db.adminCommand({setParameter: 1, internalQueryExecYieldIterations: 2}));
diff --git a/jstests/noPassthrough/read_majority.js b/jstests/noPassthrough/read_majority.js
index 2310e4ccfeb..a8e1b9f4221 100644
--- a/jstests/noPassthrough/read_majority.js
+++ b/jstests/noPassthrough/read_majority.js
@@ -10,8 +10,6 @@
* - 'local'-only commands should error on majority-committed levels, and accept 'local' level.
* - An aggregation with '$out' should fail with majority-committed levels.
*
- * Tests are run for both majority-committed read concern levels: "majority" and "snapshot".
- *
* All of this requires support for committed reads, so this test will be skipped if the storage
* engine does not support them.
*/
@@ -231,8 +229,6 @@ load("jstests/libs/analyze_plan.js");
const db = conn.getDB("test");
const supportsCommittedReads =
assert.commandWorked(db.serverStatus()).storageEngine.supportsCommittedReads;
- const supportsSnapshotReadConcern =
- assert.commandWorked(db.serverStatus()).storageEngine.supportsSnapshotReadConcern;
MongoRunner.stopMongod(conn);
if (supportsCommittedReads) {
diff --git a/jstests/noPassthrough/snapshot_cursor_integrity.js b/jstests/noPassthrough/snapshot_cursor_integrity.js
index d5d0678a641..859dd713ad5 100644
--- a/jstests/noPassthrough/snapshot_cursor_integrity.js
+++ b/jstests/noPassthrough/snapshot_cursor_integrity.js
@@ -1,6 +1,6 @@
// Tests that a cursor is iterated in a transaction/session iff it was created in that
// transaction/session. Specifically tests this in the context of snapshot cursors.
-// @tags: [requires_replication]
+// @tags: [uses_transactions]
(function() {
"use strict";
@@ -12,10 +12,6 @@
rst.initiate();
const primaryDB = rst.getPrimary().getDB(dbName);
- if (!primaryDB.serverStatus().storageEngine.supportsSnapshotReadConcern) {
- rst.stopSet();
- return;
- }
const session1 = primaryDB.getMongo().startSession();
const sessionDB1 = session1.getDatabase(dbName);
diff --git a/jstests/noPassthrough/snapshot_cursor_shutdown_stepdown.js b/jstests/noPassthrough/snapshot_cursor_shutdown_stepdown.js
index 8d60e290d7d..ec2cbfd5254 100644
--- a/jstests/noPassthrough/snapshot_cursor_shutdown_stepdown.js
+++ b/jstests/noPassthrough/snapshot_cursor_shutdown_stepdown.js
@@ -1,5 +1,5 @@
// Tests that stashed transaction resources are destroyed at shutdown and stepdown.
-// @tags: [requires_replication]
+// @tags: [uses_transactions]
(function() {
"use strict";
@@ -15,10 +15,6 @@
rst.initiate();
let primaryDB = rst.getPrimary().getDB(dbName);
- if (!primaryDB.serverStatus().storageEngine.supportsSnapshotReadConcern) {
- rst.stopSet();
- return;
- }
let session = primaryDB.getMongo().startSession();
let sessionDB = session.getDatabase(dbName);
diff --git a/jstests/noPassthrough/snapshot_reads.js b/jstests/noPassthrough/snapshot_reads.js
index 3c2555ab4b5..91e0fce616d 100644
--- a/jstests/noPassthrough/snapshot_reads.js
+++ b/jstests/noPassthrough/snapshot_reads.js
@@ -1,5 +1,5 @@
// Tests snapshot isolation on readConcern level snapshot read.
-// @tags: [requires_replication]
+// @tags: [uses_transactions]
(function() {
"use strict";
@@ -14,10 +14,6 @@
rst.initiate(conf);
const primaryDB = rst.getPrimary().getDB(dbName);
- if (!primaryDB.serverStatus().storageEngine.supportsSnapshotReadConcern) {
- rst.stopSet();
- return;
- }
function parseCursor(cmdResult) {
if (cmdResult.hasOwnProperty("cursor")) {
diff --git a/jstests/replsets/dbhash_at_cluster_time.js b/jstests/replsets/dbhash_at_cluster_time.js
index 3a77217fdd9..d2a77899003 100644
--- a/jstests/replsets/dbhash_at_cluster_time.js
+++ b/jstests/replsets/dbhash_at_cluster_time.js
@@ -1,5 +1,6 @@
/**
* Tests that "atClusterTime" is supported by the "dbHash" command.
+ * @tags: [uses_transactions]
*/
(function() {
"use strict";
@@ -18,11 +19,6 @@
const db = session.getDatabase("test");
let txnNumber = 0;
- if (!db.serverStatus().storageEngine.supportsSnapshotReadConcern) {
- rst.stopSet();
- return;
- }
-
// We force 'secondary' to sync from 'primary' using the "forceSyncSourceCandidate" failpoint to
// ensure that an intermittent connectivity issue doesn't lead to the secondary not advancing
// its belief of the majority commit point. This avoids any complications that would arise due
diff --git a/jstests/replsets/dbhash_lock_acquisition.js b/jstests/replsets/dbhash_lock_acquisition.js
index e8b7ff9cbad..8c14e159e24 100644
--- a/jstests/replsets/dbhash_lock_acquisition.js
+++ b/jstests/replsets/dbhash_lock_acquisition.js
@@ -1,6 +1,7 @@
/**
* Tests that the dbHash command acquires IX mode locks on the global, database, and collection
* resources when running inside a multi-statement transaction.
+ * @tags: [uses_transactions]
*/
(function() {
"use strict";
@@ -12,11 +13,6 @@
const primary = rst.getPrimary();
const db = primary.getDB("test");
- if (!db.serverStatus().storageEngine.supportsSnapshotReadConcern) {
- rst.stopSet();
- return;
- }
-
const session = primary.startSession({causalConsistency: false});
const sessionDB = session.getDatabase(db.getName());
diff --git a/jstests/sharding/aggregation_currentop.js b/jstests/sharding/aggregation_currentop.js
index d58daaa1aa2..9ae97ef6949 100644
--- a/jstests/sharding/aggregation_currentop.js
+++ b/jstests/sharding/aggregation_currentop.js
@@ -13,7 +13,7 @@
* applicable.
*
* This test requires replica set configuration and user credentials to persist across a restart.
- * @tags: [requires_persistence]
+ * @tags: [requires_persistence, uses_transactions]
*/
// Restarts cause issues with authentication for awaiting replication.
@@ -90,15 +90,6 @@ TestData.skipAwaitingReplicationOnShardsBeforeCheckingUUIDs = true;
createUsers(shardConn);
createUsers(mongosConn);
- // Gate this test to transaction supporting engines only as it uses txnNumber.
- assert(shardAdminDB.auth("admin", "pwd"));
- if (!shardAdminDB.serverStatus().storageEngine.supportsSnapshotReadConcern) {
- jsTestLog("Do not run on storage engine that does not support transactions");
- st.stop();
- return;
- }
- shardAdminDB.logout();
-
// Create a test database and some dummy data on rs0.
assert(clusterAdminDB.auth("admin", "pwd"));
diff --git a/src/mongo/db/initialize_operation_session_info.cpp b/src/mongo/db/initialize_operation_session_info.cpp
index d94cfdb78bc..137fba1196c 100644
--- a/src/mongo/db/initialize_operation_session_info.cpp
+++ b/src/mongo/db/initialize_operation_session_info.cpp
@@ -42,7 +42,8 @@ boost::optional<OperationSessionInfoFromClient> initializeOperationSessionInfo(
const BSONObj& requestBody,
bool requiresAuth,
bool isReplSetMemberOrMongos,
- bool supportsDocLocking) {
+ bool supportsDocLocking,
+ bool supportsRecoverToStableTimestamp) {
if (!requiresAuth) {
return boost::none;
@@ -106,6 +107,10 @@ boost::optional<OperationSessionInfoFromClient> initializeOperationSessionInfo(
uassert(ErrorCodes::InvalidOptions,
"Specifying autocommit=true is not allowed.",
!osi.getAutocommit().value());
+ uassert(ErrorCodes::IllegalOperation,
+ "Multi-document transactions are only allowed on storage engines that support "
+ "recover to stable timestamp.",
+ supportsRecoverToStableTimestamp);
} else {
uassert(ErrorCodes::InvalidOptions,
"'startTransaction' field requires 'autocommit' field to also be specified",
diff --git a/src/mongo/db/initialize_operation_session_info.h b/src/mongo/db/initialize_operation_session_info.h
index 8882c4e7052..e67bf7531e4 100644
--- a/src/mongo/db/initialize_operation_session_info.h
+++ b/src/mongo/db/initialize_operation_session_info.h
@@ -46,6 +46,9 @@ namespace mongo {
* Both isReplSetMemberOrMongos and supportsDocLocking need to be true if the command contains a
* transaction number, otherwise this function will throw.
*
+ * supportsRecoverToStableTimestamp needs to be true if the command contains autocommit:false,
+ * otherwise this function will throw.
+ *
* On success, returns the parsed request information. Returning boost::none implies that the
* proper command or session requirements were not met.
*/
@@ -54,6 +57,7 @@ boost::optional<OperationSessionInfoFromClient> initializeOperationSessionInfo(
const BSONObj& requestBody,
bool requiresAuth,
bool isReplSetMemberOrMongos,
- bool supportsDocLocking);
+ bool supportsDocLocking,
+ bool supportsRecoverToStableTimestamp);
} // namespace mongo
diff --git a/src/mongo/db/logical_session_id_test.cpp b/src/mongo/db/logical_session_id_test.cpp
index bc5befe3a96..e80ab1f38b3 100644
--- a/src/mongo/db/logical_session_id_test.cpp
+++ b/src/mongo/db/logical_session_id_test.cpp
@@ -248,7 +248,7 @@ TEST_F(LogicalSessionIdTest, GenWithoutAuthedUser) {
TEST_F(LogicalSessionIdTest, InitializeOperationSessionInfo_NoSessionIdNoTransactionNumber) {
addSimpleUser(UserName("simple", "test"));
- initializeOperationSessionInfo(_opCtx.get(), BSON("TestCmd" << 1), true, true, true);
+ initializeOperationSessionInfo(_opCtx.get(), BSON("TestCmd" << 1), true, true, true, true);
ASSERT(!_opCtx->getLogicalSessionId());
ASSERT(!_opCtx->getTxnNumber());
@@ -264,6 +264,7 @@ TEST_F(LogicalSessionIdTest, InitializeOperationSessionInfo_SessionIdNoTransacti
<< "TestField"),
true,
true,
+ true,
true);
ASSERT(_opCtx->getLogicalSessionId());
@@ -280,6 +281,7 @@ TEST_F(LogicalSessionIdTest, InitializeOperationSessionInfo_MissingSessionIdWith
<< "TestField"),
true,
true,
+ true,
true),
AssertionException,
ErrorCodes::InvalidOptions);
@@ -296,6 +298,7 @@ TEST_F(LogicalSessionIdTest, InitializeOperationSessionInfo_SessionIdAndTransact
<< "TestField"),
true,
true,
+ true,
true);
ASSERT(_opCtx->getLogicalSessionId());
@@ -317,6 +320,7 @@ TEST_F(LogicalSessionIdTest, InitializeOperationSessionInfo_IsReplSetMemberOrMon
<< "TestField"),
true,
false,
+ true,
true),
AssertionException,
ErrorCodes::IllegalOperation);
@@ -334,6 +338,27 @@ TEST_F(LogicalSessionIdTest, InitializeOperationSessionInfo_SupportsDocLockingFa
<< "TestField"),
true,
true,
+ false,
+ true),
+ AssertionException,
+ ErrorCodes::IllegalOperation);
+}
+
+TEST_F(LogicalSessionIdTest, InitializeOperationSessionInfo_SupportsRecoverToStableTimestampFalse) {
+ addSimpleUser(UserName("simple", "test"));
+ LogicalSessionFromClient lsid;
+ lsid.setId(UUID::gen());
+
+ ASSERT_THROWS_CODE(
+ initializeOperationSessionInfo(
+ _opCtx.get(),
+ BSON("TestCmd" << 1 << "lsid" << lsid.toBSON() << "txnNumber" << 100LL << "OtherField"
+ << "TestField"
+ << "autocommit"
+ << false),
+ true,
+ true,
+ true,
false),
AssertionException,
ErrorCodes::IllegalOperation);
@@ -352,6 +377,7 @@ TEST_F(LogicalSessionIdTest, InitializeOperationSessionInfo_IgnoresInfoIfNoCache
<< "TestField"),
true,
true,
+ true,
true));
}
diff --git a/src/mongo/db/s/session_catalog_migration_destination_test.cpp b/src/mongo/db/s/session_catalog_migration_destination_test.cpp
index 010ae23f768..5d8fa25978d 100644
--- a/src/mongo/db/s/session_catalog_migration_destination_test.cpp
+++ b/src/mongo/db/s/session_catalog_migration_destination_test.cpp
@@ -241,7 +241,8 @@ public:
// The ephemeral for test storage engine doesn't support document-level locking, so
// requests with txnNumbers aren't allowed. To get around this, we have to manually set
// up the session state and perform the insert.
- initializeOperationSessionInfo(innerOpCtx.get(), insertBuilder.obj(), true, true, true);
+ initializeOperationSessionInfo(
+ innerOpCtx.get(), insertBuilder.obj(), true, true, true, false);
OperationContextSession sessionTxnState(
innerOpCtx.get(), true, boost::none, boost::none, "testDB", "insert");
diff --git a/src/mongo/db/service_entry_point_common.cpp b/src/mongo/db/service_entry_point_common.cpp
index 275e1050114..9176d9f82b6 100644
--- a/src/mongo/db/service_entry_point_common.cpp
+++ b/src/mongo/db/service_entry_point_common.cpp
@@ -638,7 +638,8 @@ void execCommandDatabase(OperationContext* opCtx,
request.body,
command->requiresAuth(),
replCoord->getReplicationMode() == repl::ReplicationCoordinator::modeReplSet,
- opCtx->getServiceContext()->getStorageEngine()->supportsDocLocking());
+ opCtx->getServiceContext()->getStorageEngine()->supportsDocLocking(),
+ opCtx->getServiceContext()->getStorageEngine()->supportsRecoverToStableTimestamp());
evaluateFailCommandFailPoint(opCtx, command->getName());
diff --git a/src/mongo/s/commands/strategy.cpp b/src/mongo/s/commands/strategy.cpp
index cfa58924d3f..3c3c98f4013 100644
--- a/src/mongo/s/commands/strategy.cpp
+++ b/src/mongo/s/commands/strategy.cpp
@@ -335,7 +335,7 @@ void runCommand(OperationContext* opCtx,
// Fill out all currentOp details.
CurOp::get(opCtx)->setGenericOpRequestDetails(opCtx, nss, command, request.body, opType);
- initializeOperationSessionInfo(opCtx, request.body, command->requiresAuth(), true, true);
+ initializeOperationSessionInfo(opCtx, request.body, command->requiresAuth(), true, true, true);
auto& readConcernArgs = repl::ReadConcernArgs::get(opCtx);
auto readConcernParseStatus = readConcernArgs.initialize(request.body);