[CXX-927] Support sending writeConcern for commands that write Created: 10/Jun/16  Updated: 30/Jan/17  Resolved: 21/Oct/16

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

Type: New Feature Priority: Major - P3
Reporter: Rathi Gnanasekaran Assignee: David Golden
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on CDRIVER-1704 Inconsistent application of read/writ... Closed
depends on CDRIVER-1527 Add mongoc_client_[read|write|read_wr... Closed
is depended on by DRIVERS-290 Support sending writeConcern for comm... Closed
Related
related to CXX-1085 Inconsistent API for operation level ... Closed
Epic Link: C++11 Driver MongoDB 3.4 Support

 Description   

When talking with server 3.4 or greater (maxWireVersion >=5), writeConcern should be a supported option for commands that write.
Helpers for the following commands therefore must be updated to support the option. The list is ordered according to likelihood that a driver has a helper for the command.

  • aggregate with $out
  • copydb
  • create
  • createIndexes
  • drop
  • dropDatabase
  • dropIndexes
  • mapReduce with $out
  • clone
  • cloneCollection
  • cloneCollectionAsCapped
  • collMod
  • convertToCapped
  • emptyCapped
  • renameCollection
  • appendoplognote
  • godInsert
  • capTrunc
  • reindex
    * mergechunk


Note:

When the writeConcern on a command that writes fails, the resulting document still comes back with ok: 1. Hence, to check for write concern and raise the appropriate error to your users, you will need to check the resulting document for a writeConcernError field. If it is present, then writeConcern failed.



 Comments   
Comment by Githook User [ 29/Nov/16 ]

Author:

{u'username': u'xdg', u'name': u'David Golden', u'email': u'xdg@xdg.me'}

Message: CXX-927 Document use of write_concern for helper functions

The C driver helpers handle write concern from the collection struct and
return an error if a write concern error occurs, so this merely documents
that setting write concern on the collection is required for use.
Branch: master
https://github.com/mongodb/mongo-cxx-driver/commit/0e40786e66b86bdbd48cdd1ed67cafabe7c4eb97

Comment by David Golden [ 14/Oct/16 ]

This is done from the C++ driver side, so I'm marking it resolved. However, this will not actually work until the C driver addresses its tickets relating to write concern.

Comment by Githook User [ 14/Oct/16 ]

Author:

{u'username': u'xdg', u'name': u'David Golden', u'email': u'xdg@xdg.me'}

Message: CXX-927 Document use of write_concern for helper functions

The C driver helpers handle write concern from the collection struct and
return an error if a write concern error occurs, so this merely documents
that setting write concern on the collection is required for use.
Branch: 3.1-dev
https://github.com/mongodb/mongo-cxx-driver/commit/0e40786e66b86bdbd48cdd1ed67cafabe7c4eb97

Comment by David Golden [ 14/Oct/16 ]

Aggregation needs CDRIVER-1704.

Comment by David Golden [ 12/Oct/16 ]

CDRIVER-1527 cleans up the application of collection/database write concern to helpers. Once merged, we have the option to rely on it for Server 3.4 support rather than adding write concern to options.

We could do that later for all relevant commands as part of CXX-1085.

That means the necessary work is:

  • on mongocxx::collection
    • aggregate with $out –  document that write concern must be set on collection
    • createIndexes – document that write concern must be set on collection
    • drop – document that write concern must be set on collection
    • renameCollection – document that write concern must be set on collection
  • on mongocxx::database
    • create –  document that write concern must be set on database(for create_collection and create_view)
    • dropDatabase – document that write concern must be set on database
    • collMod – nothing; CXX-1058 will deprecate it
Comment by David Golden [ 11/Oct/16 ]

Summary of write concern support changes needed:

  • on mongocxx::collection
    • aggregate with $out – need to add to existing options
    • createIndexes – need to add to existing options
    • drop – new options class needed
    • renameCollection – new options class needed
  • on mongocxx::database
    • create – need to add to existing options (for create_collection and create_view)
    • dropDatabase – new options class needed
    • collMod – to be deprecated in mongocxx API
Comment by David Golden [ 16/Jun/16 ]

libmongoc 1.4.0 will add additional helper function variants that take write concern

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