-
Type:
Bug
-
Status: Closed
-
Priority:
Major - P3
-
Resolution: Fixed
-
Affects Version/s: 3.4.0-rc3
-
Component/s: Aggregation Framework
-
Labels:None
-
Backwards Compatibility:Fully Compatible
-
Operating System:ALL
-
Backport Completed:
-
Steps To Reproduce:
-
Sprint:Query 2016-12-12
Have a collection "teststructure" with the following documents:
/* 1 */
|
{
|
"_id" : ObjectId("58077488ff3d2f357d79b86c"),
|
"parent" : null,
|
"name" : "New York",
|
"type" : "city",
|
}
|
|
/* 2 */
|
{
|
"_id" : ObjectId("58077488ff3d2f357d79b86d"),
|
"parent" : ObjectId("58077488ff3d2f357d79b86c"),
|
"name" : "Building One",
|
"type" : "building"
|
}
|
|
/* 3 */
|
{
|
"_id" : ObjectId("58077488ff3d2f357d79b86e"),
|
"parent" : ObjectId("58077488ff3d2f357d79b86d"),
|
"name" : "Room 1",
|
"type" : "room"
|
}
|
Have a collection "objects" with the following documents that a reference field "ts" to a document from "teststructure" collection:
/* 1 */
|
{
|
"_id" : ObjectId("58077488ff3d2f357d79b891"),
|
"name" : "test1",
|
"ts" : ObjectId("58077488ff3d2f357d79b86e"),
|
"resource" : {
|
"rid" : "uuid1",
|
"cl" : "desks"
|
}
|
}
|
|
/* 2 */
|
{
|
"_id" : ObjectId("33065488ff3d2f357d70b753"),
|
"name" : "test2",
|
"ts" : ObjectId("58077488ff3d2f357d79b86e"),
|
"resource" : {
|
"rid" : "uuid2",
|
"cl" : "desks"
|
}
|
}
|
The following query (which should retrive recursivelly the desks that are assigned in leaf nodes - rooms) crashes mongodb service:
db.teststructure.aggregate([
|
{
|
$match: {
|
"_id": ObjectId('58077488ff3d2f357d79b86c') |
}
|
},
|
{
|
$graphLookup: {
|
from: "teststructure", |
startWith: ObjectId('58077488ff3d2f357d79b86c'), |
connectFromField: "_id", |
connectToField: "parent", |
maxDepth: parseInt(100),
|
as: "path", |
depthField: "depth" |
}
|
},
|
{
|
$graphLookup: {
|
from: "objects", |
startWith: { if: { $eq: ["$path.type", 'room'] }, then: ObjectId('58077488ff3d2f357d79b86c'), else: "$path._id" }, |
connectFromField: "_id", |
connectToField: "ts", |
maxDepth: parseInt(100),
|
as: "desks", |
depthField: "depth" |
}
|
}
|
])
|
Run the above query and mongodb crashes. More details (about logs) in steps to reproduce.
Then we have to manually restart mongodb server using "sudo service mongod restart".
The problem seems to be related with the usage of the conditional operator in startWith expression from $graphLookup.
- is related to
-
SERVER-25535 Remove injectExpressionContext() methods from pipeline directory
-
- Closed
-