Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-46696

mongo shell can end up creating multiple implicit sessions on the same replica set connection

    • Fully Compatible
    • ALL
    • v4.4
    • Sharding 2020-03-23
    • 34

      The issue is that the mongo shell creates new _mongo variable every query (via setHiddenMongo) and this is the variable ends up being passed to _DelegatingDriverSession. Note that setHiddenMongo ends up creating new mongo variables because the connection the connection is actually a DBClientRS so runCommandWithTarget will return the connection to the primary. Thus, the comparison here will always fail. The variable also uses the same connection object, but since it is a new variable, it "forgets" everything about the connection, leaving the "authenticated" and "_defaulSession" variables undefined.

      This means that when getDB is called, it will end up trying to authenticate on the same c++ connection, which in turn will try to get the default session. But since it is a new variable, it will not have the _defaultSession variable set and end up creating a new one on the same cpp connection.

            Assignee:
            randolph@mongodb.com Randolph Tan
            Reporter:
            janna.golden@mongodb.com Janna Golden
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: