Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-3762

Improve error message when running concurrent queries using the same client session

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

      What problem are you facing?

      When connected to serverless and running a find query for multiple databases in parallel while passing the same session to all requests driver fails with an error:

      TypeError: Cannot pin multiple connections to the same session
          at ClientSession.pin (/Users/sergey.petushkov/Projects/MongoDB/compass2/node_modules/mongodb/lib/sessions.js:114:19)
      

      What driver and relevant dependency versions are you using?

      Node.js Driver v4.1.4
      MongoDB 5.1.0 Enterprise Serverless (Load Balanced)

      Steps to reproduce?

      Assuming sample data exists on the server:

      var client = new MongoClient('<connection string>')
      await client.connect();
      var session = client.startSession();
      await Promise.all([
        client
          .db("sample_airbnb")
          .collection("listingsAndReviews")
          .find({}, { session })
          .limit(20)
          .toArray(),
        client
          .db("sample_mflix")
          .collection("movies")
          .find({}, { session })
          .limit(20)
          .toArray(),
      ]);
      

      Note that the issue appears to happen only when connected to serverless and doesn't reproduce when running commands in parallel against the same database

            Assignee:
            Unassigned Unassigned
            Reporter:
            sergey.petushkov@mongodb.com Sergey Petushkov
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: