Uploaded image for project: 'C++ Driver'
  1. C++ Driver
  2. CXX-1086

Deprecate non-const methods on mongocxx::client



    • New Feature
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • None
    • 3.2.0-rc0
    • Documentation
    • None


      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?


        Issue Links



              sam.rossi@mongodb.com Samuel Rossi (Inactive)
              david.golden@mongodb.com David Golden
              0 Vote for this issue
              2 Start watching this issue