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

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major - P3
    • Resolution: Fixed
    • 3.7.9
    • 4.0.0-rc0
    • 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

    Description

      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
      

      Attachments

        Issue Links

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved: