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

Converting an index to multikey is not visible within the same txn, causing incorrect data to be returned

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Major - P3 Major - P3
    • 4.0.0-rc0
    • Affects Version/s: 3.7.9
    • Component/s: Index Maintenance
    • None
    • Fully Compatible
    • ALL
    • Hide
      /*
       * Set up cluster.
       */
      var r = new ReplSetTest({nodes:2});
      r.startSet();r.initiate();
      
      var dbName = 'test';
      var collName = 'test';
      
      const sessionOptions = {causalConsistency: false};
      const session = r.getPrimary().startSession(sessionOptions);
      const sessionDb = session.getDatabase(dbName);
      const sessionColl = sessionDb.getCollection(collName);
      
      
      /*
       * Repro
       */
      assert.commandWorked(sessionDb.runCommand({create: collName, writeConcern: {w: "majority"}}));
      
      assert.writeOK(sessionColl.insert({a: 2}));
      assert.commandWorked(sessionColl.createIndex({a: 1}));
      r.awaitLastOpCommitted();
      
      session.startTransaction();
      assert.writeOK(sessionColl.update({}, {$set: {a: [2]}}));
      assert.eq({a: [2]}, sessionColl.findOne({a: 2}, {_id: 0, a: 1}));
      // session.commitTransaction();
      
      Show
      /* * Set up cluster. */ var r = new ReplSetTest({nodes:2}); r.startSet();r.initiate(); var dbName = 'test' ; var collName = 'test' ; const sessionOptions = {causalConsistency: false }; const session = r.getPrimary().startSession(sessionOptions); const sessionDb = session.getDatabase(dbName); const sessionColl = sessionDb.getCollection(collName); /* * Repro */ assert.commandWorked(sessionDb.runCommand({create: collName, writeConcern: {w: "majority" }})); assert.writeOK(sessionColl.insert({a: 2})); assert.commandWorked(sessionColl.createIndex({a: 1})); r.awaitLastOpCommitted(); session.startTransaction(); assert.writeOK(sessionColl.update({}, {$set: {a: [2]}})); assert.eq({a: [2]}, sessionColl.findOne({a: 2}, {_id: 0, a: 1})); // session.commitTransaction();
    • Storage NYC 2018-05-21
    • 36

      The update() call in the repro script is not visible, causing the assert.eq on the next line to fail:

      assert: [{ "a" : [ 2 ] }] != [{ "a" : 2 }] are not equal
      doassert@src/mongo/shell/assert.js:18:14
      assert.eq@src/mongo/shell/assert.js:174:1
      @test.js:21:1
      

            Assignee:
            daniel.gottlieb@mongodb.com Daniel Gottlieb (Inactive)
            Reporter:
            robert.guo@mongodb.com Robert Guo (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: