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

Cursor session id (none) is not the same as the operation context's

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Critical - P2 Critical - P2
    • 3.1.0, 3.0.8
    • Affects Version/s: 3.0.6
    • Component/s: Core, Native
    • Environment:
      linux, mongo shard cluster, connecting to a mongos instance via ssh tunnel

      1.) Only one collection and especially one query is failin: Guess it has either todo with the content or with the length of the result?
      2.) it is only happening if I set readPreference expicity to "primaryPreferred".

      Test script:
      Import the attached file "buggycollection1.json" like this into a mongo db shard cluster / connect to a mongos:
      mongoimport -h localhost -d mongo-bug-sessions -c buggycollection1 buggycollection1.json

      const mongodb = require('mongodb');
      
      const conf = {
          opts: {
              readPreference: 'primaryPreferred'
          },
          url: 'mongodb://mongos-instance/mongo-bug-sessions'
      };
      
      mongodb.MongoClient.connect(
          conf.url,
          conf.opts
      )
          .then((client) => {
              console.log(new Date(), 'connected');
              client.on('close', () => console.log('closed'));
              client.on('reconnect', () => console.log('reconnect'));
              client.on('disconnect', () => console.log('disconnect'));
      
              const db = client.db('mongo-bug-sessions');
      
              db.collection('buggycollection1').find({lang: 'de'}).toArray()
                  .then((translations) => {
                      console.log('A', !!translations);
                  });
          });
      

      Output:

      /usr/local/bin/node /home/simon/Dev/Web/hokify-server/helpers/mongodbtest2.js
      2018-04-19T08:45:25.804Z 'connected'
      (node:9721) UnhandledPromiseRejectionWarning: MongoError: Cursor session id (none) is not the same as the operation context's session id (c9b18612-f8b1-4efb-a2a8-b2319b5d78f2 - 0rbp3hXFaGQzW/eEz2QZrZ7et36CzL3bnxgnuRX9rEo=)
          at /home/simon/Dev/Web/hokify-server/node_modules/mongodb-core/lib/connection/pool.js:599:61
          at authenticateStragglers (/home/simon/Dev/Web/hokify-server/node_modules/mongodb-core/lib/connection/pool.js:516:16)
          at Connection.messageHandler (/home/simon/Dev/Web/hokify-server/node_modules/mongodb-core/lib/connection/pool.js:552:5)
          at emitMessageHandler (/home/simon/Dev/Web/hokify-server/node_modules/mongodb-core/lib/connection/connection.js:309:10)
          at Socket.<anonymous> (/home/simon/Dev/Web/hokify-server/node_modules/mongodb-core/lib/connection/connection.js:452:17)
          at Socket.emit (events.js:159:13)
          at addChunk (_stream_readable.js:265:12)
          at readableAddChunk (_stream_readable.js:252:11)
          at Socket.Readable.push (_stream_readable.js:209:10)
          at TCP.onread (net.js:608:20)
      (node:9721) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
      (node:9721) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
      
      

      See also realted issue on mongoose tracker: https://github.com/Automattic/mongoose/issues/6357

      Thanks
      Simon

        1. full_debub.log
          68 kB
        2. buggycollection1.json
          186 kB

            Assignee:
            daniel.aprahamian@mongodb.com Daniel Aprahamian (Inactive)
            Reporter:
            s.tretter@gmail.com Simon Tretter
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: