Update Operation mongo working inconsistent

Query batchUpdateQuery = new Query(
			    Criteria.where("_id").is(orderId)
			        .and("batches").elemMatch(Criteria.where("_id").is(batchId))
			);
		  log.debug("batchUpdateQuery {} ", batchUpdateQuery.toString());
		  
		  Update batchUpdate = new Update().set("batches.$[item].status", batchStatus.name())
		          .filterArray(Criteria.where("item._id").is(batchId));
		  log.debug("batchUpdate {} ", batchUpdate.toString());
		  FindAndModifyOptions options = new FindAndModifyOptions().returnNew(true);
		  Order updatedOrder = mongoTemplate.findAndModify(batchUpdateQuery, batchUpdate, options, Order.class);
			log.debug("updatedOrder {} ", updatedOrder);

we are using above code for updating batch information in one collection only, but we are facing sometime
-but the query is printed correctly , all logs msg are printed correctly, yet few batch status update is getting missed
-is it bcz we are updating status of same collection , but we are not getting any exception or error msg also
Below is the issue seen with Mongo db. update operation.

The update of collection is not working consistently.

Example : One file is split into 14 batches of 10 records total 140 records.

So, update function is working for first few batches let’s say 10 batches to update the status of batch as completed, but rest 4 batch status is not getting updated and overall status of file remains in pending state.

We have tried a few different alternatives and solutions but still facing the same problem.

  1. We are using spring boot application with dependency as below.

    org.springframework.boot
    spring-boot-starter-data-mongodb
  2. spring boot version used

    org.springframework.boot
    spring-boot-starter-parent
    3.1.4

  3. connection string and properties set for mongoDBspring.data.mongodb.database=orders
    spring.data.mongodb.uri=mongodb+srv://{{mongodb.username}}:{{mongodb.password}}@{{mongodb.host}}/?retryWrites=true&w=majoritylogging.level.org.springframework.data.mongodb.repository.query= INFO
    logging.level.org.springframework.data.mongodb.core.MongoTemplate=INFO
  4. following is the class we use in spring boot used to perform operations on DB.import org.springframework.data.mongodb.repository.MongoRepository;

We don’t use any custom setup of JDBC / Java driver to make connection with DB. Everything is being handled by spring framework.