死锁问题!求高手提点,有啥方向可以解决?
简单描述:
并发6个进程。
进程1:使用游标FETCH表KS.BJ_ENTRUST,使用WITH UR脏读。查询所有记录(大约1000条)
进程2-6:均统一操作流程UPDATE表KS.BJ_ENTRUST,选择条件为3个主键。每次更新一条记录,总更新1000条,平均下来每个进程更新200条左右记录,不重复。
问题现象:
会发生-911,主要卡在UPDATE语句中,不过频率很低,不是每次出现。
系统配置描述:
Interval for checking deadlock (ms) (DLCHKTIME) = 10000
Percent. of lock lists per application (MAXLOCKS) = 10
Lock timeout (sec) (LOCKTIMEOUT) = -1
使用db2expln,db2look进行分析,结果如下:
- SQL code
-------------------- SECTION ---------------------------------------Section = 2SQL Statement: SELECT COUNT(*)INTO :H00053 FROM SOC.BJ_ENTRUST WHERE ORDER_BUSINESS_CODE =:H00051 AND REPORT_STAT =:H00052 WITH URStatement Isolation Level = Uncommitted ReadSection Code Page = 1386Estimated Cost = 10803.450195Estimated Cardinality = 1.000000Access Table Name = KS.BJ_ENTRUST ID = 10,3075| #Columns = 0| Relation Scan| | Prefetch: Eligible| Isolation Level: Uncommitted Read| Lock Intents| | Table: Intent None| | Row : None| Sargable Predicate(s)| | #Predicates = 2| | Predicate Aggregation| | | Column Function(s)Aggregation Completion| Column Function(s)Return Data to Application| #Columns = 1End of sectionOptimizer Plan: RETURN ( 1) | GRPBY ( 2) | TBSCAN ( 3) | Table: KS BJ_ENTRUST -------------------- SECTION ---------------------------------------Section = 3SQL Statement: DECLARE GET_REV_BJE_CUSOR CURSOR WITH HOLD FOR SELECT MARKET_CODE, ORDER_BUSINESS_CODE, SEC_CODE, ENTRUST_DATE, CONTRACT_NO, REPORT_SEAT FROM SOC.BJ_ENTRUST WHERE ORDER_BUSINESS_CODE =:H00054 AND REPORT_STAT =:H00055 ORDER BY CONTRACT_NO FOR FETCH ONLY WITH URStatement Isolation Level = Uncommitted ReadSection Code Page = 1386Estimated Cost = 10803.473633Estimated Cardinality = 67.947197Access Table Name = KS.BJ_ENTRUST ID = 10,3075| #Columns = 6| Relation Scan| | Prefetch: Eligible| Isolation Level: Uncommitted Read| Lock Intents| | Table: Intent None| | Row : None| Sargable Predicate(s)| | #Predicates = 2| | Insert Into Sorted Temp Table ID = t1| | | #Columns = 6| | | #Sort Key Columns = 1| | | | Key 1: CONTRACT_NO (Ascending)| | | Sortheap Allocation Parameters:| | | | #Rows = 68| | | | Row Width = 40| | | PipedSorted Temp Table Completion ID = t1Access Temp Table ID = t1| #Columns = 6| Relation Scan| | Prefetch: Eligible| Sargable Predicate(s)| | Return Data to Application| | | #Columns = 6Return Data CompletionEnd of sectionOptimizer Plan: RETURN ( 1) | TBSCAN ( 2) | SORT ( 3) | TBSCAN ( 4) | Table: KS BJ_ENTRUST -------------------- SECTION ---------------------------------------Section = 4SQL Statement: UPDATE SOC.BJ_ENTRUST SET (ENTRUST_PRICE, CALL_PRICE, REPORT_STAT)=( :H00062 , :H00063 , :H00064 ) WHERE ORDER_BUSINESS_CODE =:H00065 AND ENTRUST_DATE =:H00066 AND CONTRACT_NO =:H00067 Section Code Page = 1386Estimated Cost = 61.697514Estimated Cardinality = 1.000000Access Table Name = KS.BJ_ENTRUST ID = 10,3075| Index Scan: Name = SYSIBM.SQL110602100446070 ID = 1| | Regular Index (Not Clustered)| | Index Columns:| | | 1: CONTRACT_NO (Ascending)| | | 2: ENTRUST_DATE (Ascending)| | | 3: ORDER_BUSINESS_CODE (Ascending)| #Columns = 0| Single Record| Fully Qualified Unique Key| #Key Columns = 3| | Start Key: Inclusive Value| | | | 1: ?| | | | 2: ?| | | | 3: ?| | Stop Key: Inclusive Value| | | | 1: ?| | | | 2: ?| | | | 3: ?| Data Prefetch: None| Index Prefetch: None| Lock Intents| | Table: Intent Exclusive| | Row : ExclusiveUpdate: Table Name = KS.BJ_ENTRUST ID = 10,3075End of sectionOptimizer Plan: UPDATE ( 2) /---/ \ FETCH Table: ( 3) KS /-/ \ BJ_ENTRUST IXSCAN Table: ( 3) KS | BJ_ENTRUST Index: SYSIBM SQL110602100446070