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

mapReduce with output collection writes incorrect 'ns' to profiler

    XMLWordPrintableJSON

Details

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: Major - P3 Major - P3
    • None
    • 3.3.4
    • Diagnostics, Querying
    • None
    • ALL
    • Hide

      var testDB = db.getSiblingDB("mr_db");
      assert.commandWorked(testDB.dropDatabase());
      var coll = testDB.getCollection("source_col");
       
      function getLatestProfilerEntry(inputDb) {
          var cursor = inputDb.system.profile.find();
          return cursor.sort({$natural: -1}).next();
      }
       
      testDB.setProfilingLevel(2);
       
      var mapFunction = function() {
          emit(this.a, this.b);
      };
       
      var reduceFunction = function(a, b) {
          return Array.sum(b);
      };
       
      coll.drop();
      for (var i = 0; i < 3; i++) {
          assert.writeOK(coll.insert({a: i, b: i}));
      }
       
      coll.mapReduce(mapFunction, reduceFunction, {query: {a: {$gte: 0}}, out: "out_col"});
       
      var profileObj = getLatestProfilerEntry(testDB);
      assert.eq(profileObj.ns, coll.getFullName(), tojson(profileObj));
      

      Show
      var testDB = db.getSiblingDB("mr_db"); assert.commandWorked(testDB.dropDatabase()); var coll = testDB.getCollection("source_col");   function getLatestProfilerEntry(inputDb) { var cursor = inputDb.system.profile.find(); return cursor.sort({$natural: -1}).next(); }   testDB.setProfilingLevel(2);   var mapFunction = function() { emit(this.a, this.b); };   var reduceFunction = function(a, b) { return Array.sum(b); };   coll.drop(); for (var i = 0; i < 3; i++) { assert.writeOK(coll.insert({a: i, b: i})); }   coll.mapReduce(mapFunction, reduceFunction, {query: {a: {$gte: 0}}, out: "out_col"});   var profileObj = getLatestProfilerEntry(testDB); assert.eq(profileObj.ns, coll.getFullName(), tojson(profileObj));

    Description

      When mapReduce is run with an output collection (and profiling enabled), the system.profile record written will have a 'ns' field reflecting the output collection namespace. The value for 'ns' should instead be the source collection namespace.

      Attachments

        Activity

          People

            david.storch@mongodb.com David Storch
            james.wahlin@mongodb.com James Wahlin
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: