Replicaset issues when testing HA

已查看 13 次
跳至第一个未读帖子

Jorge L.

未读,
2015年6月4日 06:45:302015/6/4
收件人 node-mong...@googlegroups.com
We are using mongoDB native driver for node:

"mongodb": "2.0.27"

but we are experiencing problems when we shutdown some of the replicaset instances in order to test robustness and HA of our app.

Our replicaset has 3 instances: primary (P1), and 2 secondaries (S1 and S2). We have tested several configurations with the same result. The most promising one is:

 

var DATABASE = { uri: 'mongodb://mongo1:27017,mongo2:27017,mongo3:27017/testdb', options: { db: { bufferMaxEntries: 0 }, replSet: { replicaSet: 'testReplica', socketOptions: { keepAlive: 1 } } } }; MongoClient.connect(DATABASE.uri, DATABASE.options, function(err, db) {...});

 
We've followed these steps:
  • When starting up the app with the replicaset up, it opens 5 sockets per mongo instance (15 socket in total).
  • If we stop one of the secondaries (S1), then the 5 sockets corresponding to S1 are closed.
  • If we restart S1, it is not opened the 5 sockets to S1. Is that correct?
  • If we stop the primary (P1), then the 5 sockets corresponding to P1 are closed
  • When one of the secondaries are elected as primary, two possible options are available:
    • If S1 is selected as primary, then our client does not detect this primary because there is no connection to it. As a result, the app fails.
    • If S2 is selected as primary, then our client reconnects and keeps working correctly.
  • When the primary (P1) is restarted and configured as primary, the mongo client is reconnected successfully.
It looks like our mongo client does not reconfigure correctly with secondaries, however it works correctly with the primary. Perhaps the replicaset topology is not discovered correctly.

Is this a bug? Is it a misunderstanding?


Jorge L.

未读,
2015年6月4日 09:18:282015/6/4
收件人 node-mong...@googlegroups.com
It looks like the problem was related to mismatch between the addresses in replicaset and the addresses in the client application. If both addresses match, then the reconnection works correctly.
回复全部
回复作者
转发
0 个新帖子