Aggregation giving unable to decode message length due to I/O exception

I have a collection which has compound index on fields A,B and C. I have a usecase to fetch the record which have the latest update time for each of the set of A,B and C provided to us. For this I used the following aggreagation query.

db.students.aggregate([
  {
    $match: {
      $or: [
        {
          "A": "j2",
          "B": "b2",
          "C" : "c1"
        },
        {
          "journeyId": "j1",
          "blockId": "b1".
          "C" : "c2"
        }
      ]
    }
  },
  {
    $sort: {
      "lastUpdatedTime": -1
    }
  },
    {
    $group: {
      _id: "$journeyId",
      latestRecord: {
        $first: "$$ROOT"
      }
    }
  },
     { "$replaceRoot" : { "newRoot" : "$latestRecord"}}
]);

but while running this query getting the exception from the mongo server unable to decode message length due to I/O exception. What could be the reason for this. Also please explain how this query will be executed

Hi @Nishant_Kumar4 and welcome to the MongoDB community forum!!

In order to help you with a possible solution, we would need more information on the above mentioned exception.
Could you help us with few details on the deployment and the error message that you are observing.

  1. Can you help us with some sample data where the query has been used.
  2. Are you seeing the error while working on shell/Atlas/ Compass/Java application end?
  3. Do you observe any unusual messages in the mongod logs ? If yes, could you please share the same?
  4. What is the MongoDb version you are using?

Finally, could you help us with the desired output from the above query?

Best regards
Aasawari