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

mongos doesn't recognize the $facet stage

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 3.3.11
    • Affects Version/s: 3.3.9
    • Component/s: Aggregation Framework
    • None
    • Fully Compatible
    • ALL
    • Hide

      Run the $facet stage against a sharded cluster through mongos on a database for which sharding has been enabled.

      python buildscripts/resmoke.py --executor=sharding_jscore_passthrough jstests/aggregation/sources/facet/inner_lookup.js
      
      Output
      [js_test:inner_lookup] 2016-08-02T21:45:30.031-0400 2016-08-02T21:45:30.030-0400 E QUERY    [thread1] Error: command failed: {
      [js_test:inner_lookup] 2016-08-02T21:45:30.031-0400   "code" : 16436,
      [js_test:inner_lookup] 2016-08-02T21:45:30.031-0400   "ok" : 0,
      [js_test:inner_lookup] 2016-08-02T21:45:30.031-0400   "errmsg" : "Unrecognized pipeline stage name: '$facet'"
      [js_test:inner_lookup] 2016-08-02T21:45:30.031-0400 } : aggregate failed :
      [js_test:inner_lookup] 2016-08-02T21:45:30.031-0400 _getErrorWithCode@src/mongo/shell/utils.js:25:13
      [js_test:inner_lookup] 2016-08-02T21:45:30.031-0400 doassert@src/mongo/shell/assert.js:13:14
      [js_test:inner_lookup] 2016-08-02T21:45:30.031-0400 assert.commandWorked@src/mongo/shell/assert.js:264:5
      [js_test:inner_lookup] 2016-08-02T21:45:30.032-0400 DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1299:5
      [js_test:inner_lookup] 2016-08-02T21:45:30.032-0400 @jstests/aggregation/sources/facet/inner_lookup.js:25:34
      [js_test:inner_lookup] 2016-08-02T21:45:30.032-0400 @jstests/aggregation/sources/facet/inner_lookup.js:5:2
      [js_test:inner_lookup] 2016-08-02T21:45:30.032-0400
      [js_test:inner_lookup] 2016-08-02T21:45:30.032-0400 failed to load: jstests/aggregation/sources/facet/inner_lookup.js
      
      Show
      Run the $facet stage against a sharded cluster through mongos on a database for which sharding has been enabled. python buildscripts/resmoke.py --executor=sharding_jscore_passthrough jstests/aggregation/sources/facet/inner_lookup.js Output [js_test:inner_lookup] 2016-08-02T21:45:30.031-0400 2016-08-02T21:45:30.030-0400 E QUERY [thread1] Error: command failed: { [js_test:inner_lookup] 2016-08-02T21:45:30.031-0400 "code" : 16436, [js_test:inner_lookup] 2016-08-02T21:45:30.031-0400 "ok" : 0, [js_test:inner_lookup] 2016-08-02T21:45:30.031-0400 "errmsg" : "Unrecognized pipeline stage name: '$facet'" [js_test:inner_lookup] 2016-08-02T21:45:30.031-0400 } : aggregate failed : [js_test:inner_lookup] 2016-08-02T21:45:30.031-0400 _getErrorWithCode@src/mongo/shell/utils.js:25:13 [js_test:inner_lookup] 2016-08-02T21:45:30.031-0400 doassert@src/mongo/shell/assert.js:13:14 [js_test:inner_lookup] 2016-08-02T21:45:30.031-0400 assert.commandWorked@src/mongo/shell/assert.js:264:5 [js_test:inner_lookup] 2016-08-02T21:45:30.032-0400 DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1299:5 [js_test:inner_lookup] 2016-08-02T21:45:30.032-0400 @jstests/aggregation/sources/facet/inner_lookup.js:25:34 [js_test:inner_lookup] 2016-08-02T21:45:30.032-0400 @jstests/aggregation/sources/facet/inner_lookup.js:5:2 [js_test:inner_lookup] 2016-08-02T21:45:30.032-0400 [js_test:inner_lookup] 2016-08-02T21:45:30.032-0400 failed to load: jstests/aggregation/sources/facet/inner_lookup.js
    • Query 18 (08/05/16)

      The mongo/s/commands/cluster_commands library in mongos depends on the mongo/db/pipeline/pipeline library, which doesn't include the $facet stage. Since the $facet stage depends on both the pipeline and document_source libraries, it exists as its own document_source_facet library. We should change mongos to link against the mongo/db/pipeline/aggregation library instead.

      The jstests/aggregation/sources/facet/use_cases.js test runs the $facet stage against a sharded cluster through mongos, but failed to catch this issue for a couple of reasons:

      1. The implementation of the "aggregate" command in mongos skips parsing the pipeline when the database the command is being run on doesn't have sharding enabled.
      2. The test case for a $facet stage on a database with sharding enabled was expected to fail because it was designed to test that a $lookup on a sharded collection was still disallowed.

            Assignee:
            max.hirschhorn@mongodb.com Max Hirschhorn
            Reporter:
            max.hirschhorn@mongodb.com Max Hirschhorn
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: