ISSUE SUMMARY
In MongoDB 2.6.4, when the profiler is enabled or when a slow query is logged, the number of nscanned and nscannedObjects may be incorrect for update operations when the query part of the update is just a simple equality on the _id field, for example {_id: 4}.
This issue does not appear when:
- The update query has predicates over multiple fields: {_id: 1, a: 3}
- The predicate over _id is not an equality: {_id: {$gt: 3}}
- The _id equality is for a non-simple type such as a nested object or a JavaScript code type: {_id: {a: "foo"}}
For example:
db.t.drop() db.t.insert( { _id :1, x : 1 } ) db.setProfilingLevel(2) for (i=0 ; i < 10; i++) { db.t.update( {_id:1}, {_id:1, y:i} ) } db.system.profile.find({op:"update"}, {nscanned: 1, nscannedObjects: 1}) { "nscanned" : 16802817, "nscannedObjects" : 2053731089 } { "nscanned" : 775237691, "nscannedObjects" : 724972601 } { "nscanned" : 775237692, "nscannedObjects" : 724972602 } { "nscanned" : 31796369, "nscannedObjects" : 2 } { "nscanned" : 31796370, "nscannedObjects" : 589827 } { "nscanned" : 1, "nscannedObjects" : 805306369 } { "nscanned" : 2, "nscannedObjects" : 393218 } { "nscanned" : 775237693, "nscannedObjects" : 724972603 } { "nscanned" : 3, "nscannedObjects" : 393219 } { "nscanned" : 4, "nscannedObjects" : 393220 }
USER IMPACT
Users may not be able to get correct information on update operations where the query part of the update is an equality on the _id field.
WORKAROUNDS
N/A
AFFECTED VERSIONS
MongoDB 2.6.4 is affected by this issue.
FIX VERSION
The fix is included in the 2.6.5 production release.
RESOLUTION DETAILS
Properly initialize nscanned and nscannedObjects in IDHackRunner.
Original description
nscanned and nscannedObjects for update (by _id) are incorrect when profiling is enabled in MongoDB 2.6.4
The issue is not reproducible in 2.6.3.
- is related to
-
SERVER-13764 debug mechanisms report incorrect nscanned / nscannedObjects for updates
- Closed