[CDRIVER-2389] Deprecate minPoolSize and log a warning if it's used Created: 17/Nov/17 Updated: 28/Oct/23 Resolved: 05/Dec/17 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | libmongoc, network |
| Affects Version/s: | None |
| Fix Version/s: | 1.9.0 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Rustam Abdullaev | Assignee: | A. Jesse Jiryu Davis |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Environment: |
Windows 10 x64 |
||
| Issue Links: |
|
||||||||||||||||||||
| Case: | (copied to CRM) | ||||||||||||||||||||
| Description |
|
Summary: minPoolSize does not do what anyone expects, and it's inconsistent with other drivers' options that have the same or similar names. What it actually does is not useful. Deprecate it, remove it from the main mongoc_uri_t documentation, and log a warning if it's used. — Original report: Setting minPoolSize in the URL to a non-zero value causes frequent connects/disconnects in a threaded environment. That is not the behavior that one would expect from this setting. Steps to reproduce:
Results: minPoolSize=0
minPoolSize=1
|
| Comments |
| Comment by Githook User [ 05/Dec/17 ] |
|
Author: {'username': 'ajdavis', 'email': 'jesse@mongodb.com', 'name': 'A. Jesse Jiryu Davis'}Message: |
| Comment by Rustam Abdullaev [ 18/Nov/17 ] |
|
Not what anyone expects indeed; it doesn't work as in PyMongo, it doesn't work as documented in mongodb reference and I can't think of any use for what it actually does. I think at least the delay before new connections are established should be increased. Meanwhile we're going to have to add a sanitizer for the URL in our code because this isn't the first time someone tries to enable it in production :\ |
| Comment by A. Jesse Jiryu Davis [ 18/Nov/17 ] |
|
This is a C Driver design flaw. The minPoolSize option works as documented, which unfortunately is probably not what anyone expects: http://mongoc.org/libmongoc/current/mongoc_uri_t.html#connection-pool-options minPoolSize is "the number of clients to keep in the pool; once it is reached, mongoc_client_pool_push() destroys clients instead of pushing them." It could be better named "maxIdleClients". It is not a very useful setting. It does not work the same as minPoolSize in PyMongo or minConnectionsPerHost in the Java Driver, which more likely match your expectations. Those options maintain at least minPoolSize open connections, eagerly opening connections even if they are not yet demanded. I haven't come up with a backwards-compatible strategy for fixing this problem. Probably we should deprecate the option, log a warning whenever it's configured, and not introduce a new option that matches PyMongo's minPoolSize behavior unless there is a very strong desire for it. Meanwhile, please don't use minPoolSize at all. |