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

MongoError: Not Master when running createIndex in 3.6.0

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 3.6.3
    • Affects Version/s: 3.6.0
    • Component/s: None
    • Labels:

      Hello, I have been using the Node Mongo driver successfully for many years. However, when we upgraded to 3.6.0 our code began to break during our app's startup throwing the following error: 


      (node:90414) UnhandledPromiseRejectionWarning: MongoError: not master at MessageStream.messageHandler (/Users/jpavlic1/core/app/node_modules/mongodb/lib/cmap/connection.js:266:20) at MessageStream.emit (events.js:311:20) at MessageStream.EventEmitter.emit (domain.js:482:12) at processIncomingData (/Users/jpavlic1/core/app/node_modules/mongodb/lib/cmap/message_stream.js:144:12) at MessageStream._write (/Users/jpavlic1/core/app/node_modules/mongodb/lib/cmap/message_stream.js:42:5) at doWrite (_stream_writable.js:441:12) at writeOrBuffer (_stream_writable.js:425:5) at MessageStream.Writable.write (_stream_writable.js:316:11) at Socket.ondata (_stream_readable.js:714:22) at Socket.emit (events.js:311:20) at Socket.EventEmitter.emit (domain.js:482:12) at addChunk (_stream_readable.js:294:12) at readableAddChunk (_stream_readable.js:275:11) at Socket.Readable.push (_stream_readable.js:209:10) at TCP.onStreamRead (internal/stream_base_commons.js:186:23)


      I traced this to a step in our code where we do a createIndex on a collection that already exists, and already has the index. The createIndex is there in case we have created a new database and need the index. My connection string looks like this:



      One other thing to note - I switched the readPreference to Primary to see if that would work. It did, but it also deleted all the data in the collection. This did not previously happen when using 3.5.x. Is this expected? 

      Thanks for looking into this


            thomas.reggi@mongodb.com Thomas Reggi (Inactive)
            john_pavlick@condenast.com John Pavlick
            0 Vote for this issue
            5 Start watching this issue