-
Type: Improvement
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: 1.1.1
-
Component/s: None
-
None
Quoting a comment from mongodb/mongo-php-library#326:
If the library can have a notion of an unset read concern, read preference, and write concern, that would allow us to not pass that around the selected objects (e.g. Database, Collection, Bucket) and inject it into each operation.
Currently, the library selects the read concern, read preference, and write concern after a MongoDB\Driver\Manager is constructed and passes that amongst its classes. As such, those classes have no way of knowing if the values were specified by a user or the driver's defaults. This is relevant for things like write concern, where the driver need not include a default write concern in commands.
There are some implications for libmongoc here. Although it always omits applying a default read concern (i.e. "{}") to queries, based on 3e34af3 (for CDRIVER-1527), it lacks equivalent logic for write concerns. CDRIVER-1322 included a function to detect default write concerns, but logic in 3e34af3 (also for CDRIVER-1527) appears to include a default write concern so long as the option is specified. Since PHPLIB currently always provides a write concern to commands, we do see it sent across the wire:
2017-01-17T16:40:59.966-0500 I COMMAND [conn1] command test.foo command: insert { insert: "foo", writeConcern: {}, ordered: true, documents: [ { x: 1, _id: ObjectId('587e8f6b6118fd4a0c5acbf2') } ] } ninserted:1 keysInserted:1 numYields:0 reslen:44 locks:{ Global: { acquireCount: { r: 3, w: 3 } }, Database: { acquireCount: { w: 2, W: 1 } }, Collection: { acquireCount: { w: 2 } } } protocol:op_query 3ms ... 2017-01-17T16:45:33.064-0500 I COMMAND [conn2] command test.foo command: findAndModify { findAndModify: "foo", new: false, upsert: false, query: { x: 1 }, update: { $set: { y: 1 } }, writeConcern: {} } planSummary: COLLSCAN update: { $set: { y: 1 } } keysExamined:0 docsExamined:1 nMatched:1 nModified:1 numYields:0 reslen:120 locks:{ Global: { acquireCount: { r: 1, w: 1 } }, Database: { acquireCount: { w: 1 } }, Collection: { acquireCount: { w: 1 } } } protocol:op_query 0ms
- depends on
-
CDRIVER-2206 Expose is_default() in public API for read and write concerns
- Closed
-
PHPC-976 Create isDefault() method for read and write concerns
- Closed
- is depended on by
-
PHPLIB-271 Implement accessors for options on core classes
- Closed
- related to
-
PHPLIB-710 Operations may ignore default write concern in favor of explicit client-level write concern
- Backlog
-
PHPC-834 Add Read, ReadWrite, and Write command execute methods
- Closed
-
CDRIVER-2273 Do not include default write concern in insert, update, and delete commands
- Closed
- links to