Reputation: 51
I am using spring-boot-starter-data-jpa from Spring Boot 2.0.2.RELEASE, using spring-data-jpa. DB is Oracle. JDK 1.8.
I am using @Transactional
on top of a method that is calling a long-running query. When the transaction timeout is set to 1, the transaction is timing out within 1 second. When @Transaction
nis to timeout > 1, there is no timeout exception. The query runs we get the response. Here is a snapshot of my code:
@Transactional(propagation = Propagation.REQUIRES_NEW, timeout = 5)
public List<Pojo> doStuff() {
result = myRepository.findDetails(); -- This call long running native query
...
}
Strangely, this works when the app is run in debug mode and a breakpoint is kept at the call to repository method. I have tried the following
javax.persistence.query.timeout
with hint also did not timeoutserver.connection-timeout=3s
- did not workspring.jpa.properties.javax.persistence.query.timeout=10
- did not workoracle.jdbc.ReadTimeout
- works but does not timeout at the specified time.If 100 is mentioned then it sometimes throws exception in 1 mins sometimes less/more. We are getting response from DB after 5 mins. We would like to timeout before that and send timeout response to the client.
Upvotes: 3
Views: 1664