{"record":{"id":"7c7d48797dbe9963","repo":"mongodb/mongoid","slug":"transactions-are-not-supported-by-the-connected-se","errorCode":null,"errorMessage":"Transactions are not supported by the connected server(s).","messagePattern":"Transactions are not supported by the connected server\\(s\\)\\.","errorType":"exception","errorClass":"Mongoid::Errors::TransactionsNotSupported","httpStatus":null,"severity":"error","filePath":"lib/mongoid/clients/sessions.rb","lineNumber":87,"sourceCode":"        # @param [ Hash ] options The transaction options. Please see the driver\n        #   documentation for the available session options.\n        # @param [ Hash ] session_options The session options. A MongoDB\n        #   transaction must be started inside a session, therefore a session will\n        #   be started. Please see the driver documentation for the available session options.\n        #\n        # @raise [ Mongoid::Errors::InvalidTransactionNesting ] If the transaction is\n        #   opened on a client that already has an open transaction.\n        # @raise [ Mongoid::Errors::TransactionsNotSupported ] If MongoDB deployment\n        #   the client is connected to does not support transactions.\n        # @raise [ Mongoid::Errors::TransactionError ] If there is an error raised\n        #   by MongoDB deployment or MongoDB driver.\n        #\n        # @yield Provided block will be executed inside a transaction.\n        def transaction(options = {}, session_options: {}, &block)\n          with_session(session_options) do |session|\n            session.with_transaction(options, &block).tap { run_commit_callbacks(session) }\n          rescue *transactions_not_supported_exceptions\n            raise Mongoid::Errors::TransactionsNotSupported\n          rescue Mongoid::Errors::Rollback\n            run_abort_callbacks(session)\n          rescue Mongoid::Errors::InvalidSessionNesting\n            # Session should be ended here.\n            raise Mongoid::Errors::InvalidTransactionNesting.new\n          rescue Mongo::Error::InvalidSession, Mongo::Error::InvalidTransactionOperation => e\n            run_abort_callbacks(session)\n            raise Mongoid::Errors::TransactionError.new(e)\n          rescue StandardError => e\n            run_abort_callbacks(session)\n            raise e\n          end\n        end\n\n        # Sets up a callback is called after a commit of a transaction.\n        # The callback is called only if the document is created, updated, or destroyed\n        # in the transaction.\n        #","sourceCodeStart":69,"sourceCodeEnd":105,"githubUrl":"https://github.com/mongodb/mongoid/blob/0da0e23d71adfbad31128c18e5e2c8c301c6f7c4/lib/mongoid/clients/sessions.rb#L69-L105","documentation":"Error \"Transactions are not supported by the connected server(s).\" thrown in mongodb/mongoid.","triggerScenarios":"Thrown at lib/mongoid/clients/sessions.rb:87 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0da0e23d71adfbad31128c18e5e2c8c301c6f7c4","analyzedAt":"2026-08-23T06:25:47.656Z","schemaVersion":2},"datasetVersion":"2026-08-23T08:06:27.607Z"}