Hi Pavel
Replica set members will monitor each other (see Replication) so that every node is aware of the status of every other node in the set.
Also, if your application is connected to the replica set (e.g. using the replicaSet option in the URI string), then the driver will automatically monitor the whole replica set. Please see What’s the point of periodic monitoring in the Server Discovery and Monitoring spec.
Are you seeing any issue that was caused by the connections?
Best regards
Kevin
Hi Pavel
this number is now much higher around 37000, and I don’t understand why there are 37000 open connections?
One possible cause is an application opened a connection and don’t close them when it is done with it.
The message “scoped connection not being returned to the pool” originated from this line in the MongoDB 3.6.4 source code: https://github.com/mongodb/mongo/blob/r3.6.4/src/mongo/client/connpool.cpp#L662-L663, and from the comments, that part of the code is responsible for deleting failed connections.
Are you using a monitoring service of some kind? Also, could you check that the application is calling close()
properly on the connections?
Official drivers also operate connection pooling. It is also possible that the maximum number of connection in the pool is set too high. Please see How does connection pooling work in PyMongo for an example.
Best regards
Kevin
Hi Pavel
2018-03-17T11:05:11.537+0000 I NETWORK [thread7] Successfully connected to mongodb2:27017 (1872 connections now open to mongodb2:27017 with a 0 second timeout)
Yes the messages are from an internal replica set monitoring thread. I assume you are alarmed by the message 1872 connections now open
. However, this is not a reflection of the number of client connections to the server.
The output of db.serverStatus().connections
shows the actual number of currently open client connections to the server. Please see the connections section in serverStatus page for more information. The output of db.serverStatus()
is the canonical source of information regarding the state of the server.
Having said that, a similar concern regarding this message was reported in SERVER-34120. Please watch/upvote the ticket if you’re interested in this.
Best regards
Kevin
Hi Madhu
I think we have not found the any fix for this yet.
I having the same issue.
Please note that as mentioned in SERVER-34120, this is just a bookkeeping issue. There is no resource leak, so you can safely ignore the scoped connection not being returned to the pool
messages.
The ticket is currently in code review, meaning that this bookkeeping mistake will be fixed shortly.
Best regards,
Kevin