Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maxTimeMs in MongoTemplate.findAndModify(...) is not being honored. #4776

Open
sriram-1729 opened this issue Sep 2, 2024 · 1 comment · May be fixed by #4778
Open

maxTimeMs in MongoTemplate.findAndModify(...) is not being honored. #4776

sriram-1729 opened this issue Sep 2, 2024 · 1 comment · May be fixed by #4778
Assignees
Labels
type: bug A general bug

Comments

@sriram-1729
Copy link

sriram-1729 commented Sep 2, 2024

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.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 2, 2024
@christophstrobl
Copy link
Member

thank you for reporting - we'll have a look.

@christophstrobl christophstrobl self-assigned this Sep 3, 2024
@christophstrobl christophstrobl added type: bug A general bug and removed status: waiting-for-triage An issue we've not yet triaged labels Sep 4, 2024
sriram-1729 added a commit to sriram-1729/spring-data-mongodb that referenced this issue Sep 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug A general bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants