[SERVER-16071] The nscanned and nscannedObjects is not correct for findAndModify Created: 11/Nov/14  Updated: 15/Dec/15  Resolved: 15/Dec/15

Status: Closed
Project: Core Server
Component/s: Querying, Write Ops
Affects Version/s: 2.6.5
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: Linda Qin Assignee: Unassigned
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Duplicate
duplicates SERVER-21772 findAndModify not captured by Profiler Closed
Related
is related to SERVER-16063 Rewrite findAndModify Closed
is related to SERVER-17862 Unify stats reporting for log/profile... Closed
Operating System: ALL
Steps To Reproduce:

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

Sprint: Quint Iteration 3.1.2, Quint Iteration 3
Participants:

 Comments   
Comment by David Storch [ 15/Dec/15 ]

This was fixed in 95c072ee0a3efd under SERVER-21772. Resolving as a duplicate.

Generated at Thu Feb 08 03:39:51 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.