[GODRIVER-1883] [question] Unexpected connection numbers when initializing the client Created: 11/Feb/21 Updated: 27/Oct/23 Resolved: 16/Feb/21 |
|
| Status: | Closed |
| Project: | Go Driver |
| Component/s: | Connections |
| Affects Version/s: | 1.4.6 |
| Fix Version/s: | None |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | 策 高 | Assignee: | Unassigned |
| Resolution: | Works as Designed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
WSL Kwernel: 4.19.128-microsoft-standard |
||
| Issue Links: |
|
||||||||
| Description |
|
When initializing the client with default configs, there is more than 1 connection (sometimes 2, sometimes 3) to the specific server. When I set the MaxPoolSize to 2 and MinPoolSize to 2, I got 4 connections which are also unexpected. I am wondering if it is a bug or feature in the driver? |
| Comments |
| Comment by 策 高 [ 14/Feb/21 ] |
|
Thanks for your reply! Find the corresponding logic at go.mongodb.org/mongo-driver/x/mongo/driver/topology/server.go.
|
| Comment by Kevin Albertson [ 11/Feb/21 ] |
|
Hi gaocegege@gmail.com, thank you for the report! That sounds like expected behavior. A fixed number of connections are created per server for monitoring. This is in addition to the connections created for application use (which is dictated by MinPoolSize and MaxPoolSize). For Go driver 1.4.0+ there are a fixed 2 monitoring connections per server.
If no MaxPoolSize was specified, the default MaxPoolSize is 100. And application connections are created as needed. The higher rate of concurrent operations, the more application connections will be created, capping at MaxPoolSize.
If you are connecting to one server, since there are two monitoring connections, that is expected. Sincerely, |