Re: Why does MongoDB (Version 3.2) creates two connections instead of one?

From: Mayank Jain <firesofmay@xxxxxxxxx>
To: mongodb-user <mongodb-user@xxxxxxxxxxxxxxxx>
Date: Tue, 19 Apr 2016 22:27:38 -0700 (PDT)
Why ads?
Thanks :)

On Friday, April 15, 2016 at 3:42:12 AM UTC+5:30, Jason Carey wrote:

Mayank,

You may be seeing the Monitor Thread 
<https://github.com/mongodb/specifications/blob/master/source/server-discovery-and-monitoring/server-discovery-and-monitoring.rst#monitor-thread>.  
Drivers are required by the MongoDB Server Discovery and Monitoring 
Specification to do a variety of background health checks to monitor the 
topology behind a given MongoDB URI.  This catches things like replica set 
failover, the addition of new mongos' in sharding, etc.

Most drivers handle this with a background thread, those that don't are 
forced to periodically block during processing instead.

-Jason

On Wed, Apr 13, 2016 at 2:40 PM, Mayank Jain <fires...@xxxxxxxxx 
<javascript:>> wrote:

Hi,

I have noticed that after I create a connection, and do say an insert 
mongodb creates another connection.

I have seen this behaviour with mongodb python and clojure (which uses 
java) library both.

Here's an example of how to reproduce it:

from pymongo import MongoClient


## Run `db.serverStatus().connections`via mongo shell to check the 
current number of connections
client = MongoClient()


## Run the `db.serverStatus().connections` command again, it should 
increment by 1
client.test_database.posts.insert_one({"author": "Mike"}).inserted_id
## Now if you run `db.serverStatus().connections` command again, it again 
increments by 1

##But if you repeat insert (or any other command besides createing a new 
connection) it wont create another connection

I am using:
Python        - 3.5.1
Mac OSX       - 10.10.5
Mongo Version - 3.2.4

Is this expected? Has anyone else seen this?

Thanks.

-- 
You received this message because you are subscribed to the Google Groups 
"mongodb-user"
group.
 
For other MongoDB technical support options, see: 
https://docs.mongodb.org/manual/support/
--- 
You received this message because you are subscribed to the Google Groups 
"mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an 
email to mongodb-user...@xxxxxxxxxxxxxxxx <javascript:>.
To post to this group, send email to mongod...@xxxxxxxxxxxxxxxx 
<javascript:>.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/mongodb-user/96895ac1-a6a5-4cbb-8f29-7d567e005486%40googlegroups.com ;
<https://groups.google.com/d/msgid/mongodb-user/96895ac1-a6a5-4cbb-8f29-7d567e005486%40googlegroups.com?utm_medium=email&utm_source=footer>
.
For more options, visit https://groups.google.com/d/optout.




-- 

*{* name     : "Jason Carey",
  title    : "Software Engineer",
  location : "New York, NY",
  twitter  : ["@MongoDB 
<https://www.google.com/url?q=https%3A%2F%2Ftwitter.com%2Fmongodb&sa=D&sntz=1&usg=AFQjCNGEAIAhZyZhF7Z9ORWsRliTuc-2dg>
", "@MongoDBInc 
<https://www.google.com/url?q=https%3A%2F%2Ftwitter.com%2FMongoDBInc&sa=D&sntz=1&usg=AFQjCNH9Zm1xgTMok-W3GyJEcGcBsz7xnw>
"],
  facebook : ["MongoDB 
<https://www.google.com/url?q=https%3A%2F%2Fwww.facebook.com%2Fmongodb&sa=D&sntz=1&usg=AFQjCNGPMcaFBzmWsh-MpaWeTH6vMQoDIg>
", "MongoDB, Inc. 
<http://www.google.com/url?q=http%3A%2F%2Fwww.facebook.com%2Fmongodbinc&sa=D&sntz=1&usg=AFQjCNEqXl7N-lTJTvsA4RbtY1xEm0I8Zw>
"] *}*


-- 
You received this message because you are subscribed to the Google Groups "mongodb-user"
group.

For other MongoDB technical support options, see: https://docs.mongodb.org/manual/support/
--- 
You received this message because you are subscribed to the Google Groups "mongodb-user" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mongodb-user+unsubscribe@xxxxxxxxxxxxxxxx.
To post to this group, send email to mongodb-user@xxxxxxxxxxxxxxxx.
Visit this group at https://groups.google.com/group/mongodb-user.
To view this discussion on the web visit https://groups.google.com/d/msgid/mongodb-user/e7dbc1a1-e604-41e9-a11f-058ac141fcff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Why ads?