-
Type: Bug
-
Resolution: Works as Designed
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: None
-
Query Execution
-
ALL
-
Query result are not correctly sorted when using unwind and facet when items are inserted concurrently
.aggregate( [ {"$match": {"_id": feed_id}}, { "$lookup": { "from": "items", "localField": "_id", "foreignField": "feed_id", "as": "items", } }, {"$unwind": "$items"}, { "$sort": { "_id": 1, }, }, { "$facet": { "result": [ {"$replaceRoot": {"newRoot": "$items"}}, {"$skip": offset}, {"$limit": limit}, ], "total": [ {"$count": "count"}, ], }, }, ], )
This result on a random order instead of ordering by items._id
If inserts are done sequentially, results are as expected
Environment:
Any MongoDB version