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

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

       

       

      (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-server-query Backlog - Query Team (Inactive)
            Reporter:
            ian.boros@mongodb.com Ian Boros
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: