-
Type: Bug
-
Resolution: Gone away
-
Priority: Major - P3
-
None
-
Affects Version/s: 3.4.0
-
Component/s: Querying
-
Query
-
ALL
-
-
Query 2017-03-27
In ViewsShardingCheck, we make an assumption that the source namespace of a view must be a collection or a nonexistent namespace. But because of $collStats, it may in fact be a view, and this overeager assumption causes a failure when running a query over a view whose first stage is $collStats and whose "viewOn" is another view.
mongos> db.createView("v1", "v2", [{: {}}]) { "ok" : 1, "logicalTime" : { "clusterTime" : Timestamp(1491580269, 4), "signature" : { "hash" : BinData(0,"TC4eCke2sj28GEb7y236Nspy0ZE="), "keyId" : NumberLong(0) } }, "operationTime" : Timestamp(1491580269, 4) } mongos> db.createView("v2", "c", [{: {}}]) { "ok" : 1, "logicalTime" : { "clusterTime" : Timestamp(1491580277, 1), "signature" : { "hash" : BinData(0,"DYSY4YyCpNPs2tciTcRwkzusMLc="), "keyId" : NumberLong(0) } } } mongos> db.c.insert({x: 1}) WriteResult({ "nInserted" : 1 }) mongos> db.c.find() { "_id" : ObjectId("58e7b57d102c4c693c576c34"), "x" : 1 } mongos> db.v2.find() { "ns" : "test.c", "localTime" : ISODate("2017-04-07T15:51:32.358Z") } mongos> db.v1.find() Error: error: { "ok" : 0, "errmsg" : "Namespace test.v2 is a view, not a collection", "code" : 166, "codeName" : "CommandNotSupportedOnView", "logicalTime" : { "clusterTime" : Timestamp(1491580293, 1), "signature" : { "hash" : BinData(0,"3GtlKHmzhSsEx1vHk8I0Lz5F5E8="), "keyId" : NumberLong(0) } }, "operationTime" : Timestamp(0, 0) }
Original Description
When running an aggregation on a view that starts with $collStats and has a batchSize of 0, the following error occurs:
> db.runCommand( { aggregate: "view", pipeline: [ { $collStats: {} } ], cursor: { batchSize: 0 } } ) { "ok" : 0, "errmsg" : "Aggregation has more results than fit in initial batch, but can't create cursor since collection test.view doesn't exist", "code" : 17391, "codeName" : "Location17391" }
Either this should work as expected, or fail with a clearer error message.
- is related to
-
SERVER-22541 Aggregation plan executors should be owned by global cursor manager
- Closed
-
SERVER-27269 In sharded cluster, can't read from view whose pipeline has $collStats and is a view on another view
- Closed