[SERVER-16052] $explain query against sharded collection with 2.6 shard returns error Created: 10/Nov/14  Updated: 11/Jul/16  Resolved: 12/Nov/14

Status: Closed
Project: Core Server
Component/s: Diagnostics, Sharding
Affects Version/s: 2.7.8
Fix Version/s: 2.8.0-rc1

Type: Bug Priority: Major - P3
Reporter: J Rassi Assignee: David Storch
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Tested
Operating System: ALL
Participants:

 Description   

Running an explain using the $explain query option returns "invalid parameter: expected an object" when run against a sharded collection with a 2.6 shard and 2.7.8 mongos.

rassi@rassi:~/work/mongo$ ~/mongodb-linux-x86_64-2.6.5/bin/mongod --fork --logpath /dev/null
about to fork child process, waiting until server is ready for connections.
forked process: 5847
child process started successfully, parent exiting
rassi@rassi:~/work/mongo$ ~/mongodb-linux-x86_64-2.7.8/bin/mongos --configdb=localhost:27017 --port 30000 --fork --logpath /dev/null
2014-11-10T13:29:28.120-0500 W SHARDING running with 1 config server should be done only for testing purposes and is not recommended for production
about to fork child process, waiting until server is ready for connections.
forked process: 5860
child process started successfully, parent exiting
rassi@rassi:~/work/mongo$ ~/mongodb-linux-x86_64-2.6.5/bin/mongo --port 30000
MongoDB shell version: 2.6.5
connecting to: 127.0.0.1:30000/test
Server has startup warnings:
2014-11-10T13:29:28.125-0500 I -
2014-11-10T13:29:28.125-0500 I -        ** NOTE: This is a development version (2.7.8) of MongoDB.
2014-11-10T13:29:28.125-0500 I -        **       Not recommended for production.
2014-11-10T13:29:28.125-0500 I -
mongos> sh.addShard("localhost:27017")
{ "shardAdded" : "shard0000", "ok" : 1 }
mongos> sh.enableSharding("test")
{ "ok" : 1 }
mongos> sh.shardCollection("test.foo", {_id: 1})
{ "collectionsharded" : "test.foo", "ok" : 1 }
mongos> db.foo.find().explain()
2014-11-10T13:30:21.666-0500 error: { "$err" : "invalid parameter: expected an object ()", "code" : 10065 } at src/mongo/shell/query.js:131



 Comments   
Comment by Githook User [ 12/Nov/14 ]

Author:

{u'username': u'dstorch', u'name': u'David Storch', u'email': u'david.storch@10gen.com'}

Message: SERVER-16052 fix $explain queries for clusters with shards at version 2.6 or earlier
Branch: master
https://github.com/mongodb/mongo/commit/8f6c27d5200352d3e26cbefeac627c0b77654aa5

Comment by J Rassi [ 10/Nov/14 ]

In parallel.cpp:183, the "executionStats" element from the shard explain output is examined without first checking for its existence.

parallel.cpp:
   178	                        if (temp.hasField("nscannedObjects")) {
   179	                            docsExamined += temp["nscannedObjects"].numberLong();
   180	                        }
   181	                    }
   182
   183	                    millis += temp["executionStats"]["executionTimeMillis"].numberLong();
   184	                    numExplains++;
   185	                }
   186	                y.done();
   187	            }
   188	            x.done();

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