diff options
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", |