Mongodb – No connections to mongodb replset member post outage

mongodb

I have a weird issue in MongoDB. Let me explain.

Suppose, I have following components of mongodb:

  1. A shard with a replset containing 3 members, with 1 primary(say A) and 2
    secondary nodes (say B and C)
  2. 1 mongo-config server
  3. 1 mongos server

I am reading the data from "mongos" server with "secondary" read preference.

Lets assume, I somehow created "4 read connections" on mongos server. Now, the connections are divided between secondary replset members.

No. of Connections:

  • A (primary): 0 connections
  • B (Ist secondary): 2 connections
  • C (IInd secondary): 2 connections

Now the real issue starts when I restart mongod service of B (secondary) to replicate the outage type situation, all the read query connections are lost after that even after mongod got re-started.

  • A (primary): 0 connections
  • B (Ist secondary): 0 connections
  • C (IInd secondary): 4 connections

But to solve this, I always have to restart "mongos" service to get back B again working which is painful.

I don't find any feasible solution for this. Can any one help me in sorting this situation.

Best Answer

By "B" again working do you mean the connections to be distributed evenly when B comes back? Do you see new connections also going to C when B has come back?

I believe MongoS does not do dynamic load balancing w.r.t. to the existing state of connections. However if you create new connections, MongoS may appropriately create connections on B. Do you not see this behaviour?