[CXX-1086] Deprecate non-const methods on mongocxx::client Created: 12/Oct/16  Updated: 12/Jul/17  Resolved: 14/Apr/17

Status: Closed
Project: C++ Driver
Component/s: Documentation
Affects Version/s: None
Fix Version/s: 3.2.0-rc0

Type: New Feature Priority: Major - P3
Reporter: David Golden Assignee: Samuel Rossi (Inactive)
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to CDRIVER-938 Prohibit setting options on pooled cl... Backlog
is related to CXX-1391 reset client options when returned to... Closed

 Description   

We should deprecate all of the non-const methods on mongocxx::client, namely:

  • client::read_concern(class read_concern)
  • client::read_preference(class read_preference)
  • client::write_concern(class write_concern)

This would allow us to eventually remove the calls to mongoc_client_set_read_concern() and others from client.cpp, which in turn would allow the C++ driver to be in compliance with the C driver requirement of "It is a programming error to call this function on a client from a mongoc_client_pool_t.".

We should document that users should instead set these values on the client/pool URI, or the database or collection objects derived from the client instead.

Original description:

Because clients have mutable state, it may be possible for the following to happen:

  • check out client A from pool
  • modify client A's write concern from default set via URI
  • perform operations with modified write concern (e.g. find-and-modify ops)
  • return client A to pool
  • check out client A from pool, still with modified write concern
  • perform operations with modified write concern rather than the default

Is this actually possible? If so, should we enforce an invariant that all clients are checked out with identical configuration? Should we push that invariant upstream to libmongoc?



 Comments   
Comment by Githook User [ 14/Apr/17 ]

Author:

{u'username': u'saghm', u'name': u'Saghm Rossi', u'email': u'saghmrossi@gmail.com'}

Message: CXX-1086 Deprecate non-const methods on mongocxx::client
Branch: master
https://github.com/mongodb/mongo-cxx-driver/commit/7893799c4545c740b637d1c93917b89c35ea6bb8

Comment by David Golden [ 14/Apr/17 ]

Agreed. Let's deprecate in the documentation.

Comment by J Rassi [ 12/Apr/17 ]

david.golden: I'm pulling this into 3.2.0-rc0, feel free to bump it back out if you'd like.

Comment by David Golden [ 14/Oct/16 ]

I'm targeting this for 4.0-required as I think we need time to develop a good solution, but I don't think a solution is optional.

Comment by David Golden [ 14/Oct/16 ]

CDRIVER-938 addresses this as well. Their plan seem to be to prohibit modifying options on pooled clients. Perhaps we deprecate the functionality like they do, or perhaps we should move towards making client objects fully immutable.

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