Uploaded image for project: 'Drivers'
  1. Drivers
  2. DRIVERS-759

Drivers may defer checking if a deployment supports sessions until the session's first operation

    • Type: Icon: Improvement Improvement
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Component/s: None
    • None

      Previously, the sessions specification required that MongoClient.startSession report an error if the deployment does not support sessions.

      The spec has now been amended to permit drivers to defer checking for sessions support and reporting that error until the first time the session is used for an operation.

      Reporting this error from startSession is still permitted, so drivers may choose to not change anything.

      See changes:

      https://github.com/mongodb/specifications/commit/5efe2a1d4c7483920fbb11613652416acfb88ce7

      The rationale behind this change:

      Determining if a deployment supports sessions requires SDAM to have been started. However, some drivers lazily start SDAM the first time a client is used for an operation. If a user creates a client and then immediately starts a session, then startSession would have to perform I/O in order to check for support. For drivers with asynchronous APIs, this means that startSession would have to be an asynchronous method to comply with the spec. This is not ideal; the API becomes unnecessarily clunky and adds the overhead of a promise every time it is used, even though in the majority of cases startSession will require no I/O.

      Allowing the error to be reported later on when the session is used for an operation means that startSession can be implemented in a way that never performs I/O.

            Assignee:
            Unassigned Unassigned
            Reporter:
            kaitlin.mahar@mongodb.com Kaitlin Mahar
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: