-
Type: Bug
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: 3.0.4
-
Component/s: None
-
None
-
Empty show more show less
The issue occurred to an Atlas customer running replica set distributed between the regions in the following way: PSS in "N. Virginia (us-east-1)" and the other SSS with priority==votes==0 in Tokyo (ap-northeast-1).
The customer configured readPreference=nearest in the connection string (or programmatically)
and tried to drop the database. Please see below the code snippet:
var MongoClient = require("mongodb").MongoClient, assert = require('assert'); var url = "mongodb://<USER>:<PWD>@host_1:27017,host_2:27017,host_3:27017,host_4:27017,host_5:27017,host_6:27017/test?ssl=true&replicaSet=Cluster0-shard-0&authSource=admin&readPreference=nearest" // Use connect method to connect to the server MongoClient.connect(url, function(err, client) { assert.equal(null, err); const db = client.db("test1"); console.log("Connected successfully to server"); db.dropDatabase(function(err, result){ console.log("Error : " + err); if (err) throw err; console.log("Operation Success ?" + result); // after all the operations with db, close it. client.close(); }); });
As a result the following exception was thrown:
...node_modules/mongodb/lib/utils.js:132 throw err; ^ MongoError: not master .../mongodb-core/lib/connection/pool.js:595:61 at authenticateStragglers (...mongodb-core/lib/connection/pool.js:513:16) at Connection.messageHandler (...mongodb-core/lib/connection/pool.js:549:5) at emitMessageHandler (...mongodb-core/lib/connection/connection.js:309:10) at TLSSocket.<anonymous> (.../mongodb-core/lib/connection/connection.js:452:17) at emitOne (events.js:115:13) at TLSSocket.emit (events.js:210:7) at addChunk (_stream_readable.js:266:12) at readableAddChunk (_stream_readable.js:253:11) at TLSSocket.Readable.push (_stream_readable.js:211:10)
This issue was also reproduced with Compass 1.12.4.
I also tried to reproduce it with the Java driver, though it worked as expected.