In our Spring Boot 3 project, we want to use the following property to limit SQL query runtime to 2 mins:
spring.jpa.properties.jakarta.persistence.query.timeout=120000
We also use Liquibase for data migrations during service startup. Since we do not want to have this timeout for Liquibase run scripts: does Liquibase consider this property or does it ignore it?
Liquibase itself does not take Spring properties into account. Moreover, this is a JPA property configuring the connection between Spring and the database. Liquibase is not in the equation.
To configure a query timeout, you must do the Liquibase connection configuration: You can define the configuration in the JDBC connection, for example in liquibase.properties
:
url=jdbc:postgresql://localhost:5432/db?socketTimeout=120
Note the configuration is DB-specific. I guess Oracle or MySQL would use a different configuration for timeouts. Above is configuration for PostgreSQL.
Finally, you can test it out using a long-running query, ex. using pg_sleep
in PostgreSQL (learn more in this answer).