[GODRIVER-2366] Prevent unnecessary goroutines when minPoolSize > maxPoolSize Created: 04/Apr/22  Updated: 28/Oct/23  Resolved: 09/May/22

Status: Closed
Project: Go Driver
Component/s: None
Affects Version/s: None
Fix Version/s: 1.9.2

Type: Bug Priority: Unknown
Reporter: Matt Dale Assignee: Qingyang Hu
Resolution: Fixed Votes: 0
Labels: neweng
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Documentation Changes: Not Needed

 Description   

Currently, the pool.maintain() goroutine will create up to one goroutine per requested connection to satisfy minPoolSize. In the case that minPoolSize > maxPoolSize, many of those created goroutines will be stuck waiting for connections indefinitely (no new connections are created once maxPoolSize is reached).

This configuration is technically invalid, but it seems that the Go driver doesn't currently return a configuration error when minPoolSize > maxPoolSize. From the CMAP spec:

  /**
   *  The minimum number of Connections that MUST exist at any moment
   *  in a single connection pool.
   *  If specified, MUST be an integer >= 0. If maxPoolSize is > 0
   *  then minPoolSize must be <= maxPoolSize
   *  Defaults to 0.
   */
  minPoolSize?: number;

Either update pool.maintain() to prevent creating goroutines that will be blocked indefinitely when trying to satisfy minPoolSize or update the configuration option validation to return an error when minPoolSize > maxPoolSize



 Comments   
Comment by Githook User [ 04/Oct/22 ]

Author:

{'name': 'Qingyang Hu', 'email': '103950869+qingyang-hu@users.noreply.github.com', 'username': 'qingyang-hu'}

Message: GODRIVER-2366 Restrict minPoolSize to not exceeding maxPoolSize (#933)
Branch: release/1.9
https://github.com/mongodb/mongo-go-driver/commit/920d1949c09b9986f34caa615e9bbe2ca3934cb6

Comment by Githook User [ 09/May/22 ]

Author:

{'name': 'Qingyang Hu', 'email': '103950869+qingyang-hu@users.noreply.github.com', 'username': 'qingyang-hu'}

Message: GODRIVER-2366 Restrict minPoolSize to not exceeding maxPoolSize (#933)
Branch: master
https://github.com/mongodb/mongo-go-driver/commit/5be1db14bde372c8f2ccef4002c867a617f9da9f

Generated at Thu Feb 08 08:38:25 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.