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

mapReduce with output collection writes incorrect 'ns' to profiler

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.3.4
    • Component/s: 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));

      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.

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

              Created:
              Updated:
              Resolved: