How To
Summary
ロック・タイムアウト (SQL0911N RC=68) またはデッドロック (SQL0911N RC=2) が発生した場合、デフォルトでは db2dia.log には何も記録されず、詳細な状況調査にはあらかじめイベント・モニターを有効にしておく必要があります。
しかし、データベース構成パラメーター MON_LCK_MSG_LVL を 3 以上にしておくことで、ロック・タイムアウトやデッドロックの概要を db2diag.log に記録できます。
MON_LCK_MSG_LVL がデフォルトの 1 の場合、ロック・エスカレーションのみ記録されますが、2 にするとデッドロックも、3 にするとロック・タイムアウトも記録されます。
Steps
設定方法
- インスタンス・オーナーでデータベース・サーバーにログインします。
- 対象データベースに接続し、MON_LCK_MSG_LVL を変更します。(設定は動的に反映されます)
db2 connect to <データベース名> db2 update db cfg using MON_LCK_MSG_LVL 3
出力結果
- ロック・タイムアウトが発生すると、ADM5506W にロック所有者 (Owner) およびロック要求者 (Requester) のアプリケーション名やアプリケーション ID、競合したロックなどが記録されます。
2020-05-01-08.49.07.473527+540 E10783A1301 LEVEL: Warning PID : 10551608 TID : 3343 PROC : db2sysc 0 INSTANCE: db2inst1 NODE : 000 DB : SAMPLE APPHDL : 0-7 APPID: *LOCAL.db2inst1.200430234828 AUTHID : db2inst1 HOSTNAME: host1 EDUID : 3343 EDUNAME: db2agent (SAMPLE) 0 FUNCTION: DB2 UDB, database monitor, sqmLockEvents::collectLockEvent, probe:437 MESSAGE : ADM5506W The current unit of work was involved in an unresolved contention for use of an object. The type of the event is: "Lock timeout". The identifier of the lock on which this event happened is: "00050005000000000000000054". The timestamp of the event is: "2020-05-01-08.49.07.472566". The identifier of the member at which the event happened, and the identifier of the event is: "1". The affected application is named "db2bp" The application is associated with the workload named "SYSDEFAULTUSERWORKLOAD". The application identifier is: "*LOCAL.db2inst1.200430234828". The identifier of the member on which the application is running is: "0". The role that this application plays with respect to this lock is: "Requestor". 2020-05-01-08.49.07.475453+540 E12085A1302 LEVEL: Warning PID : 10551608 TID : 3343 PROC : db2sysc 0 INSTANCE: db2inst1 NODE : 000 DB : SAMPLE APPHDL : 0-7 APPID: *LOCAL.db2inst1.200430234828 AUTHID : db2inst1 HOSTNAME: host1 EDUID : 3343 EDUNAME: db2agent (SAMPLE) 0 FUNCTION: DB2 UDB, database monitor, sqmLockEvents::createLockOwnerRecord, probe:437 MESSAGE : ADM5506W The current unit of work was involved in an unresolved contention for use of an object. The type of the event is: "Lock timeout". The identifier of the lock on which this event happened is: "00050005000000000000000054". The timestamp of the event is: "2020-05-01-08.49.07.472566". The identifier of the member at which the event happened, and the identifier of the event is: "1". The affected application is named "db2bp" The application is associated with the workload named "SYSDEFAULTUSERWORKLOAD". The application identifier is: "*LOCAL.db2inst1.200430234846". The identifier of the member on which the application is running is: "0". The role that this application plays with respect to this lock is: "Owner".
- デッドロックが発生すると、ADM5506W にビクティム (Victim) および参加者 (Participant) のアプリケーション名やアプリケーション ID、競合したロックなどが記録されます。
2020-04-22-18.05.29.489094-420 E2243E1356 LEVEL: Warning PID : 2528734 TID : 139712438200064 PROC : db2sysc 0 INSTANCE: db2inst1 NODE : 000 DB : SAMPLE APPHDL : 0-11555 APPID: *LOCAL.db2inst1.200423010040 UOWID : 4 ACTID: 1 AUTHID : DB2INST1 HOSTNAME: host1 EDUID : 539 EDUNAME: db2agent (SAMPLE) 0 FUNCTION: DB2 UDB, database monitor, sqmLockEvents::collectLockEvent, probe:437 MESSAGE : ADM5506W The current unit of work was involved in an unresolved contention for use of an object. The type of the event is: "Deadlock". The identifier of the lock on which this event happened is: "03000700060000000000000052". The timestamp of the event is: "2020-04-22-18.05.29.488816". The identifier of the member at which the event happened, and the identifier of the event is: "3". The affected application is named "db2bp" The application is associated with the workload named "SYSDEFAULTUSERWORKLOAD". The application identifier is: "*LOCAL.db2inst1.200423010040". The identifier of the member on which the application is running is: "0". The role that this application plays with respect to this lock is: "Victim". 2020-04-22-18.05.29.490428-420 E3600E1361 LEVEL: Warning PID : 2528734 TID : 139712434005760 PROC : db2sysc 0 INSTANCE: db2inst1 NODE : 000 DB : SAMPLE APPHDL : 0-11506 APPID: *LOCAL.db2inst1.200423003652 UOWID : 7 ACTID: 2 AUTHID : DB2INST1 HOSTNAME: host1 EDUID : 194 EDUNAME: db2agent (SAMPLE) 0 FUNCTION: DB2 UDB, database monitor, sqmLockEvents::collectLockEvent, probe:437 MESSAGE : ADM5506W The current unit of work was involved in an unresolved contention for use of an object. The type of the event is: "Deadlock". The identifier of the lock on which this event happened is: "03000700050000000000000052". The timestamp of the event is: "2020-04-22-18.05.29.488816". The identifier of the member at which the event happened, and the identifier of the event is: "3". The affected application is named "db2bp" The application is associated with the workload named "SYSDEFAULTUSERWORKLOAD". The application identifier is: "*LOCAL.db2inst1.200423003652". The identifier of the member on which the application is running is: "0". The role that this application plays with respect to this lock is: "Participant".
報告されたロック名の詳細は MON_FORMAT_LOCK_NAME 表関数で確認できます。
例
- エラーを報告したデータベースに接続します。
db2 connect to <データベース名>
- MON_FORMAT_LOCK_NAME 表関数でロック ID の詳細を照会します。
以下の例ではロック名 00050005000000000000000054 は DB2INST1.T1 表の表ロックとわかります。db2 "SELECT SUBSTR(NAME,1,20) AS NAME, SUBSTR(VALUE,1,20) AS VALUE FROM TABLE( MON_FORMAT_LOCK_NAME('00050005000000000000000054')) as LOCK" NAME VALUE -------------------- ----------------- LOCK_OBJECT_TYPE TABLE TBSP_NAME USERSPACE1 TABSCHEMA DB2INST1 TABNAME T1 4 record(s) selected.
運用上の考慮点
デッドロックの情報を出力するには、デッドロックまたはロック・イベント・モニターが起動している必要があります。
データベース作成時、自動的にデッドロック・イベント・モニター (DB2DETAILDEADLOCK) が作成されて起動しますが、これを除去している場合はロック・イベント・モニターの作成を検討してください。
[Db2] ロック・イベント・モニターの設定方法
[Db2] DB2DETAILDEADLOCK イベント・モニターの再作成方法
データベース作成時、自動的にデッドロック・イベント・モニター (DB2DETAILDEADLOCK) が作成されて起動しますが、これを除去している場合はロック・イベント・モニターの作成を検討してください。
[Db2] ロック・イベント・モニターの設定方法
[Db2] DB2DETAILDEADLOCK イベント・モニターの再作成方法
Additional Information
Document Location
Worldwide
[{"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Product":{"code":"SSEPGG","label":"Db2 for Linux, UNIX and Windows"},"ARM Category":[{"code":"a8m0z000000cwHGAAY","label":"lock"}],"ARM Case Number":"","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"10.1.0;10.5.0;11.1.0;11.5.0;9.7.0","Line of Business":{"code":"LOB10","label":"Data and AI"}}]
Was this topic helpful?
Document Information
Modified date:
15 August 2023
UID
ibm16208205