[CXX-1391] reset client options when returned to the pool Created: 12/Jul/17  Updated: 12/Jul/17  Resolved: 12/Jul/17

Status: Closed
Project: C++ Driver
Component/s: Implementation
Affects Version/s: 3.1.1
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Pierre Petitprez Assignee: David Golden
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to CXX-1086 Deprecate non-const methods on mongoc... Closed
related to CDRIVER-938 Prohibit setting options on pooled cl... Backlog

 Description   

When I acquire a client from a pool and manually modify the write concern at client level (client::write_concern(wc)), the modified client is released to the pool.

Later on, if I acquire a new client from this pool, I may end-up with a client with the modified write concern, which does not correspond to the one the pool has been created with.

With current behavior, application code seems to be responsible to reset the client write concern to an appropriate value before it is released to the pool.

The pool should take care of resetting the write concern to an appropriate value or the write_concern of a client acquired from the pool should be read-only.



 Comments   
Comment by David Golden [ 12/Jul/17 ]

Hi. Thanks for the bug report and are sorry that you experienced this problem. Unfortunately, this is a limitation of libmongoc. In the next release of the C++ driver (3.2.0), modifying client options will be deprecated (see CXX-1086). A future version of libmongoc will remove the ability to modify options at all (CDRIVER-938) at which point the C++ driver will have to do the same.

We recommend setting default client options in the URI string used to configure the pool or setting operation-specific options such as write concern on the database/collection objects acquired from a checked out client. This will avoid the problem you experienced.

Generated at Wed Feb 07 22:02:29 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.