DB2 9.5 中的锁定超时分析新方法
2008-07-07 16:24:14 来源:WEB开发网收集 SQL 语句的历史信息
为了获得锁持有者的应用程序执行的 SQL 语句的信息,我们使用 DETAILS HISTORY 选项创建一个死锁事件监视器并激活它。例如,可以通过如下方法创建一个恰当的死锁事件监视器并将其激活:
清单 8. 使用 DETAILS HISTORY 选项创建死锁事件监视器
db2 "CREATE EVENT MONITOR evmondeadlock FOR DEADLOCKS WITH DETAILS HISTORY
WRITE TO FILE 'path'"
db2 "SET EVENT MONITOR evmondeadlock STATE 1"
您可能会问:“为什么需要死锁事件监视器来监视锁定超时?”答案是构建锁定超时报告需要用到死锁事件监视器代码交付的功能。使用 DETAILS HISTORY 选项创建死锁事件监视器时,DB2 跟踪已经在事务中执行的 SQL 语句。如果发生死锁或锁定超时,这个信息可用于提供 SQL 语句的历史信息,这些 SQL 语句可能与死锁或锁定超时的发生有关。
激活了死锁事件监视器之后,再次运行上面描述的锁定超时场景。这次 DB2 编写一个锁定超时报告,如清单 9 所示:
清单 9. 包含 SQL 语句历史信息的锁定超时报告
LOCK TIMEOUT REPORT
Date: 03/01/2008
Time: 15:10:13
Instance: DB2
Database: SAMPLE
Database Partition: 0
Lock Information:
Lock Name: 02000600040040010000000052
Lock Type: Row
Lock Specifics: Tablespace ID=2, Table ID=6, Row ID=x0400400100000000
Lock Requestor:
System Auth ID: FECHNER
Application Handle: [0-202]
Application ID: *LOCAL.DB2.080103140934
Application Name: db2bp.exe
Requesting Agent ID: 2356
Coordinator Agent ID: 2356
Coordinator Partition: 0
Lock timeout Value: 10000 milliseconds
Lock mode requested: ..U
Application Status: (SQLM_UOWEXEC)
Current Operation: (SQLM_EXECUTE_IMMEDIATE)
Lock Escalation: No
Context of Lock Request:
Identification: UOW ID (1); Activity ID (1)
Activity Information:
Package Schema: (NULLID )
Package Name: (SQLC2G13NULLID )
Package Version: ()
Section Entry Number: 203
SQL Type: Dynamic
Statement Type: DML, Insert/Update/Delete
Effective Isolation: Cursor Stability
Statement Unicode Flag: No
Statement: UPDATE EMPLOYEE SET BONUS = SALARY * 0.1
WHERE JOB = 'MANAGER'
Lock Owner (Representative):
System Auth ID: FECHNER
Application Handle: [0-188]
Application ID: *LOCAL.DB2.080103140511
Application Name: db2bp.exe
Requesting Agent ID: 5488
Coordinator Agent ID: 5488
Coordinator Partition: 0
Lock mode held: ..X
List of Active SQL Statements: Not available
List of Inactive SQL Statements from current UOW:
Entry: #1
Identification: UOW ID (6); Activity ID (2)
Package Schema: (NULLID )
Package Name: (SQLC2G13)
Package Version: ()
Section Entry Number: 201
SQL Type: Dynamic
Statement Type: DML, Select (blockable)
Effective Isolation: Cursor Stability
Statement Unicode Flag: No
Statement: SELECT LASTNAME, FIRSTNME, SALARY FROM EMPLOYEE
ORDER BY LASTNAME ASC
Entry: #2
Identification: UOW ID (6); Activity ID (1)
Package Schema: (NULLID )
Package Name: (SQLC2G13)
Package Version: ()
Section Entry Number: 203
SQL Type: Dynamic
Statement Type: DML, Insert/Update/Delete
Effective Isolation: Cursor Stability
Statement Unicode Flag: No
Statement: UPDATE EMPLOYEE SET SALARY = SALARY * 1.02
- ››db2 对float类型取char后显示科学计数法
- ››DB2中出现SQL1032N错误现象时的解决办法
- ››DB2 锁升级示例
- ››db2诊断系列之---定位锁等待问题
- ››db2 命令选项解释
- ››DB2 最佳实践: 使用 DB2 pureXML 管理 XML 数据的...
- ››DB2 9.5 SQL Procedure Developer 认证考试 735 准...
- ››DB2 9.5 SQL Procedure Developer 认证考试 735 准...
- ››DB2 9.5 SQL Procedure Developer 认证考试 735 准...
- ››DB2 基础: 表空间和缓冲池
- ››DB2 XML 编程,第 1 部分: 理解 XML 数据模型
- ››DB2 pureScale 实战
更多精彩
赞助商链接