Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-44151

Retryable write of findAndModify can return incorrect results when the 'fields' argument is specified

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Duplicate
    • Affects Version/s: 4.2.0
    • Fix Version/s: None
    • Component/s: Querying, Sharding
    • Labels:
      None
    • Operating System:
      ALL

      Description

       

       

      (function() {
      const t = db.find_and_modify;
      t.drop();
       
      assert.commandWorked(t.insert({x: 1, y: 1, z: 1}));
       
      let result = t.findAndModify({
          query: {x: 1},
          'new': false,
          update: {$set: {randomField: true}},
          fields: {x: 1, y: 1}
      });
      assert.eq(result.z, undefined);
      })(); 

      This test will succeed when run in the 'core' suite. When run in retryable_writes_jscore_passthrough which retries each write at least once, it will fail. This is because this code only fetches the preimage/postimage of the document from the oplog, but does not re-apply the 'fields' projection. This means that the entire pre-image/post-image will always be returned.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                0 Vote for this issue
                Watchers:
                5 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: