Query result not correctly sorted when using unwind and facet with concurrently inserts

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Works as Designed
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • None
    • None
    • None
    • None
    • None

      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

       

              Assignee:
              [DO NOT USE] Backlog - Query Execution
              Reporter:
              Micael Malta
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

                Created:
                Updated:
                Resolved: