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.

1 Answer 1


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?

  • @aks, I even tried to add new connections after B came back in action. But still only C is processing those request. Only when I restarted Mongos server, B started receiving connections.
    – liondgr8
    Apr 29, 2014 at 9:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.