{"record":{"id":"61fb63679d6aeb97","repo":"mongodb/mongoid","slug":"transactions-are-not-supported-by-the-connected-se-61fb63","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/railties/console_sandbox.rb","lineNumber":18,"sourceCode":"require 'mongoid/threaded'\nrequire 'mongoid/errors/transactions_not_supported'\n\n# This method raises an error if the cluster the client is connected to\n# does not support transactions in any case. At the moment this is the case\n# of the standalone topology.\n#\n# Please note that if this method did not raise, it does not guarantee that\n# transactions are available for the cluster.\n#\n# @param [ Mongo::Client ] client Client connected to a cluster to be tested.\n#\n# @raise [ Mongoid::Errors::TransactionsNotSupported ] If the cluster\n#   definitely does not support transactions.\ndef check_if_transactions_might_be_available!(client)\n  return unless client.cluster.single?\n\n  raise Mongoid::Errors::TransactionsNotSupported\nend\n\n# Starts a transaction that should include all the operations inside\n# the sandboxed console session. This transaction should not be ever committed.\n# When a user end the console session, the client will disconnect, and\n# the transaction will be automatically aborted therefore.\n#\n# @param [ Mongo::Client ] client Client to start the transaction.\ndef start_sandbox_transaction(client)\n  session = client.start_session\n  Mongoid::Threaded.set_session(session, client: client)\n  session.start_transaction\nend\n\n# Prepares console sandbox mode. This method should be called when\n# a user starts rails console with '--sandbox' flag.\ndef start_sandbox\n  Mongoid.persistence_context.client.tap do |client|","sourceCodeStart":1,"sourceCodeEnd":36,"githubUrl":"https://github.com/mongodb/mongoid/blob/0da0e23d71adfbad31128c18e5e2c8c301c6f7c4/lib/mongoid/railties/console_sandbox.rb#L1-L36","documentation":"Error \"Transactions are not supported by the connected server(s).\" thrown in mongodb/mongoid.","triggerScenarios":"Thrown at lib/mongoid/railties/console_sandbox.rb:18 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"}