JIRA 4.3 : Surviving Connection Closures
This page last changed on Apr 08, 2010 by rosie@atlassian.com.
When a database server reboots, or there is a network failure, all the connections in the connection pool are broken and this normally requires a Application Server reboot. However, the Commons DBCP (Database Connection Pool) which is used by the Tomcat application server (and hence JIRA Standalone) can validate connections before issuing them by running a simple SQL query, and if a broken connection is detected, a new one is created to replace it. To do this, you will need to set the "validationQuery" option on the database connection pool.
Determining the Validation QueryEach database has slightly different SQL syntax. The Validation Query should be as simple as possible, as this is run every time a connection is retrieved from the pool.
Setting the validationQuery parameterIn your application server, where the JDBC DataSource is configured, a parameter needs to be added to tell the Connection Pool to use a validation query (determined above) to validate connections. JIRA Standalone (after version 3.2) or JIRA EAR/WAR on Tomcat 5.5 and Tomcat 6.0If you are using JIRA Standalone, edit conf/server.xml Locate the section where the 'jdbc/JiraDS' DataSource is set up, and add the following:
For example (for MySQL): <Resource name="jdbc/JiraDS" auth="Container" type="javax.sql.DataSource" driverClassName="com.mysql.jdbc.Driver" url="jdbc:mysql://localhost/jiradb?useUnicode=true&characterEncoding=UTF8" username="jirauser" password="jirapassword" maxActive="20" validationQuery="select 1" /> Tomcat 4 and 5.0:Edit conf/server.xml (Tomcat 4) or conf/Catalina/localhost/jira.xml (Tomcat 5.0), locate the section where the 'jdbc/JiraDS' DataSource is set up, and add the following:
For example: <Resource name="jdbc/JiraDS" auth="Container" type="javax.sql.DataSource"/> <ResourceParams name="jdbc/JiraDS"> <parameter> <name>driverClassName</name> <value>oracle.jdbc.driver.OracleDriver</value> </parameter> <parameter> <name>url</name> <value>jdbc:oracle:thin:@<database host machine>:<port>:<SID></value> </parameter> <parameter> <name>username</name> <value>...</value> </parameter> <parameter> <name>password</name> <value>...</value> </parameter> <parameter> <name>validationQuery</name> <value>select 1</value> </parameter> <parameter> <name>factory</name> <value>org.apache.commons.dbcp.BasicDataSourceFactory</value> </parameter> </ResourceParams> Orion / OC4JFor Orion/OC4J, edit config/data-sources.xml, and add the property as a nested tag: <data-source class="<datasource driver class>" name="<name>" location="<location>" xa-location="<xa-location>" ejb-location="<ejb-location>" url="<url>" connection-driver="<driver>" username="<login>" password="<password>" inactivity-timeout="30" > <property name="validationQuery" value="Select 1" /> </data-source> Other app serversConsult the relevant JIRA app server guide and the app server documentation to find how to add the property. ResultsYou should now be able to survive a complete loss of all connections and be able to recover without rebooting the your App Server. |
![]() |
Document generated by Confluence on Mar 27, 2011 18:52 |