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

close() method on connections in the shell is broken with logical sessions

    • Type: Icon: Bug Bug
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Shell
    • Labels:
      None
    • Server Tooling & Methods
    • ALL
    • Hide

      Run this against a mongod with auth enabled and a user named "admin" with the password "admin"

      var newConn = new Mongo();
      newConn.getDB("admin").auth("admin", "admin");
      newConn.close();
      

      Although newConn is no longer usable, it won't actually be closed on the server side.

      Show
      Run this against a mongod with auth enabled and a user named "admin" with the password "admin" var newConn = new Mongo(); newConn.getDB( "admin" ).auth( "admin" , "admin" ); newConn.close(); Although newConn is no longer usable, it won't actually be closed on the server side.
    • Service Arch 2018-10-08, Service Arch 2018-10-22, Service Arch 2018-11-05, Service Arch 2018-11-19, Service Arch 2018-12-03, Service Arch 2018-12-17, Service Arch 2018-12-31, Service Arch 2019-01-14, Service Arch 2019-01-28, Service Arch 2019-02-11, Service Arch 2019-02-25, Service Arch 2019-03-11, Service Arch 2019-03-25

      When logical sessions are implicitly created in the shell, they bump the ref-count of the client that created them, so that they can end the session on the same connection. The close() method on the Mongo connection works by resetting the shared_ptr<DBClientBase> that holds the underlying C++ client. Since the implicit session now holds a copy of that shared_ptr, close() basically does nothing.

      There seem to be two options:

      • Have the Session object hold a weak_ptr to its DBClientBase, and lock/check the client before trying to end the session. The downside here is that the session might be finalized before the client and we'd leak the session on the server.
      • Have the client keep track of its default session and end it during its finalizer.

            Assignee:
            backlog-server-stm Backlog - Server Tooling and Methods (STM) (Inactive)
            Reporter:
            jonathan.reams@mongodb.com Jonathan Reams
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: