[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: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Epic Link: | PM-112 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Driver Compliance: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 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. |