Configuring a database query timeout
Problem
If database queries are taking too long to perform, and your application is becoming unresponsive, you can configure a timeout for database queries.
Cause
There is no default timeout in Confluence.
Resolution
If you are using PostgreSQL with driver version 8.3 or later Do Not set a query timeout as described below, as it will cause a SEVERE
error and prevent Confluence from starting.
You will need to reapply these changes when upgrading Confluence, as the original databaseSubsystemContext.xml
file changes from version to version.
To configure a database query timeout, do the following on your test server:
- Shut down Confluence.
- Extract
databaseSubsystemContext.xml
from theconfluence-x.x.x.jar
that is inconfluence/WEB-INF/lib/
, and put a copy inconfluence/WEB-INF/classes/
. See Editing files within .jar archives. Edit
confluence/WEB-INF/classes/databaseSubsystemContext.xml
to add the defaultTimeout property to the "transactionManager" bean:<bean id="transactionManager" class="org.springframework.orm.hibernate.HibernateTransactionManager"> <property name="sessionFactory"> <ref bean="sessionFactory"/> </property> <property name="defaultTimeout" value="120"/> </bean>
The timeout is measured in seconds and will forcibly abort queries that take longer than this. In some cases, these errors are not handled gracefully by Confluence and will result in the user seeing the Confluence error page.
- Start Confluence.
Once the timeout is working properly in your test environment, migrate the configuration change to your production Confluence environment.
Additional Information
- Configuring database query timeout – official documentation for this configuration
- CONF-13462 – feature request to allow configuration within the application.