[SERVER-13307] Server crash when a predicate inside $elemMatch value is not indexable Created: 21/Mar/14  Updated: 11/Jul/16  Resolved: 24/Mar/14

Status: Closed
Project: Core Server
Component/s: Querying
Affects Version/s: 2.5.5, 2.6.0-rc1
Fix Version/s: 2.6.0-rc3

Type: Bug Priority: Major - P3
Reporter: Steve Duan Assignee: David Storch
Resolution: Done Votes: 1
Labels: query
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

mac os x


Issue Links:
Related
is related to SERVER-12531 $not expression inside $elemMatch cau... Closed
Operating System: OS X
Participants:

 Description   

The $elemMatch value is considered indexable, causing the server to erroneously try to build index bounds for the "$size: 3" predicate.

> t = db.t
test.t
> t.drop()
2014-03-21T14:16:28.601-0400 trying reconnect to 127.0.0.1:27017 (127.0.0.1) failed
2014-03-21T14:16:28.602-0400 reconnect 127.0.0.1:27017 (127.0.0.1) ok
true
> t.ensureIndex({a: 1})
{
	"createdCollectionAutomatically" : true,
	"numIndexesBefore" : 1,
	"numIndexesAfter" : 2,
	"ok" : 1
}
> t.find({a: {$elemMatch: {$size: 3, $gt: 2}}})
2014-03-21T14:17:02.525-0400 DBClientCursor::init call() failed
Error: error doing query: failed



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

Author:

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

Message: SERVER-13307 do not try to index ELEM_MATCH_VALUE if a child predicate can't be indexed

(cherry picked from commit 9713848c54f3a0a25f9682d21a35179e6b8a3a86)
Branch: v2.6
https://github.com/mongodb/mongo/commit/96d25f6e3010da5ebc031f255df0cfc2680259c0

Comment by Githook User [ 24/Mar/14 ]

Author:

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

Message: SERVER-13307 do not try to index ELEM_MATCH_VALUE if a child predicate can't be indexed
Branch: master
https://github.com/mongodb/mongo/commit/9713848c54f3a0a25f9682d21a35179e6b8a3a86

Comment by David Storch [ 21/Mar/14 ]

Hi Steve, thanks for the bug report. I was able to reproduce this locally. I am going to replace the description of this ticket with the repro and get this triaged.

Comment by Steve Duan [ 21/Mar/14 ]

i'm still seeing this assert with latest code as of 03/21/2014. db version v2.7.0-pre- git version: 63fbd2ff4dbe5c80ad2c5ac1b35bc5b06e98a14b

2014-03-21T12:17:16.416-0400 [conn29] test.correctness0.878168563729 Assertion failure 0 src/mongo/db/query/index_bounds_builder.cpp 543
2014-03-21T12:17:16.431-0400 [conn29] test.correctness0.878168563729 0xe7ede3 0xe312d5 0xe17f42 0xb700d3 0xb6ee3a 0xb996b4 0xb99f86 0xbaae1b 0x9c2adf 0x9c4143 0x9c5aad 0x9b4529 0xb92dfe 0xb7ce74 0xa550e0 0x7a79e2 0xe4172d 0x7f5129a87efc
0x7f5129020f8d
bin/mongod(_ZN5mongo15printStackTraceERSo+0x23) [0xe7ede3]
bin/mongod(_ZN5mongo10logContextEPKc+0x1a5) [0xe312d5]
bin/mongod(_ZN5mongo12verifyFailedEPKcS1_j+0xc2) [0xe17f42]
bin/mongod(_ZN5mongo18IndexBoundsBuilder9translateEPKNS_15MatchExpressionERKNS_11BSONElementERKNS_10IndexEntryEPNS_19OrderedIntervalListEPNS0_15BoundsTightnessE+0x1493) [0xb700d3]
bin/mongod(_ZN5mongo18IndexBoundsBuilder9translateEPKNS_15MatchExpressionERKNS_11BSONElementERKNS_10IndexEntryEPNS_19OrderedIntervalListEPNS0_15BoundsTightnessE+0x1fa) [0xb6ee3a]
bin/mongod(_ZN5mongo18QueryPlannerAccess12makeLeafNodeERKNS_14CanonicalQueryERKNS_10IndexEntryEmPNS_15MatchExpressionEPNS_18IndexBoundsBuilder15BoundsTightnessE+0x524) [0xb996b4]
bin/mongod(_ZN5mongo18QueryPlannerAccess22buildIndexedDataAccessERKNS_14CanonicalQueryEPNS_15MatchExpressionEbRKSt6vectorINS_10IndexEntryESaIS7_EE+0x2a6) [0xb99f86]
bin/mongod(_ZN5mongo12QueryPlanner4planERKNS_14CanonicalQueryERKNS_18QueryPlannerParamsEPSt6vectorIPNS_13QuerySolutionESaIS9_EE+0x1e2b) [0xbaae1b]
bin/mongod(ZN5mongo21SortStageKeyGenerator16getBoundsForSortERKNS_7BSONObjES3+0x21f) [0x9c2adf]
bin/mongod(ZN5mongo21SortStageKeyGeneratorC2ERKNS_7BSONObjES3+0x8f3) [0x9c4143]
bin/mongod(_ZN5mongo9SortStage4workEPm+0x31d) [0x9c5aad]
bin/mongod(_ZN5mongo7OrStage4workEPm+0x189) [0x9b4529]
bin/mongod(_ZN5mongo12PlanExecutor7getNextEPNS_7BSONObjEPNS_7DiskLocE+0xde) [0xb92dfe]
bin/mongod(ZN5mongo11newRunQueryERNS_7MessageERNS_12QueryMessageERNS_5CurOpES1+0xc24) [0xb7ce74]
bin/mongod(_ZN5mongo16assembleResponseERNS_7MessageERNS_10DbResponseERKNS_11HostAndPortE+0xbf0) [0xa550e0]
bin/mongod(_ZN5mongo16MyMessageHandler7processERNS_7MessageEPNS_21AbstractMessagingPortEPNS_9LastErrorE+0x92) [0x7a79e2]
bin/mongod(_ZN5mongo17PortMessageServer17handleIncomingMsgEPv+0x4cd) [0xe4172d]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x7efc) [0x7f5129a87efc]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x6d) [0x7f5129020f8d]
2014-03-21T12:17:16.432-0400 [conn29] assertion 0 assertion src/mongo/db/query/index_bounds_builder.cpp:543 ns:test.correctness0.878168563729 query:{ $query: { 2: { $elemMatch:

{ $size: 5, $nin: [ "b" ] }

} }, $orderby:

{ 2: -1, A: 1 }

}
2014-03-21T12:17:16.432-0400 [conn29] ntoskip:0 ntoreturn:299
2014-03-21T12:17:16.436-0400 [conn29] end connection 127.0.0.1:48216 (0 connections now open)
2014-03-21T12:17:45.457-0400 [clientcursormon] mem (MB) res:61 virt:683
2014-03-21T12:17:45.457-0400 [clientcursormon] mapped (incl journal view):480
2014-03-21T12:17:45.457-0400 [clientcursormon] connections:0
2014-03-21T12:22:45.488-0400 [clientcursormon] mem (MB) res:61 virt:683
2014-03-21T12:22:45.488-0400 [clientcursormon] mapped (incl journal view):480
2014-03-21T12:22:45.488-0400 [clientcursormon] connections:0

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