{"record":{"id":"0891845e30135c3f","repo":"mongodb/mongoid","slug":"transactions-not-supported","errorCode":null,"errorMessage":"transactions_not_supported","messagePattern":"transactions_not_supported","errorType":"exception","errorClass":"Mongoid::Errors::TransactionsNotSupported","httpStatus":null,"severity":"error","filePath":"lib/mongoid/clients/sessions.rb","lineNumber":51,"sourceCode":"        #   client from which the session was started or if sessions are nested.\n        #\n        # @return [ Object ] The result of calling the block.\n        #\n        # @yieldparam [ Mongo::Session ] The session being used for the block.\n        def with_session(options = {})\n          raise Mongoid::Errors::InvalidSessionNesting.new if Threaded.get_session(client: persistence_context.client)\n\n          session = persistence_context.client.start_session(options)\n          Threaded.set_session(session, client: persistence_context.client)\n          yield(session)\n        rescue Mongo::Error::InvalidSession => e\n          raise Mongoid::Errors::SessionsNotSupported.new if e.is_a?(Mongo::Error::SessionsNotSupported)\n\n          raise e\n        rescue Mongo::Error::OperationFailure => e\n          if (e.code == 40_415 && e.server_message =~ /startTransaction/) ||\n             (e.code == 20 && e.server_message =~ /Transaction/)\n            raise Mongoid::Errors::TransactionsNotSupported.new\n          else\n            raise e\n          end\n        rescue *transactions_not_supported_exceptions\n          raise Mongoid::Errors::TransactionsNotSupported\n        ensure\n          Threaded.clear_modified_documents(session)\n          Threaded.clear_session(client: persistence_context.client)\n        end\n\n        # Executes a block within the context of a transaction.\n        #\n        # If the block does not raise an error, the transaction is committed.\n        # If an error is raised, the transaction is aborted. The error is passed on\n        # except for the `Mongoid::Errors::Rollback`. This error is not passed on,\n        # so you can raise is if you want to deliberately rollback the transaction.\n        #\n        # @param [ Hash ] options The transaction options. Please see the driver","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/mongodb/mongoid/blob/0da0e23d71adfbad31128c18e5e2c8c301c6f7c4/lib/mongoid/clients/sessions.rb#L33-L69","documentation":"Error \"transactions_not_supported\" thrown in mongodb/mongoid.","triggerScenarios":"Thrown at lib/mongoid/clients/sessions.rb:51 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"}