-
Type: Task
-
Resolution: Fixed
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
(copied to CRM)
-
Empty show more show less
Environment:
- Driver: 2.2.33
- Server: 3.4.10 PSA
Code:
//var sleep = require('sleep'); var MongoClient = require('mongodb').MongoClient; var url = "mongodb://192.168.99.101:40000,192.168.99.101:40001/test?replicaSet=rsTest"; var options = { poolSize: 5, autoReconnect: true, connectTimeoutMS:5000, socketTimeoutMS:5000, bufferMaxEntries: 1000, connectWithNoPrimary: true, replicaSet: "rsTest", reconnectTries: 100, reconnectInterval: 1000 } function insertDocs(db) { var myobj = { name: "Company Inc", address: "Highway 37" }; db.collection("customers").insertOne(myobj, function(erri, res) { if (erri) { console.error(erri); throw erri }; console.log("1 document inserted"); console.log("sleeping"); setTimeout(() => insertDocs(db), 1000); console.log("wake up!"); }); } MongoClient.connect(url, options, function(err, db) { if (err) throw err; insertDocs(db); });
I ran this code which inserts a document every second.
Then ran rs.stepDown() on the primary. My expectation was that the writes will be buffered and that the driver will seamlessly handle it (without throwing exceptions).
What I actually got is the following error as soon as rs.stepDown() was invoked:
MongoError: not master at Function.MongoError.create (/Users/tomeryakir/tmp/njsconns/node_modules/mongodb-core/lib/error.js:31:11) at /Users/tomeryakir/tmp/njsconns/node_modules/mongodb-core/lib/connection/pool.js:497:72 at authenticateStragglers (/Users/tomeryakir/tmp/njsconns/node_modules/mongodb-core/lib/connection/pool.js:443:16) at .messageHandler (/Users/tomeryakir/tmp/njsconns/node_modules/mongodb-core/lib/connection/pool.js:477:5) at Socket.<anonymous> (/Users/tomeryakir/tmp/njsconns/node_modules/mongodb-core/lib/connection/connection.js:331:22) at emitOne (events.js:96:13) at Socket.emit (events.js:188:7) at readableAddChunk (_stream_readable.js:177:18) at Socket.Readable.push (_stream_readable.js:135:10) at TCP.onread (net.js:542:20)
Is this the expected behaviour?