[SERVER-28941] MatchExpressionWhere can discard errors when it's shallowCloned Created: 24/Apr/17  Updated: 30/Oct/23  Resolved: 01/May/17

Status: Closed
Project: Core Server
Component/s: JavaScript, Querying
Affects Version/s: None
Fix Version/s: 3.5.7

Type: Bug Priority: Major - P3
Reporter: Jonathan Reams Assignee: Jonathan Reams
Resolution: Fixed Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
Backwards Compatibility: Fully Compatible
Operating System: ALL
Sprint: Platforms 2017-05-08
Participants:
Linked BF Score: 0

 Description   

This was uncovered by BF-3588:

[ReplicaSetFixture:job15:primary] 2017-03-16T17:57:56.018+0000 I COMMAND  [conn36] command test.max_time_ms appName: "MongoDB Shell" command: find { find: "max_time_ms", filter: { $where: function () {
[ReplicaSetFixture:job15:primary]         if (this.slow) {
[ReplicaSetFixture:job15:primary]             sleep(2 * 1000);
[ReplicaSetFixture:job15:primary]   ... }, batchSize: 3.0, maxTimeMS: 2000.0 } planSummary: COLLSCAN exception: $where compile error code:28692 numYields:0 reslen:191 locks:{ Global: { acquireCount: { r: 6 } }, MMAPV1Journal: { acquireCount: { r: 2 } }, Database: { acquireCount: { r: 3 } }, Collection: { acquireCount: { R: 3 } } } protocol:op_command 2269ms
[js_test:max_time_ms] 2017-03-16T17:57:56.073+0000 	"operationTime" : Timestamp(1489687073, 17),
[js_test:max_time_ms] 2017-03-16T17:57:56.077+0000 	"ok" : 0,
[js_test:max_time_ms] 2017-03-16T17:57:56.078+0000 	"errmsg" : "$where compile error",
[js_test:max_time_ms] 2017-03-16T17:57:56.078+0000 	"code" : 28692,
[js_test:max_time_ms] 2017-03-16T17:57:56.079+0000 	"codeName" : "Location28692"
[js_test:max_time_ms] 2017-03-16T17:57:56.080+0000 } : expected batch 1 (query) to not hit the time limit
[js_test:max_time_ms] 2017-03-16T17:57:56.080+0000 doassert@src/mongo/shell/assert.js:18:14
[js_test:max_time_ms] 2017-03-16T17:57:56.080+0000 assert.doesNotThrow@src/mongo/shell/assert.js:363:13
[js_test:max_time_ms] 2017-03-16T17:57:56.081+0000 @jstests/core/max_time_ms.js:363:1

The failure is a uassert failure that happens at the top of bool WhereMatchExpression::matches(const MatchableDocument* doc, MatchDetails* details), which is after the javascript function is actually compiled in Status WhereMatchExpression::init(StringData dbName).

In Status WhereMatchExpression::init(StringData dbName), if the javascript engine actually failed to compile the function, I think you'd get a javascript-specific error code rather than "$where compile error". In fact, I can't see a way for you to ever have _func == 0 unless init had failed and its error silently discarded.

The only place that we call init and silently discard its error is in the unique_ptr<MatchExpression> WhereMatchExpression::shallowClone() function.



 Comments   
Comment by Githook User [ 01/May/17 ]

Author:

{u'username': u'jbreams', u'name': u'Jonathan Reams', u'email': u'jbreams@mongodb.com'}

Message: SERVER-28941 MatchExpressionWhere can discard errors when it's shallowCloned
Branch: master
https://github.com/mongodb/mongo/commit/8665131a118e9515fc18ba0d41dcc773874f1529

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