[SERVER-32712] CommandNotSupportedOnView error with aggregation on views Created: 16/Jan/18  Updated: 21/Mar/18  Resolved: 16/Feb/18

Status: Closed
Project: Core Server
Component/s: Aggregation Framework, Querying
Affects Version/s: 3.4.7
Fix Version/s: None

Type: Bug Priority: Major - P3
Reporter: yang feng Assignee: Mark Agarunov
Resolution: Incomplete Votes: 0
Labels: read-only-views
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

5 nodes with :
OS: RHEL 7.2 x64
CPU CORE COUNT: 5
RAM: 256GB
NIC: 1000 Mbps


Attachments: Text File aggregation_failed_on_views.log    
Operating System: ALL
Steps To Reproduce:

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.

Participants:

 Description   

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.



 Comments   
Comment by Kelsey Schubert [ 16/Feb/18 ]

Hi dy,

We haven’t heard back from you for some time, so I’m going to mark this ticket as resolved. If this is still an issue for you, please provide additional information and we will reopen the ticket.

Regards,
Kelsey

Comment by Mark Agarunov [ 01/Feb/18 ]

Hello dy,

We still need additional information to diagnose the problem. If this is still an issue for you, would you please provide:

  • The complete logs from all affected mongod and mongos nodes when this issue is present
  • An example of the structure of the documents that are being inserted?

Thanks,
Mark

Comment by Mark Agarunov [ 16/Jan/18 ]

Hello dy,

Thank you for the report. To get a better idea of what may be causing this error, could you please provide the complete logs from all affected mongod and mongos nodes when this issue is present? This should give some insight into why these commands are failing on views. Additionally could you please provide an example of the structure of the documents that are being inserted? This should help us reproduce the issue.

Thanks,
Mark

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