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

nscanned and nscannedObjects misreported for update() operations using BasicCursor

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: 2.6.1
    • Component/s: Logging
    • Labels:
      None
    • ALL
    • Hide
      var tdb = db.getSiblingDB("updateLogTest")
      var coll = tdb.getCollection("c");
      
      coll.drop();
      for (var i = 0; i < 1000; i++) coll.insert({val:i});
      
      tdb.setProfilingLevel(0);
      tdb.system.profile.drop();
      tdb.setProfilingLevel(2,0);
      tdb.adminCommand({setParameter:1, logLevel:1});
      
      coll.find({val:999});
      coll.update({val:999}, {$set: {val:1000}});
      
      tdb.adminCommand({setParameter:1, logLevel:0});
      tdb.setProfilingLevel(0,100);
      
      var spQuery = tdb.system.profile.findOne({ns:"updateLogTest.c", op:"query"});
      var spUpdate = tdb.system.profile.findOne({ns:"updateLogTest.c", op:"update"});
      
      assert.eq(1000, spQuery.nscanned);
      assert.eq(1000, spQuery.nscannedObjects);
      assert.eq(1000, spUpdate.nscanned);        // fails, nscanned == 1
      assert.eq(1000, spUpdate.nscannedObjects); // fails, nscannedObjects == 1
      
      Show
      var tdb = db.getSiblingDB( "updateLogTest" ) var coll = tdb.getCollection( "c" ); coll.drop(); for ( var i = 0; i < 1000; i++) coll.insert({val:i}); tdb.setProfilingLevel(0); tdb.system.profile.drop(); tdb.setProfilingLevel(2,0); tdb.adminCommand({setParameter:1, logLevel:1}); coll.find({val:999}); coll.update({val:999}, {$set: {val:1000}}); tdb.adminCommand({setParameter:1, logLevel:0}); tdb.setProfilingLevel(0,100); var spQuery = tdb.system.profile.findOne({ns: "updateLogTest.c" , op: "query" }); var spUpdate = tdb.system.profile.findOne({ns: "updateLogTest.c" , op: "update" }); assert.eq(1000, spQuery.nscanned); assert.eq(1000, spQuery.nscannedObjects); assert.eq(1000, spUpdate.nscanned); // fails, nscanned == 1 assert.eq(1000, spUpdate.nscannedObjects); // fails, nscannedObjects == 1

      update() reports nscanned = 1 and nscannedObjects = 1 when scanning 1000 documents to find the update target. find() reports nscanned = 1000 and nscannedObjects = 1000 for the identical query.

      The error appears in the system.profile collection and in the mongod log.

            Assignee:
            Unassigned Unassigned
            Reporter:
            norman.graham@mongodb.com Norman Graham (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: