You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
09:52:54.176 DEBUG before aggregation
09:52:59.245 ERROR [...]MongoExecutionTimeoutException[...]
Please note that I get a MongoExecutionTimeoutException exactly 5s after I start the aggregation execution which is exactly as configured in the AggregationOptions via the maxTime option. Please also note that I executed the aggregation using the mongoTemplate.aggregate() method.
However, if I execute the same long-running aggregation using mongoTemplate.aggregateStream() instead:
10:02:36.662 DEBUG before aggregation
10:03:00.870 DEBUG after aggregation
Please note that no exception is thrown and I reach the debug log "after aggregation" even though the aggregation took around 24s which is a lot more than the configured 5s. My expectation would be that instead an exception should be thrown after 5s as for the aggregate() method.
Further hints
I did some further analysis and debugging and found out that in org.springframework.data.mongodb.core.MongoTemplate l2277 the AggregateIterable cursor's internal field maxTimeMS is still set to 0 even though the option's field maxTime field es properly set to "PT5s" and also delegate.sources[0].maxTime is "PT5s". I believe that either mongoTemplate itself or the delegate should copy all the aggregate options properly to the cursor.
As an experiment I manually called
cursor.maxTime(5000, TimeUnit.MILLISECONDS);
in l2277 using the debugger and after 5s I got the MongoExecutionTimeoutException as expected!
The text was updated successfully, but these errors were encountered:
mp911de
changed the title
AggregationOption 'maxTime' is ignored for MongoTemplate.aggregateStream() (but works for mongoTemplate.aggregate())AggregationOptions.maxTime ignored for MongoTemplate.aggregateStream()Feb 19, 2024
Dear spring-data-mongodb team,
I am using Spring Boot v3.2.2, hence spring-data-mongodb v4.2.2.
If I execute a long-running aggregation (>5s) with the following code
I see the following logs, as expected:
Please note that I get a MongoExecutionTimeoutException exactly 5s after I start the aggregation execution which is exactly as configured in the AggregationOptions via the maxTime option. Please also note that I executed the aggregation using the mongoTemplate.aggregate() method.
However, if I execute the same long-running aggregation using mongoTemplate.aggregateStream() instead:
I see the following logs:
Please note that no exception is thrown and I reach the debug log "after aggregation" even though the aggregation took around 24s which is a lot more than the configured 5s. My expectation would be that instead an exception should be thrown after 5s as for the aggregate() method.
Further hints
I did some further analysis and debugging and found out that in org.springframework.data.mongodb.core.MongoTemplate l2277 the AggregateIterable cursor's internal field
maxTimeMS
is still set to 0 even though the option's field maxTime field es properly set to "PT5s" and also delegate.sources[0].maxTime is "PT5s". I believe that either mongoTemplate itself or the delegate should copy all the aggregate options properly to the cursor.As an experiment I manually called
in l2277 using the debugger and after 5s I got the MongoExecutionTimeoutException as expected!
The text was updated successfully, but these errors were encountered: