[CDRIVER-3757] mongoc_client_pool_new does not initialize its condition variable Created: 16/Jul/20 Updated: 28/Oct/23 Resolved: 23/Jul/20 |
|
| Status: | Closed |
| Project: | C Driver |
| Component/s: | libmongoc |
| Affects Version/s: | None |
| Fix Version/s: | 1.18.0, 1.17.3, 1.18.0-alpha |
| Type: | Bug | Priority: | Major - P3 |
| Reporter: | Andrew Witten (Inactive) | Assignee: | Andrew Witten (Inactive) |
| Resolution: | Fixed | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
The condition variable in mongoc_client_pool_t does not get initialized, which results in undefined behavior. As a consequence, it is possible that a call to mongoc_client_pool_pop when all clients have already been distributed may never return, even when a client becomes available. |
| Comments |
| Comment by Githook User [ 24/Nov/20 ] |
|
Author: {'name': 'Andrew Witten', 'email': 'andrew.witten@mongodb.com', 'username': 'awitten1'}Message: Initializes pool condition variable. Adds (non-deterministic) test for the case where a thread is waiting in call to `mongoc_client_pool_pop` for a client to become available. |
| Comment by Githook User [ 23/Jul/20 ] |
|
Author: {'name': 'Andrew Witten', 'email': 'andrew.witten@mongodb.com', 'username': 'awitten1'}Message: Initializes pool condition variable. Adds (non-deterministic) test for the case where a thread is waiting in call to `mongoc_client_pool_pop` for a client to become available. |
| Comment by Kaitlin Mahar [ 20/Jul/20 ] |
|
andrew.witten No worries! Thank you for the quick reply and clarification. |
| Comment by Andrew Witten (Inactive) [ 20/Jul/20 ] |
|
Hi Kaitlin. Sorry, my description wasn't clear. I will edit that now. The issue is that even when a client becomes available, the function still may not return. mongoc_client_pool_try_pop won't be affected, because it doesn't block in the event that max_pool_size clients have already been distributed (it just returns NULL). |
| Comment by Kaitlin Mahar [ 20/Jul/20 ] |
|
Hi andrew.witten, question - isn't the expected behavior of this method to not return until a new client is available? Or is the problem that even if a client later becomes available, the method might not return? I ask because I work on the Swift driver, which wraps libmongoc, and we use mongoc_client_pool_t s to back our MongoClient type. We actually always use mongoc_client_pool_try_pop though. Would that method be affected at all by this bug? |
| Comment by Andrew Witten (Inactive) [ 17/Jul/20 ] |