データベース接続のチューニング

Jira uses a database connection pool, based on Apache Commons DBCP (DataBase Connection Pool), to manage Jira's access to its underlying database.

In earlier Jira versions, the database connection pool was handled purely through the Apache Tomcat application server running Jira. However, from Jira version 4.4, Jira's dbconfig.xml file provides a set of database connection pool settings to Tomcat, which in turn are used by Tomcat to manage Jira's database connection pool. From JIRA version 5.1, the number database connection pool settings defined in Jira's dbconfig.xml file substantially increased.

The information on this page can help you tweak Jira's database connection pool settings. You can do this by using the Jira configuration tool or by directly editing Jira's dbconfig.xml file, as described below.

The Advanced tab of the Jira Configuration Tool makes it easier to both configure and control Jira's database connection pool. The Database monitoring page (accessible to Jira system administrators) provides a visual tool for monitoring Jira's database connection usage.

接続プールアーキテクチャー

Whenever Jira needs to access (i.e. read from or write to) its database, a database connection is required.

A database connection is a large and complex object that handles all communication between Jira and its database. As such, database connections are time consuming to establish and consume a significant amount of memory on both the client (the Jira application) and database server.

To avoid the impact of creating a new database connection for each database access request made by Jira, a pool of pre-established database connections is maintained. Each new database access request made by Jira uses a connection from this pool of pre-established connections, as required. Hence:

  1. Jira の起動時にはプール内で Jira とそのデータベース間の最小限のデータベース コネクションが確立されます。
  2. When Jira needs to access its database, Jira:
    1. プールに対してデータベース接続を要求します
    2. そのデータベース接続を使用してデータベースの読み出しまたは書き込みを行います
    3. 処理が終了するとデータベース接続をプールに戻します。

If the frequency of Jira's database access requests begin to exceed the number of available database connections in the pool, extra connections are automatically created to handle the load.

Conversely, if the frequency of Jira's database access requests begin to drop below the number of available database connections in the pool, connections can be automatically closed to release resources back to the system.

最近のデータベースは多数の接続を比較的簡単に処理することが可能で、メモリーさえ十分にあれば同時接続可能数は数百にもなります。ただし、クライ アント側では接続は大量のメモリーを消費します。従って、最大接続数をそれよりずっと小さい数に制限して、接続する必要が生じたアプリケーションがほぼ待 つことなく接続を利用できるようにするのが一般的です。

Jira のデータベース コネクションの調整

  1. Jira のインストール環境をシャットダウンします。
  2. 次のいずれかを行います。
    • Use the Jira configuration tool to tune Jira's database connections.
      1. Start the Jira configuration tool:
        (info) Please Note: You may need to set the JAVA_HOME environment variable to run the Jira configuration tool. See Installing Java for details.
      2. Once the Jira configuration tool is running, click its Advanced tab.
      3. Refer to Connection pool settings below for more information about the options on this tab. To specify a value for one of these options, ensure its leftmost checkbox has been selected first.
        (info) Some options above are simple checkboxes (i.e. in the centre of the JIRA configuration tool). Selecting these checkboxes sets the values of their associated options to 'true'. Conversely, clearing these checkboxes sets the values of their associated options to 'false'.
      4. [Save] ボタンをクリックして変更を保存すると、dbconfig.xml ファイルの要素として格納されます。
    • または、Jira ホーム ディレクトリのルートにある dbconfig.xml ファイルを編集します。
      1. Refer to Connection pool settings below for more information about the elements you can add to your dbconfig.xml file to fine tune Jira's database connection.
      2. 編集済みの dbconfig.xml ファイルを保存します。
  3. Jira のインストール環境を再起動します。

接続プールの設定

Jira configuration tool 'Advanced' tab option

 dbconfig.xml の要素
説明
推奨事項/注意事項
デフォルト値*
最大サイズ

pool-max-size

同時にオープン可能なデータベース接続の最大数。

This value should be sufficiently large enough that Jira rarely needs to wait for a database connection to become available when Jira requires one.

このパラメーターの設定方法に関連するヒントは、下の「監視」の項目をご覧ください。

