diff options
author | William Schultz <william.schultz@mongodb.com> | 2018-07-23 12:20:11 -0400 |
---|---|---|
committer | William Schultz <william.schultz@mongodb.com> | 2018-07-23 12:20:11 -0400 |
commit | 826d21952137b50e6376cea627995d24a9eb54a9 (patch) | |
tree | b3decb90d9cfa30078293b7021c83c9122749785 /src/mongo/db/initialize_operation_session_info.cpp | |
parent | a73722cc85bd1027898be8af651e1312d68a680b (diff) | |
download | mongo-826d21952137b50e6376cea627995d24a9eb54a9.tar.gz |
SERVER-35695 Add server parameter to enable transactions on inMemory
storage engine
Diffstat (limited to 'src/mongo/db/initialize_operation_session_info.cpp')
-rw-r--r-- | src/mongo/db/initialize_operation_session_info.cpp | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/src/mongo/db/initialize_operation_session_info.cpp b/src/mongo/db/initialize_operation_session_info.cpp index 965dc0f1e53..446170d63f2 100644 --- a/src/mongo/db/initialize_operation_session_info.cpp +++ b/src/mongo/db/initialize_operation_session_info.cpp @@ -34,9 +34,16 @@ #include "mongo/db/logical_session_cache.h" #include "mongo/db/logical_session_id_helpers.h" #include "mongo/db/operation_context.h" +#include "mongo/db/server_parameters.h" namespace mongo { +// Allows multi-document transactions to run with the 'inMemory' storage engine. This flag should +// ONLY be used for testing purposes. Production systems should not run transactions on the +// 'inMemory' storage engines until "rollback to a timestamp" is supported on the 'inMemory' storage +// engine (see SERVER-34165). +MONGO_EXPORT_SERVER_PARAMETER(enableInMemoryTransactions, bool, false); + boost::optional<OperationSessionInfoFromClient> initializeOperationSessionInfo( OperationContext* opCtx, const BSONObj& requestBody, @@ -107,10 +114,18 @@ boost::optional<OperationSessionInfoFromClient> initializeOperationSessionInfo( uassert(ErrorCodes::InvalidOptions, "Specifying autocommit=true is not allowed.", !osi.getAutocommit().value()); + + // We allow transactions to run on in-memory storage engines for testing purposes. + bool allowInMemoryTransactions = false; + auto storageEngine = opCtx->getServiceContext()->getStorageEngine(); + if (storageEngine) { + allowInMemoryTransactions = + storageEngine->isEphemeral() && enableInMemoryTransactions.load(); + } uassert(ErrorCodes::IllegalOperation, "Multi-document transactions are only allowed on storage engines that support " "recover to stable timestamp.", - supportsRecoverToStableTimestamp); + supportsRecoverToStableTimestamp || allowInMemoryTransactions); } else { uassert(ErrorCodes::InvalidOptions, "'startTransaction' field requires 'autocommit' field to also be specified", |