Open
Description
JDK: Amazon Coretto 17.0.12
MongoDB version: 7.0.14
spring-data-mongodb version: 4.3.3
Sample code:
Criteria criteria = Criteria.where("name").is(name);
Query query = Query.query(criteria);
query.maxTimeMsec(5L);
Update update = Update.update("lastFetchedAt", new Date());
FindAndModifyOptions findAndModifyOptions = FindAndModifyOptions.options().returnNew(true);
return mongoTemplate.findAndModify(query, update, findAndModifyOptions, ExampleModel.class);
From the above, it is expected that the query to fetch the document should time out after 5ms, but this is not what happens. The maxTimeMsec set is ignored, and the document gets updated.
If the following command is run through mongosh:
db.runCommand({findAndModify: "example", query: {"name": "example100000"}, update: {"lastFetchedAt": new Date()}, maxTimeMS: 5})
we get the following error:
MongoServerError[MaxTimeMSExpired]: Plan executor error during findAndModify :: caused by :: operation exceeded time limit
This is similar to issue #4374, but here maxTimeMs cannot be carried forward to UpdateOptions.