[DRIVERS-224] Implement findAndModify writeConcern support Created: 22/Apr/15  Updated: 15/Apr/19  Resolved: 21/Jun/16

Status: Closed
Project: Drivers
Component/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: David Golden Assignee: Barrie Segal
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
depends on CSHARP-1437 findAndModify take a write concern Closed
depends on CXX-692 findAndModify take a write concern Closed
depends on CXX-693 findAndModify take a write concern Closed
depends on JAVA-908 Support write concern for findAndModi... Closed
depends on PHPLIB-129 findAndModify take a write concern Closed
depends on PYTHON-989 findAndModify support for writeConcern Closed
depends on RUBY-1037 Support sending write concern to a fi... Closed
depends on RUST-20 Implement findAndModify writeConcern ... Closed
depends on NODE-549 findAndModify take a write concern Closed
Duplicate
is duplicated by DRIVERS-232 findAndModify accepts writeConcern Closed
Related
related to CDRIVER-824 collection_find_and_modify() should a... Closed
related to SERVER-6558 findAndModify should take a write con... Closed
Epic Link: PM-112
Driver Compliance:
Key Status/Resolution FixVersion
NODE-549 Done
PYTHON-989 Done 3.2
RUBY-1037 Done 2.2.0
JAVA-908 Done 2.14.0, 3.2.0
PERL-564 Done 1.2.0
SCALA-213 Won't Fix
PHPLIB-129 Done 1.0.0-beta2
CXX-692 Done legacy-1.1.0-rc0
CXX-693 Done 3.0.0-rc0
CSHARP-1437 Done 1.11, 2.2
PERL-597 Done 1.2.0
RUST-20 Duplicate

 Description   

The Write Concern specification details the specifics of adding write concern to your driver for findAndModify.

In short, when talking with server 3.2 or greater (maxWireVersion >=4), writeConcern should be added to the findAndModify command used from the CRUD spec helper methods findOneAndUpdate, findOneAndReplace, and findOneAndDelete.

Important Note:

When the writeConcern on findAndModify fails, the resulting document still comes back with ok: 1. This is the same as the write commands. 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 Andrew Morrow (Inactive) [ 17/Nov/15 ]

C++11 driver supports this only by changing the write concern at the collection level.

Comment by A. Jesse Jiryu Davis [ 22/Apr/15 ]

Got it. My druthers: bump the wire protocol version on the server side so we can detect whether findAndModify's write concern is honored or not, then raise error from the driver if user sends an explicit writeConcern with findAndModify on a pre-3.1 server. Better to raise an informative error than to silently ignore the user's desire for a certain level of durability to be acknowledged.

Comment by Bernie Hackett [ 22/Apr/15 ]

It doesn't look like older server versions raise when writeConcern is passed. I just tried this on 2.2.

Comment by A. Jesse Jiryu Davis [ 22/Apr/15 ]

Server behavior does change when we release new versions. For example, the aggregation framework didn't exist before 2.2. The "aggregate" helper method throws an error on server versions that don't support it.

Some driver architectures would make the emulation you propose very complex to implement for tiny benefit, if any. Better to specify that we throw an error if the user passes an explicit write concern to findAndModify on a server version that doesn't support it.

Generated at Thu Feb 08 08:21:02 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.