[SERVER-12760] Running aggregation query with $explain in mixed setup causes assertion error Created: 18/Feb/14  Updated: 11/Jul/16  Resolved: 19/Feb/14

Status: Closed
Project: Core Server
Component/s: Sharding
Affects Version/s: 2.5.5
Fix Version/s: 2.6.0-rc0

Type: Bug Priority: Major - P3
Reporter: Ross Lawley Assignee: Mathias Stearn
Resolution: Done Votes: 0
Labels: 26qa
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
is related to SERVER-13050 Misleading error message with aggrega... Closed
Operating System: ALL
Steps To Reproduce:

Using: mongod 2.4, mongod 2.5.6-pre, mongoS 2.5.6-pre
With a sharded collection (I used a hashed _id shard key)
Run an aggregation command with $explain

In the shell run:

db.runCommand({ "aggregate" : "<sharded_collection>" , "pipeline" : [ { "$project" : { "a" : 1 }} ] , "explain" : true})
{
    "splitPipeline" : {
        "shardsPart" : [
            {
                "$project" : {
                    "a" : true
                }
            }
        ],
        "mergerPart" : [ ]
    },
    "shards" : {
        "shard0000" : {
            "host" : "precise64:27020",
            "stages" : [
                {
                    "$cursor" : {
                        "query" : {
 
                        },
                        "fields" : {
                            "a" : 1,
                            "_id" : 1
                        },
                        "plan" : {
                            "cursor" : "BasicCursor",
                            "isMultiKey" : false,
                            "scanAndOrder" : false,
                            "allPlans" : [
                                {
                                    "cursor" : "BasicCursor",
                                    "isMultiKey" : false,
                                    "scanAndOrder" : false
                                }
                            ]
                        }
                    }
                },
                {
                    "$project" : {
                        "a" : true
                    }
                }
            ]
        }
    },
    "code" : 0,
    "ok" : 0,
    "errmsg" : "exception: assertion src/mongo/bson/bsonobjbuilder.h:93"
}

The mongos logs:

014-02-18T12:59:46.835+0000 [conn1] pcursor finished on shard shard0001:precise64:27021, current connection state is { state: { conn: "(done)", vinfo: "mongo-java-driver-test.TEST @ 2|5||530354304b162de78a5666d2", cursor: { ok: 0.0, errmsg: "unrecognized field "cursor" }, count: 0, done: false }, retryNext: false, init: true, finish: true, errored: false }
2014-02-18T12:59:46.836+0000 [conn1] Assertion failure !e.eoo() src/mongo/bson/bsonobjbuilder.h 93
2014-02-18T12:59:46.839+0000 [conn1] 0xd61551 0xd0d089 0xcee7be 0x6d7811 0xb4fca9 0xc03fba 0xb4a18c 0xc28783 0xc01ccb 0x6dab41 0xd17fbb 0x7f2dedf31e9a 0x7f2ded244ccd
 ./bin/mongos(_ZN5mongo15printStackTraceERSo+0x21) [0xd61551]
 ./bin/mongos(_ZN5mongo10logContextEPKc+0x159) [0xd0d089]
 ./bin/mongos(_ZN5mongo12verifyFailedEPKcS1_j+0x17e) [0xcee7be]
 ./bin/mongos() [0x6d7811]
 ./bin/mongos(_ZN5mongo15dbgrid_pub_cmds15PipelineCommand3runERKSsRNS_7BSONObjEiRSsRNS_14BSONObjBuilderEb+0x1329) [0xb4fca9]
 ./bin/mongos(_ZN5mongo7Command22execCommandClientBasicEPS0_RNS_11ClientBasicEiPKcRNS_7BSONObjERNS_14BSONObjBuilderEb+0x2ba) [0xc03fba]
 ./bin/mongos(_ZN5mongo7Command20runAgainstRegisteredEPKcRNS_7BSONObjERNS_14BSONObjBuilderEi+0x32c) [0xb4a18c]
 ./bin/mongos(_ZN5mongo8Strategy15clientCommandOpERNS_7RequestE+0x303) [0xc28783]
 ./bin/mongos(_ZN5mongo7Request7processEi+0x6ab) [0xc01ccb]
 ./bin/mongos(_ZN5mongo21ShardedMessageHandler7processERNS_7MessageEPNS_21AbstractMessagingPortEPNS_9LastErrorE+0x71) [0x6dab41]
 ./bin/mongos(_ZN5mongo17PortMessageServer17handleIncomingMsgEPv+0x4fb) [0xd17fbb]
 /lib/x86_64-linux-gnu/libpthread.so.0(+0x7e9a) [0x7f2dedf31e9a]
 /lib/x86_64-linux-gnu/libc.so.6(clone+0x6d) [0x7f2ded244ccd]

Participants:

 Description   

When using $explain in a mixed cluster I get a exception: assertion src/mongo/bson/bsonobjbuilder.h:93 in the returned object and the logs don't look healthy.

However, when running with cursor which also isn't supported in 2.4 I get a nice error message:

db.runCommand({ "aggregate" : "<sharded_collection>" , "pipeline" : [ { "$project" : { "a" : 1 }} ] , "cursor" : { }})
{
    "code" : 17020,
    "ok" : 0,
    "errmsg" : "exception: All shards must support cursors to get a cursor back from aggregation"
}



 Comments   
Comment by Githook User [ 06/Mar/14 ]

Author:

{u'username': u'RedBeard0531', u'name': u'Mathias Stearn', u'email': u'mathias@10gen.com'}

Message: SERVER-13050 Don't send "cursor" to shards when doing agg explain

Follow up to SERVER-12760. If cursor is sent to the shards, the explain will
fail for the wrong reason and we would give a worse error message. With this
change we now correctly report that the explain failed because one of the
shards doesn't support explain.
Branch: master
https://github.com/mongodb/mongo/commit/3befa12b80bc656e72cd80669ceb5e799ba762ff

Comment by Mathias Stearn [ 19/Feb/14 ]

Pushed a change that should improve the error reporting.

Comment by Githook User [ 19/Feb/14 ]

Author:

{u'username': u'RedBeard0531', u'name': u'Mathias Stearn', u'email': u'mathias@10gen.com'}

Message: SERVER-12760 Handle sharded agg explain better during upgrade
Branch: master
https://github.com/mongodb/mongo/commit/00c7183b1a79b795f3d39c9079bb2f795c1cabb6

Comment by Ross Lawley [ 19/Feb/14 ]

> Is this only an issue during upgrade where explain isn't supported?
Yes, only observed it via a the mixed cluster.

Comment by Mathias Stearn [ 18/Feb/14 ]

$explain was accepted in 2.4, but it wasn't officially supported, largely because it was known to be broken when sharding. Is this only an issue during upgrade where explain isn't supported? I can probably make the error message better in this case though.

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