-
Type: Improvement
-
Resolution: Done
-
Priority: Major - P3
-
None
-
Component/s: None
-
None
In DRIVERS-144, we omit nModified when doing Collection.update() against a legacy server.
In DRIVERS-143, we omit nModified when executing the Bulk API against a legacy server.
In this ticket, we sometimes omit nModified when executing the Bulk API against mongos 2.6 in a mixed-version cluster.
According to SERVER-13001, when a client executes an "update" command on a 2.6 mongos, and mongos executes it against some 2.4 mongods, mongos omits nModified from the response, or sets nModified to NULL. (We don't yet know which.)
If the client does a series of "update" commands within the same bulk operation against the same mongos, some responses could include nModified and some won't, depending on which mongods the mongos sent the operation to.
mongos follows this principle: nModified is 0 if you know it's 0. It's N if you know it's N. It's omitted or NULL if you don't know its true value. Drivers must follow this principle too.
The driver algorithm for merging results, when using write commands, follows in pseudocode:
full_result = { "writeErrors": [], "writeConcernErrors": [], "nInserted": 0, "nUpserted": 0, "nMatched": 0, "nModified": 0, "nRemoved": 0, "upserted": [], } for each server response in all bulk operations' responses: if the operation is an update: if the response has a non-NULL nModified: if full_result has a non-NULL nModified: full_result['nModified'] += response['nModified'] else: # If any call does not return nModified we can't report # a valid final count so omit the field completely. remove nModified from full_result or set to NULL
If you're merging results from the Bulk API when using legacy ops, of course, nModified is already omitted according to DRIVERS-143.
If you like, you can wait until SERVER-13001 is complete and we know whether mongos sets nModified to NULL or omits it.
This is going to require an additional QA ticket for all drivers.
- depends on
-
SERVER-13210 nModified should be 0 when a write error occurs.
- Closed
-
CXX-20 Implement full support for write commands
- Closed
-
JAVA-1134 BulkWriteResult.getModifiedCount should throw if server version < 2.6
- Closed
-
PYTHON-647 Omit nModified field from Bulk API results if legacy server
- Closed
- is related to
-
CDRIVER-293 Don't include the nModified field in Bulk API results if talking to a legacy server via mongos
- Closed
-
CSHARP-927 Don't include the nModified field in Bulk API results if talking to a legacy server via mongos
- Closed
-
NODE-151 Don't include the nModified field in Bulk API results if talking to a legacy server via mongos
- Closed
-
PHPLIB-50 Don't include the nModified field in Bulk API results if talking to a legacy server via mongos
- Closed
-
RUBY-729 Don't include the nModified field in Bulk API results if talking to a legacy server via mongos
- Closed
- related to
-
SERVER-13001 exclude nModified from legacy write results
- Closed