Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-28941

MatchExpressionWhere can discard errors when it's shallowCloned

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major - P3
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 3.5.7
    • Component/s: JavaScript, Querying
    • Labels:
      None
    • Backwards Compatibility:
      Fully Compatible
    • Operating System:
      ALL
    • Sprint:
      Platforms 2017-05-08
    • 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.

        Attachments

          Activity

            People

            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: