Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Does Liquibase within Spring Boot consider persistence query timeout

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?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

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).

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading