Aggregation may fail with QueryPlanKilled if the targeted collection has been recently created

XMLWordPrintableJSON

    • Type: Bug
    • Resolution: Works as Designed
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • None
    • Catalog and Routing
    • ALL
    • 200
    • 🟦 Shard Catalog
    • None
    • None
    • None
    • None
    • None
    • None

      An aggregation that runs against a collection that has been recently created or that is concurrently created may fail with QueryPlanKilled.

      This is the sequence of operations run in a jstest that has triggered the error. The aggregation uses $out, but we assume the issue would occur with any aggregation that is not collectionless.

      // create the collection through an insert with write concern {w:1}
      coll.insert({x:1}, {writeConcern: {w:1}})
      
      // run aggregation with readConcern: 'majority'
      coll.aggregate([{$match: {}},{$out: "collOut"}], {readConcern: {level:'majority'}})
      

      Reasoning

      During aggregation, all involved collections are acquired up front, then released, and re-acquired when pipeline execution starts.
      It could happen that the aggregation's target collection appears only after the second acquisition. At that point, the operation would fail with QueryPlanKilled, because a collection participating in the aggregation cannot be created while the aggregation is in progress.

            Assignee:
            Unassigned
            Reporter:
            Silvia Surroca
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: