-
Type:
Bug
-
Resolution: Fixed
-
Priority:
Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Query Execution
-
Minor Change
-
ALL
-
None
-
None
-
None
-
None
-
None
-
None
-
None
mongos returns an empty cursor with this aggregation when the db does not exist.
db.aggregate([{$match: {size: "medium"}}, {$documents: [{_id: 1, size: "medium"}, {_id: 2}]}]);
This command should return an error since $documents can only be used in the first stage in a pipeline.
Additionally, mongos will return an empty cursor with this aggregation. This aggregation should also raise an error since $unionWith must be used with a collection.
db.aggregate([
{
$unionWith: {
pipeline: [{ $documents: {$map: {input: {$range: [0, 5]}, in : {x: "$$this"}}}}]
}
},
{ $group: {_id: "$x", x: {$first: "$x"}}},
{ $project: {_id: 0}},
])
.toArray();
Discovered in SERVER-63811. The empty cursor is being returned by this logic:
if (executionNsRoutingInfoStatus.isOK()) {
cm = std::move(executionNsRoutingInfoStatus.getValue());
} else if (!(hasChangeStream &&
executionNsRoutingInfoStatus == ErrorCodes::NamespaceNotFound)) {
appendEmptyResultSetWithStatus(
opCtx, namespaces.requestedNss, executionNsRoutingInfoStatus.getStatus(), result);
return Status::OK();
}
However validation checks should have occurred before this logic and returned an error.
- is depended on by
-
COMPASS-7278 Investigate changes in SERVER-69836: mongos doesn't raise validation errors but returns empty cursors when the database doesn't exist
-
- Closed
-
- is related to
-
SERVER-63811 mongos returns no results for $documents if the database doesn't exist
-
- Closed
-
- related to
-
SERVER-82045 Make $merge inside a $lookup behave the same in replicaset and sharded cluster when db does not exists
-
- Closed
-
-
SERVER-94144 [v7.0] $documents inside $lookup fails to parse with QueryStats
-
- Closed
-