Uploaded image for project: 'Drivers'
  1. Drivers
  2. DRIVERS-145

Don't include the nModified field in Bulk API results if talking to a legacy server via mongos

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Component/s: None
    • Labels:
      None

      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.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              barrie Barrie Segal
              Reporter:
              jesse A. Jesse Jiryu Davis
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: