I was just doing a study of the mongodb drivers about replset, this is my demo
var MongoClient = require('mongodb').MongoClient;
var Logger = require('mongodb').Logger;
var url = 'mongodb://10.21.3.44:30000/haozxuan';
Logger.setLevel('debug');
MongoClient.connect(url, /*{"replSet": {"haInterval": 1000}},*/ function (err, db) {
if (err) console.log('err is ', err);
var collection = db.collection('test');
setInterval(function () {
collection.findOne({}, function (err, res) {
console.log('res is ',new Date(), res);
})
}, 1000)
})
i have a replset, info
primary 10.21.3.44:30000
secondary 10.21.3.44:30001
secondary 10.21.3.44:30002
arbiter 10.21.3.44:30003
when i run db.shutdownServer, i catch this result:
res is Thu Jan 28 2016 10:18:06 GMT+0800 (CST) null
res is Thu Jan 28 2016 10:18:07 GMT+0800 (CST) null
res is Thu Jan 28 2016 10:18:08 GMT+0800 (CST) null
res is Thu Jan 28 2016 10:18:09 GMT+0800 (CST) null
res is Thu Jan 28 2016 10:18:10 GMT+0800 (CST) null
res is Thu Jan 28 2016 10:18:11 GMT+0800 (CST) null
res is Thu Jan 28 2016 10:18:13 GMT+0800 (CST) null
res is Thu Jan 28 2016 10:18:14 GMT+0800 (CST) null
res is Thu Jan 28 2016 10:18:15 GMT+0800 (CST) null
however, in this page(A) http://mongodb.github.io/node-mongodb-native/2.0/api/ReplSet.html, the parma haInterval default is 5000ms.
and then , i find mort info in this page(B) https://github.com/christkv/mongodb-core/blob/master/lib%2Ftopologies%2Freplset.js#L138
is this something wrong in page A?
and how much the haInterval of suitable? 10s too long? or 1s too short. i think too short have affect mongo server, too long have affect my application.i am confuse about that.
Regards
haozxuan