20

最大アイドル状態

pool-max-idle

プール内でアイドル状態のまま保持可能なデータベース接続の最大数。

この値を負に設定すると、プール内でアイドル状態のまま存在可能なデータベース接続の最大数は無制限になります。

下で説明する Minimum Idle/Size の値が上で説明した Maximum Size の値と同一の場合 (デフォルトではこれが成立します) は、この設定は無意味になります。

Maximum Size の値

最小アイドル状態/サイズ

pool-min-size

(min-idle)

同時にオープンしているアイドル状態のデータベース接続の最小数。

この値を上で説明した Maximum Size と同一にすると (デフォルトではこれが成立します)、プールにおける接続数は一定でアイドル接続がクローズされることはありません。

On very large Jira installations, there may be some benefit in specifying a lower value for this setting than that of Maximum Size, to conserve resources.

Maximum Size の値

初期サイズ

pool-initial-size

プール内でオープンされるデータベース接続の初期値。

This setting is not usually configured (other than the default value of 0), since a number of database connections are quickly created when Jira starts up.

0
(dbconfig.xml で指定されていない場合)

最大待機時間

pool-max-wait

The length of time (in milliseconds) that Jira is allowed to wait for a database connection to become available (while there are no free ones available in the pool), before returning an error.

'-1' を指定すると Tomcat の待ち時間は無期限となります。

この値は、競合が発生してもそれに対応できる程度に十分長い時間としなければならないと同時に、無応答やブラウザータイムアウトとなる前にユーザーに対して適切なエラー情報を提供できる程度に短い時間でなければなりません。

30000

高度な設定

通常は以下の設定を変更する必要はありません。必要ならば、Apache DBCP ドキュメントをご覧ください。

プールステートメント

pool-prepared-statements

データベース接続プールにおいてプリペアドステートメントのプーリングを有効にします。

Do not amend the default value of false, as it will cause exceptions. For more information see JRASERVER-44908 - DBPC configuration pool-prepared-statements leads to Statement Leak Closed

false
(dbconfig.xml で指定されていない場合)

最大オープンステートメント

max-open-prepared-statements

ステートメントプールから同時に割り当て可能な空きステートメントの最大数。

例外の原因となるため、デフォルト値を修正しないでください

0
(dbconfig.xml で指定されていない場合)

バリデーションクエリ

validation-query

接続プールから取り出された接続の検証を行う SQL クエリです。指定する場合、クエリは少なくとも1つの行を返す SQL SELECT 文でなければなりません。

詳細については、 コネクション切断の問題を乗り越える方法 を参照してください。

select 1
(MySQL の場合)

(または、dbconfig.xml で指定なし)

バリデーションクエリのタイムアウト

validation-query-timeout

検証クエリがデータベース接続の破損を検出するまでのシステム待ち時間 (単位は秒)。

検証クエリは処理量の小さいものを使用するためこの時間は非常に短い時間で構いません。

上で Validation Query を指定した場合は Validation Query Timeout の値も指定しなければなりません。指定しない場合は '-1' が設定され、データベースの破損が起こっていない場合でも、システムは破損を無期限に待ち続けます。

(warning) This should only be done for MySQL. Using a Validation Query Timeout on any database other than MySQL will cause significant problems with the Jira instance.

3
(MySQL の場合)

(または、dbconfig.xml で指定なし)

借りるときにテスト

pool-test-on-borrow

Tests if the database connection is valid when it is borrowed from the database connection pool by Jira.

そのデータベース接続が破損している場合はプールから削除されます。

This value should always be 'false' as Jira borrows a connection for each database operation.

(tick) If you continue to have problems with database connections closing, try setting this option to 'true'. However, this should only be used as a last resort and only in the event that decreasing the value of Time Between Eviction Runs has not reduced or prevented problems with database connections closing.

True (dbconfig.xml で指定されていない場合)。ただし、バリデーション クエリが明示的に指定されていない場合、この設定は有効になりませんMySQL は既定のバリデーション クエリを備えているため、この影響を受けます。

返却時にテスト

pool-test-on-return

Tests if the database connection is valid when it is returned to the database connection pool by Jira.

そのデータベース接続が破損している場合はプールから削除されます。

This value should always be 'false' as Jira returns borrowed connections for each database operation.

false
(dbconfig.xml で指定されていない場合)

アイドル状態にテスト

pool-test-while-idle

データベース接続がアイドル状態のときに正しく機能しているか否かを定期的にテストします。

そのデータベース接続が破損している場合はプールから削除されます。

MySQL の場合はこれを 'true' にします。

By default, MySQL database servers close database connections if they are not used for an extended period of time. This causes problems with Jira installations (which use MySQL databases) that are largely inactive for long periods, e.g. overnight. Setting this to 'true' will work around this behavior.

なお、Test While Idle の指定が必要となるのは、上で説明した Validation Query を指定したときのみです。

true
(MySQL の場合)

false
(dbconfig.xml で指定されていない場合)

追い出し実行間の時間

time-between-eviction-runs-millis

アイドルオブジェクトのエビクションスレッド実行間隔 (単位はミリ秒)。ゼロまたは負の値を指定するとアイドルオブジェクトのエビクションスレッドは実行されません。

エビクションスレッドは、アイドル状態にあるデータベース接続数が上で説明した Minimum Idle/Size を超えたときにアイドル状態にあるデータベース接続を削除します。

MySQL の場合、接続のエビクションとテストを正常に行うためにはこのパラメーターを大きめの正の値に設定します。一般的に妥当な値は300000 (5 分) です。

(tick) テータベース接続のクローズがうまくいかないという問題が定常的に発生する場合はこのオプション値を小さめにしてみてください。

300000
(MySQL の場合)

5000
(HSQLDB の場合)

(または、dbconfig.xml で指定なし)

追い出し可能な最小限のアイドル時間

min-evictable-idle-time-millis

アイドルオブジェクトのエビクションを実行する場合に、データベース接続プール内のオブジェクトがアイドルオブジェクトエビクションの対象となるまでのアイドル状態最小時間。


60000
(MySQL の場合)

4000
(HSQLDB の場合)

(または、dbconfig.xml で指定なし)

クローズ漏れの削除

pool-remove-abandoned

データベース接続のクローズ漏れ状態が次の Removed Abandoned Timeout で指定した時間を超えたときにそれを削除するか否かのフラグ。

If an internal failure occurs, it is possible that Jira may borrow a connection and never return it. If this happens too often, then the pool may run short of database connections, causing Jira's performance to degrade or Jira to fail altogether.

この値は 'true' にします。

これによってクローズ漏れ状態の接続を整理してプール内の接続数を回復し、システムパフォーマンスの低下を防止します。

true

クローズ漏れの削除のタイムアウト

pool-remove-abandoned-timeout

データベース接続がクローズ漏れと判定されるまでのアイドル状態継続時間 (単位は秒)。


300

* (info) Please note:

  • Jira writes elements with their default values (in the right-hand column of the table above) to the dbconfig.xml file after:
    • Jira セットアップ ウィザード を最後まで実行したとき。
    • You use the Advanced tab of the Jira configuration tool to configure/tune your database connection — even when the leftmost checkboxes of options associated with these elements have not been selected.
  • ただし、値の下に '(dbconfig.xml で指定されていない場合)' と表示されている要素は例外です。これらの要素は次のようになります。
    • Jira セットアップ ウィザードを最後まで実行したあとは、dbconfig.xml には書き込まれません。
    • 次の場合にのみ dbconfig.xml ファイルへの書き込みが行われます:
      • このファイルを手作業で書き換えたとき
      • Using the Advanced tab of the Jira configuration tool, selecting the leftmost checkboxes of the options associated with these elements and specifying values for these options.
  • 上述の表の一番右の列で、既定値の下に "(dbconfig.xml で指定されていない場合)" と表示されている要素では、dbconfig.xml ファイルに要素が存在しない場合でも既定値が適用されます。

接続プールの監視

Jira provides a view of its database connection usage via the 'Database Monitoring' page. See Monitoring database connection usage for more information.

Last modified on Mar 26, 2019

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.