[SERVER-7089] connection churn from mongos to mongod Created: 20/Sep/12  Updated: 05/Jun/13  Resolved: 13/Nov/12

Status: Closed
Project: Core Server
Component/s: Networking, Sharding
Affects Version/s: 2.2.0
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Daniel Pasette (Inactive) Assignee: Randolph Tan
Resolution: Duplicate Votes: 2
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-7612 explicit primary read pref does not ... Closed
Operating System: ALL
Participants:

 Description   

seeing tons of sockets being opening and closed where the client to mongos pool is constant.



 Comments   
Comment by Randolph Tan [ 13/Nov/12 ]

Confirmed that SERVER-7612 fixed this issue. Running the sample script below will generate 609 connections to the primary in 2.2.1 and 309 connections when using a mongos with SERVER-7612 fix.

var st = new ShardingTest({ shards: { rs0: { nodes: 2 }} });
 
var conns = [];
for (var x = 0; x < 300; x++) {
    conns.push(new Mongo(st.s.host));
}
 
conns.forEach(function(conn) {
    conn.getDB('test').user.find().readPref('primary').hasNext();
});
 
var stat = st.rs0.getPrimary().getDB('admin').runCommand({ connPoolStats: 1 });
 
st.stop();

Comment by Randolph Tan [ 12/Nov/12 ]

Finally got a very good idea on how this could happen - read preference. If the requests to the mongos are specified as a read preference of primary, then it will create 2 primary connections for each replica set connection object:

(1) one from being called by checkMaster then stored in the _master variable when setting the shard version of the connection and
(2) the other from being called by selectNodeUsingTags then stored in the _lastSlaveOkConn when executing the actual operation.

Generated at Thu Feb 08 03:13:36 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.