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

CommandNotSupportedOnView error with aggregation on views

    • Type: Icon: Bug Bug
    • Resolution: Incomplete
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: 3.4.7
    • Labels:
    • Environment:
      5 nodes with :
      OS: RHEL 7.2 x64
      CPU CORE COUNT: 5
      RAM: 256GB
      NIC: 1000 Mbps
    • ALL
    • Hide

      1. import lots of data( about 100 millions documents) into a sharded collection.
      2. create views on some collections.
      3. perform an aggregation on the view created.

      Show
      1. import lots of data( about 100 millions documents) into a sharded collection. 2. create views on some collections. 3. perform an aggregation on the view created.

      I got the "codeName" : "CommandNotSupportedOnView" error while doing aggregation on views. This occurs from time to time, most often when right after importing lots of data. For now, it seems that restarting the mongos will fixed it temporarily.

      view creation info from system.views:

      { "_id" : "loan_his.ci_basic_custinfo", "viewOn" : "ci_basic_custinfo_20180115_2", "pipeline" : [ ] }
      

      aggregation commands:

      db.ci_basic_custinfo.aggregate([{$limit:1}])
      

      return:

      assert: command failed: {
              "ok" : 0,
              "errmsg" : "Namespace loan_his.ci_basic_custinfo is a view, not a collection",
              "code" : 166,
              "codeName" : "CommandNotSupportedOnView"
      } : aggregate failed
      _getErrorWithCode@src/mongo/shell/utils.js:25:13
      doassert@src/mongo/shell/assert.js:16:14
      assert.commandWorked@src/mongo/shell/assert.js:370:5
      DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1319:5
      @(shell):1:1
      
      2018-01-12T00:22:42.767+0800 E QUERY    [thread1] Error: command failed: {
              "ok" : 0,
              "errmsg" : "Namespace loan_his.ci_basic_custinfo is a view, not a collection",
              "code" : 166,
              "codeName" : "CommandNotSupportedOnView"
      } : aggregate failed :
      _getErrorWithCode@src/mongo/shell/utils.js:25:13
      doassert@src/mongo/shell/assert.js:16:14
      assert.commandWorked@src/mongo/shell/assert.js:370:5
      DBCollection.prototype.aggregate@src/mongo/shell/collection.js:1319:5
      @(shell):1:1
      

      And:
      1. I also get the same error doing db.view.count(), but db.view.find() seems fine.
      2. Only restarting mongos can fix it, db.runCommand("flushRouterConfig") doesn't work.
      3. Sometimes the aggregation/count() would be working fine, but failed the next minute/second, and after a while it would miraculously recover.

      I have some views whose data needs to do a full collection refresh every day, for example there's a collection named "COL", I import the new data to a new collection name "COL_20180115" on 2018-01-15, then recreate the view named "COL" pointing to the daily new collection. Since renaming collection was not supported on sharded collections, using views was the only option I came up with.

            Assignee:
            mark.agarunov Mark Agarunov
            Reporter:
            dy yang feng
            Votes:
            0 Vote for this issue
            Watchers:
            10 Start watching this issue

              Created:
              Updated:
              Resolved: