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.
Please note, that setting the |
Each 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.
Some examples are:
データベース |
バリデーションクエリ |
|---|---|
MySQL |
select 1 |
MS SQL Server |
select 1 |
Oracle |
select 1 from dual |
Postgres |
select version(); |
In 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.
If you are using JIRA Standalone, edit conf/server.xml
If you are using JIRA EAR/WAR on Tomcat 5.5 or Tomcat 6.0, edit conf/Catalina/localhost/jira.xml
Locate the section where the 'jdbc/JiraDS' DataSource is set up, and add the following:
validationQuery="select 1"validationQuery="select 1 from dual"validationQuery="select version();"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" />
|
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:
<parameter> <name>validationQuery</name> <value>select 1</value> </parameter> |
<parameter> <name>validationQuery</name> <value>select 1 from dual</value> </parameter> |
例:
<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> |
For 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> |
Consult the relevant JIRA app server guide and the app server documentation to find how to add the property.
You should now be able to survive a complete loss of all connections and be able to recover without rebooting the your App Server.