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

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Duplicate
    • Priority: Major - P3
    • None
    • Affects Version/s: 4.2.0
    • Component/s: Querying, Sharding
    • None
    • Query
    • ALL
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None
    • None

       

       

      (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.

              Assignee:
              Backlog - Query Team (Inactive)
              Reporter:
              Ian Boros
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

                Created:
                Updated:
                Resolved: