[DRIVERS-145] Don't include the nModified field in Bulk API results if talking to a legacy server via mongos Created: 10/Mar/14  Updated: 27/May/22  Resolved: 04/Oct/16

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

Type: Improvement Priority: Major - P3
Reporter: A. Jesse Jiryu Davis 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 SERVER-13210 nModified should be 0 when a write er... Closed
depends on CXX-20 Implement full support for write comm... Closed
depends on JAVA-1134 BulkWriteResult.getModifiedCount shou... Closed
depends on PYTHON-647 Omit nModified field from Bulk API re... Closed
Related
related to SERVER-13001 exclude nModified from legacy write r... Closed
is related to CDRIVER-293 Don't include the nModified field in ... Closed
is related to CSHARP-927 Don't include the nModified field in ... Closed
is related to NODE-151 Don't include the nModified field in ... Closed
is related to PHPLIB-50 Don't include the nModified field in ... Closed
is related to RUBY-729 Don't include the nModified field in ... Closed
Server Compat: 2.6
Driver Compliance:
Key Status/Resolution FixVersion
JAVA-1134 Done 2.12.0
PYTHON-647 Done 2.7
CXX-20 Done legacy-0.9.0

 Description   

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.



 Comments   
Comment by Andrew Morrow (Inactive) [ 03/Mar/15 ]

Validating for C++11 because validated for C

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