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

The nscanned and nscannedObjects is not correct for findAndModify

    • Type: Icon: Bug Bug
    • Resolution: Duplicate
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 2.6.5
    • Component/s: Querying, Write Ops
    • None
    • ALL
    • Hide

      Insert 100 documents to a collection, set logLevel to 1, and then run update and findAndModify command on the same document.

      > db.version()
      2.6.5
      > for (var i=0; i<100; i++) {db.docs.insert({x:i})}
      WriteResult({ "nInserted" : 1 })
      > db.adminCommand({setParameter:1, logLevel:1})
      { "was" : 0, "ok" : 1 }
      > db.docs.update({x:90}, {$set:{y:1}})
      WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 })
      > db.docs.findAndModify({query:{x:90}, update:{$set:{y:2}}})
      { "_id" : ObjectId("5461a43c0c8835a3ca5e1707"), "x" : 90, "y" : 1 }
      

      Check the verbose log, the nscanned and nscannedObjects are correct for the update command, however they are wrong for the findAndModify command.

      • Update:
        2014-11-11T16:53:11.048+1100 [conn6] update test.docs query: { x: 90.0 } update: { $set: { y: 1.0 } } nscanned:91 nscannedObjects:91 nMatched:1 nModified:1 keyUpdates:0 numYields:0 locks(micros) w:289 0ms
        
      • findAndModify
        2014-11-11T16:53:22.528+1100 [conn6] command test.$cmd command: findAndModify { findandmodify: "docs", query: { x: 90.0 }, update: { $set: { y: 2.0 } } } update: { $set: { y: 2.0 } } nscanned:1 nscannedObjects:1 nMatched:1 nModified:1 fastmod:1 keyUpdates:0 numYields:0 locks(micros) w:163 reslen:135 0ms
        
      Show
      Insert 100 documents to a collection, set logLevel to 1, and then run update and findAndModify command on the same document. > db.version() 2.6.5 > for ( var i=0; i<100; i++) {db.docs.insert({x:i})} WriteResult({ "nInserted" : 1 }) > db.adminCommand({setParameter:1, logLevel:1}) { "was" : 0, "ok" : 1 } > db.docs.update({x:90}, {$set:{y:1}}) WriteResult({ "nMatched" : 1, "nUpserted" : 0, "nModified" : 1 }) > db.docs.findAndModify({query:{x:90}, update:{$set:{y:2}}}) { "_id" : ObjectId( "5461a43c0c8835a3ca5e1707" ), "x" : 90, "y" : 1 } Check the verbose log, the nscanned and nscannedObjects are correct for the update command, however they are wrong for the findAndModify command. Update: 2014-11-11T16:53:11.048+1100 [conn6] update test.docs query: { x: 90.0 } update: { $set: { y: 1.0 } } nscanned:91 nscannedObjects:91 nMatched:1 nModified:1 keyUpdates:0 numYields:0 locks(micros) w:289 0ms findAndModify 2014-11-11T16:53:22.528+1100 [conn6] command test.$cmd command: findAndModify { findandmodify: "docs", query: { x: 90.0 }, update: { $set: { y: 2.0 } } } update: { $set: { y: 2.0 } } nscanned:1 nscannedObjects:1 nMatched:1 nModified:1 fastmod:1 keyUpdates:0 numYields:0 locks(micros) w:163 reslen:135 0ms
    • Quint Iteration 3.1.2, Quint Iteration 3

          Assignee:
          Unassigned Unassigned
          Reporter:
          linda.qin@mongodb.com Linda Qin
          Votes:
          0 Vote for this issue
          Watchers:
          11 Start watching this issue

            Created:
            Updated:
            Resolved: