Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-88379

Poor error message with bad $merge whenMatched Pipeline

    • Type: Icon: Task Task
    • Resolution: Unresolved
    • Priority: Icon: Major - P3 Major - P3
    • None
    • Affects Version/s: None
    • Component/s: None
    • Sprint 45, Sprint 47, Sprint 54

      This $merge pipeline is bad, but the user does not get an error that makes sense for it.

      MongoServerError[CommandFailed]: Failed to get stream processor results: could not get resources for stream processor: ObjectID("65fc502c939d9731dbf91d74"), correlationID = 17bed0bde7c19b2cc15655ec
      
      AtlasStreamProcessing>  

      using the following

      db.createCollection("gps")db.createCollection("gps_array_push")db.gps_array_push.createIndex({"vehicle_id": 1}, {unique: true})
      var cols = db.getCollectionNames()
      for (const el of cols){    db.runCommand( {        collMod: "gps",        changeStreamPreAndPostImages: { enabled: true }    } )}
      db.gps.insertOne({ "vehicle_id": "vid0001", "coord": [37.76643495, -122.3969431 ],  })db.gps.insertOne({ "vehicle_id": "vid0001", "coord": [38.76643495, -123.3969431 ],  })db.gps.insertOne({ "vehicle_id": "vid0001", "coord": [39.76643495, -124.3969431 ],  })db.gps.insertOne({ "vehicle_id": "vid0001", "coord": [40.76643495, -125.3969431 ],  })
      
      
      s = {    $source:  {        connectionName: 'jsncluster0',        db: 'test',        coll: 'gps',        config : {          fullDocument: 'whenAvailable',        },      }}rr =   {    $replaceRoot: { newRoot : "$fullDocument"} }
       af = {$addFields : { "gps_array" : [{"coord" : "$coord"}]}}
       un = {$unset : ["coord"]}
       m = {$merge : {  into: {      connectionName: "jsncluster0",      db: "test",      coll: "gps_array_push"},      on: ["vehicle_id"],      let : {event_array : "$gps_array"},      whenMatched : [ { $push: { gps_array: "$$event_array" }}],     whenNotMatched: "insert"}}
      sp.process([s,rr,af,un,m]) 

            Assignee:
            sandeep.dhoot@mongodb.com Sandeep Dhoot
            Reporter:
            joe.niemiec@mongodb.com Joe Niemiec
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: