ExportXMLWordPrintableJSON

    • Type: Bug
    • Resolution: Done
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None
    • None
    • None

      I want to use the [Transactions with Sessions|https://docs.mongodb.com/mongoid/7.0/tutorials/mongoid-sessions/] on the Mongoid. 

       

      To make this possible, I already did setup a replica set on my system, but I am having a version problem with the `MongoDB server` which I am trying, but cannot upgrade.

       

      How to Reproduce...

       

      1. Enter on rails console

      ```rb

      rails c

      ```

       

      2.  Try to execute this code

      ```rb

      Project.with_session do |session|

        session.start_transaction

        Project.create!(name: 'Example')

        session.commit_transaction

      end

      ```

       

      3. The result here is the following error message

      ```rb

      Mongoid::Errors::InvalidSessionUse:

      message:

        Sessions are not supported by the connected server(s).

      summary:

        A session was attempted to be used with a MongoDB server version that doesn't support sessions. Sessions are supported in MongoDB server versions 3.6 and higher.

      resolution:

        Verify that all servers in your deployment are at least version 3.6 or don't attempt to use sessions with older server versions.

      from /Users/victor/.rvm/gems/ruby-2.6.5@pocket/gems/mongoid-7.0.5/lib/mongoid/clients/sessions.rb:98:in `rescue in with_session'

      Caused by Mongo::Error::InvalidSession: Sessions are not supported by the connected servers.

      from /Users/victor/.rvm/gems/ruby-2.6.5@pocket/gems/mongo-2.12.1/lib/mongo/client.rb:865:in `start_session'

      ```

       

      My replica sets

      ```rb

      $ mlaunch list

       

      PROCESS    PORT     STATUS     PID

       

      mongod     27017    running    -

      mongod     27018    running    33353

      mongod     27019    running    33356

      ```

       

       

      My `mongoid.yml` file config

      ```yaml

      development:

        clients:

          default:

            database: pocket_api_development

            hosts:

              - "<%= ENV["MONGO_HOST"] %>:27017"

            options:

              user: 'root'

              password: 'ri8Oogu6'

              auth_source: admin

              replica_set: replset

        options:

      test:

        clients:

          default:

            database: pocket_api_test

            hosts:

              - "<%= ENV["MONGO_HOST"] %>:27017"

            options:

              read:

                mode: :primary

              max_pool_size: 1

              user: 'root'

              password: 'ri8Oogu6'

              auth_source: admin

      ```

       

            Assignee:
            Oleg Pudeyev (Inactive)
            Reporter:
            Victor Costa
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: