[SERVER-12568] certain queries only provide disklocs for first batch of responses Created: 31/Jan/14  Updated: 29/Jan/15  Resolved: 29/Jan/15

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 2.4.8
Fix Version/s: None

Type: Bug Priority: Minor - P4
Reporter: Bruce Lucas (Inactive) Assignee: David Storch
Resolution: Duplicate Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Operating System: ALL
Steps To Reproduce:

Prepare the collection:

db.c.drop()
for (var i=0; i<5; i++)
    db.c.insert({})

Run the query, only gives disklocs for first batch:

db.c.find({}, {_id:1}).hint({_id:1}).batchSize(2).showDiskLoc().forEach(function(d) {
    printjson(d['$diskLoc'])
})
 
{ "file" : 0, "offset" : 1941680 }
{ "file" : 0, "offset" : 1941720 }
undefined
undefined
undefined

Use a BasicCursor instead and it works as expected:

db.c.find({}, {_id:1}).hint({$natural:1}).batchSize(2).showDiskLoc().forEach(function(d) {
    printjson(d['$diskLoc'])
})
 
{ "file" : 0, "offset" : 1941680 }
{ "file" : 0, "offset" : 1941720 }
{ "file" : 0, "offset" : 1941760 }
{ "file" : 0, "offset" : 1941800 }
{ "file" : 0, "offset" : 1941840 }

Or remove the projection and it also works as expected:

db.c.find({}).hint({_id:1}).batchSize(2).showDiskLoc().forEach(function(d) {
    printjson(d['$diskLoc'])
})
 
{ "file" : 0, "offset" : 1941680 }
{ "file" : 0, "offset" : 1941720 }
{ "file" : 0, "offset" : 1941760 }
{ "file" : 0, "offset" : 1941800 }
{ "file" : 0, "offset" : 1941840 }

Participants:

 Description   

Query using BtreeCursor over the _id index, do a projection, and request disklocs. The diskloc request is only honored for the first batch of responses.



 Comments   
Comment by David Storch [ 29/Jan/15 ]

This is fixed in 2.6 with the introduction of the new query system:

> db.version()
2.6.7
> db.c.drop()
true
> for (var i=0; i<5; i++) { db.c.insert({}); }
WriteResult({ "nInserted" : 1 })
> db.c.find({}, {_id:1}).hint({_id:1}).batchSize(2).showDiskLoc().forEach(function(d) {
...     printjson(d['$diskLoc'])
... })
{ "file" : 0, "offset" : 569520 }
{ "file" : 0, "offset" : 569584 }
{ "file" : 0, "offset" : 569648 }
{ "file" : 0, "offset" : 569712 }
{ "file" : 0, "offset" : 569776 }

Closing as a duplicate of SERVER-10026.

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