Documentation for JIRA 5.1.x. Documentation for other versions of JIRA is available too.

データベースサーバがリブートしたり、あるいはネットワーク障害が発生すると、データベースのコネクションプール内の全てのコネクションが切断され ます。通常、この問題を乗り越えるには、JIRA の再起動を行います(JIRA WAR ディストリビューションにおいては、JIRA を実行しているアプリケーションサーバを再起動する必要があります)。

しかし、単純な SQL クエリの実行によって、データベースのコネクションプール内のコネクションを有効にすることができます。プール内で切断されたデータベースコネクションが検出されると、新しいものが作成されてこれに置き替えられます。

To do this, you need to specify an optional <validation-query/> element (in the dbconfig.xml file of your JIRA Home Directory), whose content is the query which validates connections in the database connection pool. See the following procedure for details.

JIRA がデータベースコネクションを確実に有効にする方法

JIRA がデータベースのコネクションプール内のデータベースコネクションを確実に有効にするには:

  1. JIRA をシャットダウンします(もしくは JIRA を実行中の Tomcat インストレーション)
  2. Edit the dbconfig.xml file at the root of your JIRA Home Directory or use the Advanced tab of the JIRA Configuration Tool to configure the relevant settings.
  3. お使いのデータベース向けのバリデーションクエリを設定します:
    • If editing the dbconfig.xml file, add the <validation-query/> element with the appropriate validation query for your type of database, as shown in the example below for MySQL. (See Determining the Validation Query below for details.)

      <?xml version="1.0" encoding="UTF-8"?>
       
      <jira-database-config>
       <name>defaultDS</name>
       <delegator-name>default</delegator-name>
       <database-type>mysql</database-type>
       <jdbc-datasource>
       <url>jdbc:mysql://dbserver:3306/jiradb?useUnicode=true&amp;characterEncoding=UTF8&amp;sessionVariables=storage_engine=InnoDB</url>
       <driver-class>com.mysql.jdbc.Driver</driver-class>
       <username>jiradbuser</username>
       <password>password</password>
       <pool-min-size>20</pool-min-size>
       <pool-max-size>20</pool-max-size>
       <pool-max-wait>30000</pool-max-wait>
       
       <validation-query>select 1</validation-query>
       <min-evictable-idle-time-millis>60000</min-evictable-idle-time-millis>
       <time-between-eviction-runs-millis>300000</time-between-eviction-runs-millis>
       
       <pool-max-idle>20</pool-max-idle>
       <pool-remove-abandoned>true</pool-remove-abandoned>
       <pool-remove-abandoned-timeout>300</pool-remove-abandoned-timeout>
       
       <pool-test-while-idle>true</pool-test-while-idle>
       <validation-query-timeout>3</validation-query-timeout>
       
       </jdbc-datasource>
      </jira-database-config>
      
    • JIRA 設定ツール を利用している場合は、Advanced タブから、Validation Query のチェックボックスを選択して、お使いのデータベースの種類に適したバリデーションクエリを入力します (以下の バリデーションクエリの決定 を参照して下さい。)
  4. バリデーションクエリのタイムアウトを指定します。この値は、データベースコネクションが切断されたものとシステムが判断するまで、システムが待機しなくてはならない適当な時間 (秒単位) となります:
    • dbconfig.xml ファイルを編集する場合は、<validation-query-timeout/> 要素を適切な時間の長さ (秒単位) で追加します。
    • JIRA 設定ツール を利用している場合は、Advanced タブから、Validation Query Timeout のチェックボックスを選択し、適切な時間の長さ(秒単位)を入力します
  5. 上述のバリデーションクエリのオプションに関連する、以下のオプションを指定しても結構です(詳しくは データベース接続のチューニング - コネクションプールの設定 を参照して下さい):

    JIRA 設定ツール 'Advanced' タブオプション

    dbconfig.xml の要素

    アイドル状態にテストpool-test-while-idle
    追い出し実行間の時間time-between-eviction-runs-millis
    追い出し可能な最小限のアイドル時間min-evictable-idle-time-millis
  6. Save your edited dbconfig.xml file (or click the Save button if using the JIRA Configuration Tool).

  7. JIRA (もしくは、JIRA を実行している Tomcat) を再起動します。

(info) Please Note: If you continue to have problems with connections closing, you may need to set the time-between-eviction-runs-millis parameter to a lower value or as a last resort, set test-on-borrow to true. For more information about test-on-borrow, see Tuning Database Connections - Connection pool settings section.

Determining the validation query

各データベースの種類におけるバリデーションクエリは、それぞれ若干異なる SQL 構文の条件を有しています。バリデーションクエリは、プールからコネクションが回収される度に実行されるため、可能な限りシンプルなものが臨まれます。

各バリデーションクエリに推奨されるバリデーションクエリを以下に紹介します。:

データベースタイプ

バリデーションクエリ

MySQL

select 1

Microsoft SQL Server

select 1

Oracle

select 1 from dual

PostgreSQL

select version();

結果

これで、データベースのコネクションプールにおける全てのコネクションが完全に失われても、JIRA 、あるいは JIRA を実行中のアプリケーションサーバを再起動させる事無くコネクションを回復できます。

(warning) パフォーマンス上の留意点:

  • このオプションを設定すると、パフォーマンスに影響が及びますが、クエリそのものは素早く実行されるため、パフォーマンス上の全体的な影響は最低 限に保たれます。更に、このクエリが実行されるのは、コネクションが成立した場合においてのみとなります。よって、リクエストの間ずっとコネクションが保 たれると、クエリは一回のリクエストに対して一度のみしか発生しません。
  • 大きな JIRA インストレーションを実行している場合は、これがもたらすパフォーマンス上の影響を評価してから実装した方がよいかもしれません。
  • ラベルなし