How concurrency/locking works on documents while passing mongoDB aggregation pipeline

Viewed 152

Consider we have two collection coll1 and coll2. I am applying some aggregation stages to the coll1

db.coll1.aggregate([
       { $match: { ... } },
       { $lookup:{
           from: "coll2",
           localField: "_id",
           foreignField: "_id",
           as: "coll2"
         }
       }
      // followed by other stages
       //last stage being $merge
        { $merge : { into: "coll3", on: "_id"} }
    ])

So, my query is:

  1. While the aggregation is in progress, is it possible the underlying collection, in this case coll1, is allowed to be modified/updated ? In either case, please help to understand how it works (went through mongoDb docs, but could not understand)
  2. How does it write the final coll3 ? In sense, does it write all in one shot or one document as it finish the pipeline ?
  3. In regards to spring-data-mongodb, I am successfully able to call mongoOperation.aggregate() for the above aggregation pipeline, but it returns aggregationResult object with Zero mappedResults.( When checked in db, coll3 is getting created). Does $merge not return any such details ?

I am using mongoDb 4.2

0 Answers
Related