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

    • Type: Icon: Improvement Improvement
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Component/s: None
    • Labels:
      None
    • $i18n.getText("admin.common.words.hide")
      Key Status/Resolution FixVersion
      JAVA-1134 Done 2.12.0
      PYTHON-647 Done 2.7
      CXX-20 Done legacy-0.9.0
      $i18n.getText("admin.common.words.show")
      #scriptField, #scriptField *{ border: 1px solid black; } #scriptField{ border-collapse: collapse; } #scriptField td { text-align: center; /* Center-align text in table cells */ } #scriptField td.key { text-align: left; /* Left-align text in the Key column */ } #scriptField a { text-decoration: none; /* Remove underlines from links */ border: none; /* Remove border from links */ } /* Add green background color to cells with FixVersion */ #scriptField td.hasFixVersion { background-color: #00FF00; /* Green color code */ } /* Center-align the first row headers */ #scriptField th { text-align: center; } Key Status/Resolution FixVersion JAVA-1134 Done 2.12.0 PYTHON-647 Done 2.7 CXX-20 Done legacy-0.9.0

      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.

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

              Created:
              Updated:
              Resolved: