-
Type:
Bug
-
Resolution: Incomplete
-
Priority:
Major - P3
-
None
-
Affects Version/s: 3.4.7
-
Component/s: Aggregation Framework, Querying
-
Environment:5 nodes with :
OS: RHEL 7.2 x64
CPU CORE COUNT: 5
RAM: 256GB
NIC: 1000 Mbps
-
ALL
-
-
None
-
3
-
None
-
None
-
None
-
None
-
None
-
None
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.